Skip to content

Commit 0fb91ef

Browse files
add single blocklist delete (#18073)
Co-authored-by: Andy Butland <[email protected]>
1 parent c0a0a34 commit 0fb91ef

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

src/Umbraco.Core/EmbeddedResources/Lang/en.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
Content.
295295
</key>
296296
<key alias="nestedContentDeleteAllItems">Are you sure you want to delete all items?</key>
297+
<key alias="nestedContentDeleteItem">Are you sure you want to delete this item?</key>
297298
<key alias="nestedContentNoContentTypes">No Content Types are configured for this property.</key>
298299
<key alias="nestedContentAddElementType">Add Element Type</key>
299300
<key alias="nestedContentSelectElementTypeModalTitle">Select Element Type</key>
@@ -331,6 +332,7 @@
331332
<key alias="schedulePublishHelp">Select the date and time to publish and/or unpublish the content item.</key>
332333
<key alias="createEmpty">Create new</key>
333334
<key alias="createFromClipboard">Paste from clipboard</key>
335+
<key alias="removeItem">Remove item</key>
334336
<key alias="nodeIsInTrash">This item is in the Recycle Bin</key>
335337
<key alias="noProperties">No content can be added for this item</key>
336338
<key alias="variantSaveNotAllowed">Save is not allowed</key>

src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@
290290
<![CDATA[<a href="https://docs.umbraco.com/umbraco-cms/fundamentals/data/scheduled-publishing#timezones" target="_blank" rel="noopener">What does this mean?</a>]]></key>
291291
<key alias="nestedContentDeleteItem">Are you sure you want to delete this item?</key>
292292
<key alias="nestedContentDeleteAllItems">Are you sure you want to delete all items?</key>
293+
<key alias="nestedContentDeleteItem">Are you sure you want to delete this item?</key>
293294
<key alias="nestedContentEditorNotSupported">Property %0% uses editor %1% which is not supported by Nested
294295
Content.
295296
</key>
@@ -330,6 +331,7 @@
330331
<key alias="schedulePublishHelp">Select the date and time to publish and/or unpublish the content item.</key>
331332
<key alias="createEmpty">Create new</key>
332333
<key alias="createFromClipboard">Paste from clipboard</key>
334+
<key alias="removeItem">Remove item</key>
333335
<key alias="nodeIsInTrash">This item is in the Recycle Bin</key>
334336
<key alias="variantSaveNotAllowed">Save is not allowed</key>
335337
<key alias="variantPublishNotAllowed">Publish is not allowed</key>

src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/umbBlockListPropertyEditor.component.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
let copyAllBlocksAction = null;
3838
let deleteAllBlocksAction = null;
3939
let pasteSingleBlockAction = null;
40+
let resetSingleBlock = null;
41+
42+
let scopeOfExistence = null;
4043

4144
var inlineEditing = false;
4245
var liveEditing = true;
@@ -124,12 +127,12 @@
124127
vm.listWrapperStyles['max-width'] = vm.model.config.maxPropertyWidth;
125128
}
126129

127-
// We need to ensure that the property model value is an object, this is needed for modelObject to recive a reference and keep that updated.
130+
// We need to ensure that the property model value is an object, this is needed for modelObject to receive a reference and keep that updated.
128131
if (typeof vm.model.value !== 'object' || vm.model.value === null) {// testing if we have null or undefined value or if the value is set to another type than Object.
129132
vm.model.value = {};
130133
}
131134

132-
var scopeOfExistence = $scope;
135+
scopeOfExistence = $scope;
133136
if (vm.umbVariantContentEditors && vm.umbVariantContentEditors.getScope) {
134137
scopeOfExistence = vm.umbVariantContentEditors.getScope();
135138
} else if(vm.umbElementEditorContent && vm.umbElementEditorContent.getScope) {
@@ -179,9 +182,18 @@
179182
useLegacyIcon: false
180183
};
181184

185+
resetSingleBlock = {
186+
labelKey: "content_removeItem",
187+
labelTokens: [],
188+
icon: "icon-trash",
189+
method: requestResetSingleBlock,
190+
isDisabled: false,
191+
useLegacyIcon: false
192+
};
193+
182194
var propertyActions = [copyAllBlocksAction, deleteAllBlocksAction];
183195

184-
var propertyActionsForSingleBlockMode = [pasteSingleBlockAction];
196+
var propertyActionsForSingleBlockMode = [pasteSingleBlockAction, resetSingleBlock];
185197

186198
if (vm.umbProperty) {
187199
if (vm.singleBlockMode) {
@@ -844,6 +856,24 @@
844856
});
845857
}
846858

859+
function requestResetSingleBlock() {
860+
localizationService.localizeMany(["content_nestedContentDeleteItem", "general_delete"]).then(function (data) {
861+
overlayService.confirmDelete({
862+
title: data[1],
863+
content: data[0],
864+
close: function () {
865+
overlayService.close();
866+
},
867+
submit: function () {
868+
deleteAllBlocks();
869+
modelObject = blockEditorService.createModelObject(vm.model.value, vm.model.editor, vm.model.config.blocks, scopeOfExistence, $scope);
870+
modelObject.load().then(onLoaded);
871+
overlayService.close();
872+
}
873+
});
874+
});
875+
}
876+
847877
function openSettingsForBlock(block, blockIndex, parentForm) {
848878
editBlock(block, true, blockIndex, parentForm);
849879
}

0 commit comments

Comments
 (0)