diff --git a/src/Umbraco.Web.UI.Client/.jshintignore b/src/Umbraco.Web.UI.Client/.jshintignore deleted file mode 100644 index 97620d1820..0000000000 --- a/src/Umbraco.Web.UI.Client/.jshintignore +++ /dev/null @@ -1 +0,0 @@ -src/common/services/util.service.js \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 264c8f140d..0586651842 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -252,6 +252,19 @@ }); } + function clearNotifications(content) { + if (content.notifications) { + content.notifications = []; + } + if (content.variants) { + for (var i = 0; i < content.variants.length; i++) { + if (content.variants[i].notifications) { + content.variants[i].notifications = []; + } + } + } + } + function resetLastListPageNumber(content) { // We're using rootScope to store the page number for list views, so if returning to the list // we can restore the page. If we've moved on to edit a piece of content that's not the list or it's children @@ -341,7 +354,7 @@ }; $scope.saveAndPublish = function () { - + clearNotifications($scope.content); // TODO: Add "..." to publish button label if there are more than one variant to publish - currently it just adds the elipses if there's more than 1 variant if (showSaveOrPublishDialog()) { //before we launch the dialog we want to execute all client side validations first @@ -355,13 +368,16 @@ submitButtonLabel: "Publish", submit: function (model) { model.submitButtonState = "busy"; - + clearNotifications($scope.content); //we need to return this promise so that the dialog can handle the result and wire up the validation response return performSave({ saveMethod: contentResource.publish, action: "publish", showNotifications: false }).then(function (data) { + //show all notifications manually here since we disabled showing them automatically in the save method + formHelper.showNotifications(data); + clearNotifications($scope.content); overlayService.close(); return $q.when(data); }, @@ -369,7 +385,6 @@ model.submitButtonState = "error"; //re-map the dialog model since we've re-bound the properties dialog.variants = $scope.content.variants; - //don't reject, we've handled the error return $q.when(err); }); @@ -390,7 +405,7 @@ }; $scope.save = function () { - + clearNotifications($scope.content); // TODO: Add "..." to save button label if there are more than one variant to publish - currently it just adds the elipses if there's more than 1 variant if (showSaveOrPublishDialog()) { //before we launch the dialog we want to execute all client side validations first @@ -404,13 +419,16 @@ submitButtonLabel: "Save", submit: function (model) { model.submitButtonState = "busy"; - + clearNotifications($scope.content); //we need to return this promise so that the dialog can handle the result and wire up the validation response return performSave({ saveMethod: $scope.saveMethod(), action: "save", showNotifications: false }).then(function (data) { + //show all notifications manually here since we disabled showing them automatically in the save method + formHelper.showNotifications(data); + clearNotifications($scope.content); overlayService.close(); return $q.when(data); }, @@ -418,7 +436,6 @@ model.submitButtonState = "error"; //re-map the dialog model since we've re-bound the properties dialog.variants = $scope.content.variants; - //don't reject, we've handled the error return $q.when(err); }); diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index 5fb6fe1625..e879c3aca0 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -26,12 +26,14 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { /** internal method process the saving of data and post processing the result */ - function saveContentItem(content, action, files, restApiUrl) { + function saveContentItem(content, action, files, restApiUrl, showNotifications) { + return umbRequestHelper.postSaveContent({ restApiUrl: restApiUrl, content: content, action: action, files: files, + showNotifications: showNotifications, dataFormatter: function (c, a) { return umbDataFormatter.formatContentPostData(c, a); } @@ -632,22 +634,23 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { * * @param {Object} content The content item object with changes applied * @param {Bool} isNew set to true to create a new item or to update an existing - * @param {Array} files collection of files for the document + * @param {Array} files collection of files for the document + * @param {Bool} showNotifications an option to disable/show notifications (default is true) * @returns {Promise} resourcePromise object containing the saved content item. * */ - save: function (content, isNew, files) { + save: function (content, isNew, files, showNotifications) { var endpoint = umbRequestHelper.getApiUrl( "contentApiBaseUrl", "PostSave"); - return saveContentItem(content, "save" + (isNew ? "New" : ""), files, endpoint); + return saveContentItem(content, "save" + (isNew ? "New" : ""), files, endpoint, showNotifications); }, - saveBlueprint: function (content, isNew, files) { + saveBlueprint: function (content, isNew, files, showNotifications) { var endpoint = umbRequestHelper.getApiUrl( "contentApiBaseUrl", "PostSaveBlueprint"); - return saveContentItem(content, "save" + (isNew ? "New" : ""), files, endpoint); + return saveContentItem(content, "save" + (isNew ? "New" : ""), files, endpoint, showNotifications); }, /** @@ -674,15 +677,16 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { * * @param {Object} content The content item object with changes applied * @param {Bool} isNew set to true to create a new item or to update an existing - * @param {Array} files collection of files for the document + * @param {Array} files collection of files for the document + * @param {Bool} showNotifications an option to disable/show notifications (default is true) * @returns {Promise} resourcePromise object containing the saved content item. * */ - publish: function (content, isNew, files) { + publish: function (content, isNew, files, showNotifications) { var endpoint = umbRequestHelper.getApiUrl( "contentApiBaseUrl", "PostSave"); - return saveContentItem(content, "publish" + (isNew ? "New" : ""), files, endpoint); + return saveContentItem(content, "publish" + (isNew ? "New" : ""), files, endpoint, showNotifications); }, diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js index 9fe3324a8f..b5251cfeca 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js @@ -66,7 +66,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica args.scope.busy = true; - return args.saveMethod(args.content, $routeParams.create, fileManager.getFiles()) + return args.saveMethod(args.content, $routeParams.create, fileManager.getFiles(), args.showNotifications) .then(function (data) { formHelper.resetForm({ scope: args.scope }); @@ -439,8 +439,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica var shouldIgnore = function (propName) { return _.some([ "variants", - "notifications", - "ModelState", + "tabs", "properties", "apps", diff --git a/src/Umbraco.Web.UI.Client/src/common/services/umbrequesthelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/umbrequesthelper.service.js index 228c885529..1619ca0623 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/umbrequesthelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/umbrequesthelper.service.js @@ -136,8 +136,8 @@ function umbRequestHelper($http, $q, umbDataFormatter, angularHelper, dialogServ //create the callbacs based on whats been passed in. var callbacks = { - success: ((!opts || !opts.success) ? defaultSuccess : opts.success), - error: ((!opts || !opts.error) ? defaultError : opts.error) + success: (!opts || !opts.success) ? defaultSuccess : opts.success, + error: (!opts || !opts.error ? defaultError : opts.error) }; return httpPromise.then(function (response) { @@ -156,7 +156,7 @@ function umbRequestHelper($http, $q, umbDataFormatter, angularHelper, dialogServ //this is a JS/angular error that we should deal with return $q.reject({ errorMsg: response.message - }) + }); } //invoke the callback @@ -188,12 +188,22 @@ function umbRequestHelper($http, $q, umbDataFormatter, angularHelper, dialogServ errorMsg: result.errorMsg, data: result.data, status: result.status - }) + }); }); }, - /** Used for saving content/media/members specifically */ + /** + * @ngdoc method + * @name umbraco.resources.contentResource#postSaveContent + * @methodOf umbraco.resources.contentResource + * + * @description + * Used for saving content/media/members specifically + * + * @param {Object} args arguments object + * @returns {Promise} http promise object. + */ postSaveContent: function (args) { if (!args.restApiUrl) { @@ -211,6 +221,9 @@ function umbRequestHelper($http, $q, umbDataFormatter, angularHelper, dialogServ if (!args.dataFormatter) { throw "args.dataFormatter is a required argument"; } + if (args.showNotifications === null || args.showNotifications === undefined) { + args.showNotifications = true; + } //save the active tab id so we can set it when the data is returned. var activeTab = _.find(args.content.tabs, function (item) { @@ -246,7 +259,9 @@ function umbRequestHelper($http, $q, umbDataFormatter, angularHelper, dialogServ response.data.tabs[activeTabIndex].active = true; } - formHelper.showNotifications(response.data); + if (args.showNotifications) { + formHelper.showNotifications(response.data); + } //TODO: Do we need to pass the result through umbDataFormatter.formatContentGetData? Right now things work so not sure but we should check @@ -278,7 +293,7 @@ function umbRequestHelper($http, $q, umbDataFormatter, angularHelper, dialogServ } } - else { + else if (args.showNotifications) { formHelper.showNotifications(response.data); } diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html index b49046feac..78463fcee0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html @@ -27,7 +27,7 @@ * -