UNPKG

sheercms

Version:

Sheer Cliff CMS is a simple and powerful content management system (CMS) for Node JS.

91 lines (72 loc) 2.54 kB
var NewItemDialogController = function ($scope, $modalInstance, ContentService, groupId, startDate, endDate, types) { $scope.types = types; $scope.dialog = { title: "New Item", message: "", messageType: "" }; $scope.newItem = { name: "", typeId: null, groupId: groupId, startDate: startDate, endDate: endDate }; $scope.selectType = function(t) { $scope.newItem.typeId = t._id; $scope.newItem.templateId = t.defaultTemplateId; }; $scope.ok = function() { if (!isNullOrEmpty($scope.newItem.name) && !isNullOrEmpty($scope.newItem.typeId)) { $scope.dialog.message = "Creating the new content item...please wait."; $scope.dialog.messageType = "alert-info"; ContentService.create($scope.newItem.name, $scope.newItem.groupId, $scope.newItem.typeId, $scope.newItem.templateId, $scope.newItem.startDate, $scope.newItem.endDate).then(function(result) { if (result.success == true) { $modalInstance.close(result.contentId); } else { $scope.dialog.message = result.message; $scope.dialog.messageType = "alert-danger"; } }); } else { $scope.dialog.message = "Both the name and template are required."; $scope.dialog.messageType = "alert-danger"; } }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; function isNullOrEmpty(s) { return (s && s.length > 0) ? false : true; } function init() { //if there is only one allowed template, pre-select it. if ($scope.types && $scope.types.length === 1) { $scope.newItem.typeId = $scope.types[0]._id; } } init(); }; var ImagePreviewDialogController = function ($scope, $modalInstance, $location, item) { $scope.item = item; $scope.dialog = { title: "Image Preview", imageUrl: "", imageAlt: "" }; $scope.editItem = function() { $modalInstance.dismiss('cancel'); $location.path('/edit/' + $scope.item.contentId); }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; function init() { $scope.dialog.title = item.name; $scope.dialog.imageUrl = item.url + "?cmsmode=preview"; $scope.dialog.imageAlt = item.name; } init(); };