From c1de832c4b1335ba8a70f457faa1e8ef8300b0fb Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 12 Feb 2019 09:42:00 +0100 Subject: [PATCH] Fix: Allowed types for creation don't update --- .../content/content.create.controller.js | 9 +++++++- .../views/media/media.create.controller.js | 21 +++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js index 9fbf342435..f101450705 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js @@ -17,6 +17,7 @@ function contentCreateController($scope, var mainCulture = $routeParams.mculture ? $routeParams.mculture : null; function initialize() { + $scope.allowedTypes = null; contentTypeResource.getAllowedTypes($scope.currentNode.id).then(function (data) { $scope.allowedTypes = iconHelper.formatContentTypeIcons(data); }); @@ -80,7 +81,13 @@ function contentCreateController($scope, $scope.createOrSelectBlueprintIfAny = createOrSelectBlueprintIfAny; $scope.createFromBlueprint = createFromBlueprint; - initialize(); + // the current node changes behind the scenes when the context menu is clicked without closing + // the default menu first, so we must watch the current node and re-initialize accordingly + var unbindModelWatcher = $scope.$watch("currentNode", initialize); + $scope.$on('$destroy', function () { + unbindModelWatcher(); + }); + } angular.module("umbraco").controller("Umbraco.Editors.Content.CreateController", contentCreateController); diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.create.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.create.controller.js index 0f409d35c3..487f53a5ba 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/media.create.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/media/media.create.controller.js @@ -7,10 +7,13 @@ * The controller for the media creation dialog */ function mediaCreateController($scope, $routeParams, $location, mediaTypeResource, iconHelper, navigationService) { - - mediaTypeResource.getAllowedTypes($scope.currentNode.id).then(function(data) { - $scope.allowedTypes = iconHelper.formatContentTypeIcons(data); - }); + + function initialize() { + $scope.allowedTypes = null; + mediaTypeResource.getAllowedTypes($scope.currentNode.id).then(function(data) { + $scope.allowedTypes = iconHelper.formatContentTypeIcons(data); + }); + } $scope.createMediaItem = function(docType) { $location.path("/media/media/edit/" + $scope.currentNode.id).search("doctype", docType.alias).search("create", "true"); @@ -21,7 +24,13 @@ function mediaCreateController($scope, $routeParams, $location, mediaTypeResourc const showMenu = true; navigationService.hideDialog(showMenu); }; - + + // the current node changes behind the scenes when the context menu is clicked without closing + // the default menu first, so we must watch the current node and re-initialize accordingly + var unbindModelWatcher = $scope.$watch("currentNode", initialize); + $scope.$on('$destroy', function () { + unbindModelWatcher(); + }); } -angular.module('umbraco').controller("Umbraco.Editors.Media.CreateController", mediaCreateController); \ No newline at end of file +angular.module('umbraco').controller("Umbraco.Editors.Media.CreateController", mediaCreateController);