Add "remove all entries" property action to MNTP
This commit is contained in:
committed by
Nathan Woulfe
parent
43c00690b9
commit
a655fba948
@@ -15,7 +15,7 @@
|
||||
* @param {any} editorService
|
||||
* @param {any} userService
|
||||
*/
|
||||
function contentPickerController($scope, $q, $routeParams, $location, entityResource, editorState, iconHelper, angularHelper, navigationService, localizationService, editorService, userService) {
|
||||
function contentPickerController($scope, $q, $routeParams, $location, entityResource, editorState, iconHelper, angularHelper, navigationService, localizationService, editorService, userService, overlayService) {
|
||||
|
||||
var vm = {
|
||||
labels: {
|
||||
@@ -116,6 +116,14 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso
|
||||
}
|
||||
};
|
||||
|
||||
var removeAllEntriesAction = {
|
||||
labelKey: 'clipboard_labelForRemoveAllEntries',
|
||||
labelTokens: [],
|
||||
icon: 'trash',
|
||||
method: removeAllEntries,
|
||||
isDisabled: true
|
||||
};
|
||||
|
||||
if ($scope.model.config) {
|
||||
//special case, if the `startNode` is falsy on the server config delete it entirely so the default value is merged in
|
||||
if (!$scope.model.config.startNode) {
|
||||
@@ -129,6 +137,14 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso
|
||||
if ($scope.model.validation && $scope.model.validation.mandatory && !$scope.model.config.minNumber) {
|
||||
$scope.model.config.minNumber = 1;
|
||||
}
|
||||
|
||||
if ($scope.model.config.multiPicker === true && $scope.umbProperty) {
|
||||
var propertyActions = [
|
||||
removeAllEntriesAction
|
||||
];
|
||||
|
||||
$scope.umbProperty.setPropertyActions(propertyActions);
|
||||
}
|
||||
}
|
||||
|
||||
//Umbraco persists boolean for prevalues as "0" or "1" so we need to convert that!
|
||||
@@ -275,6 +291,8 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso
|
||||
angularHelper.getCurrentForm($scope).$setDirty();
|
||||
$scope.model.value = currIds.join();
|
||||
}
|
||||
|
||||
removeAllEntriesAction.isDisabled = currIds.length === 0;
|
||||
};
|
||||
|
||||
$scope.showNode = function (index) {
|
||||
@@ -301,10 +319,13 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso
|
||||
currIds.push(itemId);
|
||||
$scope.model.value = currIds.join();
|
||||
}
|
||||
|
||||
removeAllEntriesAction.isDisabled = false;
|
||||
};
|
||||
|
||||
$scope.clear = function () {
|
||||
$scope.model.value = null;
|
||||
removeAllEntriesAction.isDisabled = true;
|
||||
};
|
||||
|
||||
$scope.openEditor = function (item) {
|
||||
@@ -362,6 +383,8 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso
|
||||
//sync the sortable model
|
||||
$scope.sortableModel = valueIds;
|
||||
|
||||
removeAllEntriesAction.isDisabled = valueIds.length === 0;
|
||||
|
||||
//load current data if anything selected
|
||||
if (valueIds.length > 0) {
|
||||
|
||||
@@ -507,6 +530,22 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso
|
||||
}
|
||||
}
|
||||
|
||||
function removeAllEntries() {
|
||||
localizationService.localizeMany(["content_nestedContentDeleteAllItems", "general_delete"]).then(function (data) {
|
||||
overlayService.confirmDelete({
|
||||
title: data[1],
|
||||
content: data[0],
|
||||
close: function () {
|
||||
overlayService.close();
|
||||
},
|
||||
submit: function () {
|
||||
$scope.clear();
|
||||
overlayService.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
userService.getCurrentUser().then(function (user) {
|
||||
|
||||
Reference in New Issue
Block a user