Skip to content

add single blocklist delete #18073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Umbraco.Core/EmbeddedResources/Lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
Content.
</key>
<key alias="nestedContentDeleteAllItems">Are you sure you want to delete all items?</key>
<key alias="nestedContentDeleteItem">Are you sure you want to delete this item?</key>
<key alias="nestedContentNoContentTypes">No Content Types are configured for this property.</key>
<key alias="nestedContentAddElementType">Add Element Type</key>
<key alias="nestedContentSelectElementTypeModalTitle">Select Element Type</key>
Expand Down Expand Up @@ -331,6 +332,7 @@
<key alias="schedulePublishHelp">Select the date and time to publish and/or unpublish the content item.</key>
<key alias="createEmpty">Create new</key>
<key alias="createFromClipboard">Paste from clipboard</key>
<key alias="removeItem">Remove item</key>
<key alias="nodeIsInTrash">This item is in the Recycle Bin</key>
<key alias="noProperties">No content can be added for this item</key>
<key alias="variantSaveNotAllowed">Save is not allowed</key>
Expand Down
2 changes: 2 additions & 0 deletions src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@
<![CDATA[<a href="https://docs.umbraco.com/umbraco-cms/fundamentals/data/scheduled-publishing#timezones" target="_blank" rel="noopener">What does this mean?</a>]]></key>
<key alias="nestedContentDeleteItem">Are you sure you want to delete this item?</key>
<key alias="nestedContentDeleteAllItems">Are you sure you want to delete all items?</key>
<key alias="nestedContentDeleteItem">Are you sure you want to delete this item?</key>
<key alias="nestedContentEditorNotSupported">Property %0% uses editor %1% which is not supported by Nested
Content.
</key>
Expand Down Expand Up @@ -330,6 +331,7 @@
<key alias="schedulePublishHelp">Select the date and time to publish and/or unpublish the content item.</key>
<key alias="createEmpty">Create new</key>
<key alias="createFromClipboard">Paste from clipboard</key>
<key alias="removeItem">Remove item</key>
<key alias="nodeIsInTrash">This item is in the Recycle Bin</key>
<key alias="variantSaveNotAllowed">Save is not allowed</key>
<key alias="variantPublishNotAllowed">Publish is not allowed</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {

Check notice on line 1 in src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/umbBlockListPropertyEditor.component.js

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v13/dev)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 4.94 to 4.81, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
"use strict";


Expand Down Expand Up @@ -37,6 +37,9 @@
let copyAllBlocksAction = null;
let deleteAllBlocksAction = null;
let pasteSingleBlockAction = null;
let resetSingleBlock = null;

let scopeOfExistence = null;

var inlineEditing = false;
var liveEditing = true;
Expand Down Expand Up @@ -124,12 +127,12 @@
vm.listWrapperStyles['max-width'] = vm.model.config.maxPropertyWidth;
}

// 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.
// 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.
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.
vm.model.value = {};
}

var scopeOfExistence = $scope;
scopeOfExistence = $scope;
if (vm.umbVariantContentEditors && vm.umbVariantContentEditors.getScope) {
scopeOfExistence = vm.umbVariantContentEditors.getScope();
} else if(vm.umbElementEditorContent && vm.umbElementEditorContent.getScope) {
Expand Down Expand Up @@ -179,9 +182,18 @@
useLegacyIcon: false
};

resetSingleBlock = {
labelKey: "content_removeItem",
labelTokens: [],
icon: "icon-trash",
method: requestResetSingleBlock,
isDisabled: false,
useLegacyIcon: false
};

var propertyActions = [copyAllBlocksAction, deleteAllBlocksAction];

var propertyActionsForSingleBlockMode = [pasteSingleBlockAction];
var propertyActionsForSingleBlockMode = [pasteSingleBlockAction, resetSingleBlock];

if (vm.umbProperty) {
if (vm.singleBlockMode) {
Expand Down Expand Up @@ -844,6 +856,24 @@
});
}

function requestResetSingleBlock() {
localizationService.localizeMany(["content_nestedContentDeleteItem", "general_delete"]).then(function (data) {
overlayService.confirmDelete({
title: data[1],
content: data[0],
close: function () {
overlayService.close();
},
submit: function () {
deleteAllBlocks();
modelObject = blockEditorService.createModelObject(vm.model.value, vm.model.editor, vm.model.config.blocks, scopeOfExistence, $scope);
modelObject.load().then(onLoaded);
overlayService.close();
}
});
});
}

function openSettingsForBlock(block, blockIndex, parentForm) {
editBlock(block, true, blockIndex, parentForm);
}
Expand Down
Loading