From 20e12644e50392d7bcad41b4cef8da3e4cacc83c Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Thu, 14 Feb 2019 16:48:39 +0100 Subject: [PATCH] v8: Fix saving infinite spinner (#4453) --- .../content.createblueprint.controller.js | 4 -- .../dictionary/dictionary.edit.controller.js | 3 +- .../views/relationtypes/edit.controller.js | 7 ++- .../src/views/templates/edit.controller.js | 48 +++++++++---------- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.createblueprint.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.createblueprint.controller.js index 361ce36b72..c0002220e3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.createblueprint.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.createblueprint.controller.js @@ -3,7 +3,6 @@ function CreateBlueprintController( $scope, contentResource, - notificationsService, navigationService, localizationService, formHelper, @@ -13,13 +12,10 @@ name: $scope.currentNode.name }; - var successText = {}; localizationService.localize("blueprints_createBlueprintFrom", ["" + $scope.message.name + ""]).then(function (localizedVal) { $scope.title = localizedVal; }); - - $scope.cancel = function () { navigationService.hideMenu(); }; diff --git a/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.edit.controller.js index f91e0ac2c3..596f848abe 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.edit.controller.js @@ -84,8 +84,7 @@ function DictionaryEditController($scope, $routeParams, $location, dictionaryRes formHelper.resetForm({ scope: $scope, notifications: data.notifications }); - bindDictionary(data); - + bindDictionary(data); vm.page.saveButtonState = "success"; }, diff --git a/src/Umbraco.Web.UI.Client/src/views/relationtypes/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/relationtypes/edit.controller.js index 9ae3813bd2..1667a89c35 100644 --- a/src/Umbraco.Web.UI.Client/src/views/relationtypes/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/relationtypes/edit.controller.js @@ -106,13 +106,17 @@ function RelationTypeEditController($scope, $routeParams, relationTypeResource, } function saveRelationType() { - vm.page.saveButtonState = "busy"; if (formHelper.submitForm({ scope: $scope, statusMessage: "Saving..." })) { + + vm.page.saveButtonState = "busy"; + relationTypeResource.save(vm.relationType).then(function (data) { formHelper.resetForm({ scope: $scope, notifications: data.notifications }); bindRelationType(data); + vm.page.saveButtonState = "success"; + }, function (error) { contentEditingHelper.handleSaveError({ redirectOnFailure: false, @@ -120,6 +124,7 @@ function RelationTypeEditController($scope, $routeParams, relationTypeResource, }); notificationsService.error(error.data.message); + vm.page.saveButtonState = "error"; }); } diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index dee2705638..d17f556b2f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -73,7 +73,6 @@ templateHelper.getTemplateEditorShortcuts().then(function(data){ vm.page.keyboardShortcutsOverview.push(data); }); - vm.save = function (suppressNotification) { vm.page.saveButtonState = "busy"; @@ -84,7 +83,7 @@ saveMethod: templateResource.save, scope: $scope, content: vm.template, - //We do not redirect on failure for templates - this is because it is not possible to actually save the template + // We do not redirect on failure for templates - this is because it is not possible to actually save the template // type when server side validation fails - as opposed to content where we are capable of saving the content // item if server side validation fails redirectOnFailure: false, @@ -160,10 +159,10 @@ vm.init = function () { - //we need to load this somewhere, for now its here. + // we need to load this somewhere, for now its here. assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css", $scope); - //load templates - used in the master template picker + // load templates - used in the master template picker templateResource.getAll() .then(function(templates) { vm.templates = templates; @@ -186,22 +185,21 @@ vm.page.loading = false; vm.template = template; - // if this is a new template, bind to the blur event on the name - if (create) { - $timeout(function() { - var nameField = angular.element(document.querySelector('[data-element="editor-name-field"]')); - if (nameField) { - nameField.on('blur', function(event) { - if (event.target.value) { - vm.save(true); - } - }); - } - }); - } + // if this is a new template, bind to the blur event on the name + if (create) { + $timeout(function() { + var nameField = angular.element(document.querySelector('[data-element="editor-name-field"]')); + if (nameField) { + nameField.on('blur', function(event) { + if (event.target.value) { + vm.save(true); + } + }); + } + }); + } - - //sync state + // sync state if(!infiniteMode) { editorState.set(vm.template); navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) { @@ -229,19 +227,19 @@ //Update the auto-complete method to use ctrl+alt+space _editor.commands.bindKey("ctrl-alt-space", "startAutocomplete"); - //Unassigns the keybinding (That was previously auto-complete) - //As conflicts with our own tree search shortcut + // Unassigns the keybinding (That was previously auto-complete) + // As conflicts with our own tree search shortcut _editor.commands.bindKey("ctrl-space", null); // Assign new keybinding _editor.commands.addCommands([ - //Disable (alt+shift+K) - //Conflicts with our own show shortcuts dialog - this overrides it + // Disable (alt+shift+K) + // Conflicts with our own show shortcuts dialog - this overrides it { name: 'unSelectOrFindPrevious', bindKey: 'Alt-Shift-K', exec: function() { - //Toggle the show keyboard shortcuts overlay + // Toggle the show keyboard shortcuts overlay $scope.$apply(function(){ vm.showKeyboardShortcut = !vm.showKeyboardShortcut; }); @@ -333,7 +331,7 @@ }); } - //change on blur, focus + // change on blur, focus vm.editor.on("blur", persistCurrentLocation); vm.editor.on("focus", persistCurrentLocation); vm.editor.on("change", changeAceEditor);