diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js index 2d3a8e2238..eb9971d83a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontent.directive.js @@ -23,7 +23,7 @@ controllerAs: 'vm', controller: umbVariantContentController }; - + function umbVariantContentController($scope) { var unsubscribe = []; @@ -41,20 +41,19 @@ vm.showBackButton = showBackButton; function onInit() { - + // Make copy of apps, so we can have a variant specific model for the App. (needed for validation etc.) vm.editor.variantApps = Utilities.copy(vm.content.apps); var activeApp = vm.content.apps.find((app) => app.active); onAppChanged(activeApp); - } - + function showBackButton() { return vm.page.listViewPath !== null && vm.showBack; } - + /** Called when the component has linked all elements, this is when the form controller is available */ function postLink() { //set the content to dirty if the header changes @@ -65,7 +64,7 @@ } })); } - + function onDestroy() { for (var i = 0; i < unsubscribe.length; i++) { unsubscribe[i](); @@ -88,12 +87,12 @@ */ function selectApp(item) { // call the callback if any is registered - if(vm.onSelectApp) { - vm.onSelectApp({"app": item}); + if (vm.onSelectApp) { + vm.onSelectApp({ "app": item }); } } - - $scope.$on("editors.apps.appChanged", function($event, $args) { + + $scope.$on("editors.apps.appChanged", function ($event, $args) { var activeApp = $args.app; // sync varaintApps active with new active. @@ -104,11 +103,14 @@ onAppChanged(activeApp); }); + $scope.$on("listView.itemsChanged", function ($event, $args) { + vm.disableActionsMenu = $args.items.length > 0; + }); + function onAppChanged(activeApp) { // disable the name field if the active content app is not "Content" or "Info" vm.nameDisabled = (activeApp && activeApp.alias !== "umbContent" && activeApp.alias !== "umbInfo" && activeApp.alias !== "umbListView"); - } /** @@ -117,8 +119,8 @@ */ function selectAppAnchor(item, anchor) { // call the callback if any is registered - if(vm.onSelectAppAnchor) { - vm.onSelectAppAnchor({"app": item, "anchor": anchor}); + if (vm.onSelectAppAnchor) { + vm.onSelectAppAnchor({ "app": item, "anchor": anchor }); } } diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js index fdec4c98d0..846d5c85fe 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js @@ -220,6 +220,7 @@ nameDisabled: " i; i++) { var folder = folders[i]; folder.selected = false; } } + $rootScope.$broadcast("listView.itemsChanged", { items: selection }); } /** @@ -395,10 +398,11 @@ if (clearSelection) { selection.length = 0; } + $rootScope.$broadcast("listView.itemsChanged", { items: selection }); } - - + + /** * @ngdoc method * @name umbraco.services.listViewHelper#selectAllItemsToggle @@ -410,27 +414,27 @@ * @param {Array} items Items to toggle selection on, should be $scope.items * @param {Array} selection Listview selection, available as $scope.selection */ - + function selectAllItemsToggle(items, selection) { - + if (!Utilities.isArray(items)) { return; } - + if (isSelectedAll(items, selection)) { // unselect all items items.forEach(function (item) { item.selected = false; }); - + // reset selection without loosing reference. selection.length = 0; - + } else { - + // reset selection without loosing reference. selection.length = 0; - + // select all items items.forEach(function (item) { var obj = { @@ -443,6 +447,7 @@ selection.push(obj); }); } + $rootScope.$broadcast("listView.itemsChanged", { items: selection }); } @@ -558,7 +563,7 @@ }; } - + /** * @ngdoc method * @name umbraco.services.listViewHelper#editItem @@ -584,7 +589,7 @@ $location.search(p, params[p]); } } - + function isMatchingLayout(id, layout) { // legacy format uses "nodeId", be sure to look for both return layout.id === id || layout.nodeId === id; @@ -592,21 +597,21 @@ var service = { - getLayout: getLayout, - getFirstAllowedLayout: getFirstAllowedLayout, - setLayout: setLayout, - saveLayoutInLocalStorage: saveLayoutInLocalStorage, - selectHandler: selectHandler, - selectItem: selectItem, - deselectItem: deselectItem, - clearSelection: clearSelection, - selectAllItems: selectAllItems, - selectAllItemsToggle: selectAllItemsToggle, - isSelectedAll: isSelectedAll, - setSortingDirection: setSortingDirection, - setSorting: setSorting, - getButtonPermissions: getButtonPermissions, - editItem: editItem + getLayout: getLayout, + getFirstAllowedLayout: getFirstAllowedLayout, + setLayout: setLayout, + saveLayoutInLocalStorage: saveLayoutInLocalStorage, + selectHandler: selectHandler, + selectItem: selectItem, + deselectItem: deselectItem, + clearSelection: clearSelection, + selectAllItems: selectAllItems, + selectAllItemsToggle: selectAllItemsToggle, + isSelectedAll: isSelectedAll, + setSortingDirection: setSortingDirection, + setSorting: setSorting, + getButtonPermissions: getButtonPermissions, + editItem: editItem }; diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content.html b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content.html index 7db4f785f5..40a88ae6a6 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-variant-content.html @@ -8,7 +8,8 @@ + current-section="{{menu.currentSection}}" + is-disabled="disableActionsMenu"> diff --git a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html index 0fe8c862c1..789e8aa79e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html @@ -8,7 +8,7 @@ show-caret="true" has-popup="true" is-expanded="dropdown.isOpen" - disabled="!actions || !actions.length" + disabled="!actions || !actions.length || isDisabled" >