Fix: Allowed types for creation don't update

This commit is contained in:
Kenn Jacobsen
2019-02-12 09:42:00 +01:00
committed by Sebastiaan Janssen
parent 5a482a49bf
commit c1de832c4b
2 changed files with 23 additions and 7 deletions

View File

@@ -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);

View File

@@ -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);
angular.module('umbraco').controller("Umbraco.Editors.Media.CreateController", mediaCreateController);