8838: Node Actions menu should be disabled on listview (#9021)

* 8838: Node Actions menu should be disabled on listview

* 8838: Set disable actions menu on event
This commit is contained in:
patrickdemooij9
2020-11-23 00:35:38 +01:00
committed by GitHub
parent f3ec66be4c
commit 98610b50d3
7 changed files with 56 additions and 45 deletions

View File

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

View File

@@ -220,6 +220,7 @@
nameDisabled: "<?",
menu: "=",
hideActionsMenu: "<?",
disableActionsMenu: "<?",
content: "=",
editor: "=",
hideChangeVariant: "<?",

View File

@@ -52,7 +52,8 @@
link: link,
scope: {
currentNode: "=",
currentSection: "@"
currentSection: "@",
isDisabled: "<?"
}
};

View File

@@ -45,7 +45,7 @@
(function () {
'use strict';
function listViewHelper($location, localStorageService, urlHelper) {
function listViewHelper($location, $rootScope, localStorageService, urlHelper) {
var firstSelectedIndex = 0;
var localStorageKey = "umblistViewLayout";
@@ -286,6 +286,7 @@
selection.push(obj);
item.selected = true;
$rootScope.$broadcast("listView.itemsChanged", { items: selection });
}
}
@@ -308,6 +309,7 @@
if ((item.id !== 2147483647 && item.id === selectedItem.id) || (item.key && item.key === selectedItem.key)) {
selection.splice(i, 1);
item.selected = false;
$rootScope.$broadcast("listView.itemsChanged", { items: selection });
}
}
}
@@ -339,12 +341,13 @@
}
}
if(Utilities.isArray(folders)) {
if (Utilities.isArray(folders)) {
for (i = 0; folders.length > 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
};

View File

@@ -8,7 +8,8 @@
<ng-form name="contentHeaderForm" ng-if="vm.content.apps.length > 0">
<umb-editor-content-header
menu="vm.page.menu"
hide-menu="vm.page.hideActionsMenu"
hide-actions-menu="vm.page.hideActionsMenu"
disable-actions-menu="vm.disableActionsMenu"
name="vm.editor.content.name"
name-disabled="vm.nameDisabled"
editor="vm.editor"

View File

@@ -108,7 +108,8 @@
<umb-editor-menu
data-element="editor-actions"
current-node="menu.currentNode"
current-section="{{menu.currentSection}}">
current-section="{{menu.currentSection}}"
is-disabled="disableActionsMenu">
</umb-editor-menu>
</div>

View File

@@ -8,7 +8,7 @@
show-caret="true"
has-popup="true"
is-expanded="dropdown.isOpen"
disabled="!actions || !actions.length"
disabled="!actions || !actions.length || isDisabled"
>
</umb-button>