Skip to content
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

Show BlockGrid Create Dialog if there are items in clipboard #15841

Merged
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
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/blockgrid/umbBlockGridPropertyEditor.component.js

View check run for this annotation

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

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 4.80 to 4.82, 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";

function GetAreaAtBlock(parentBlock, areaKey) {
Expand Down Expand Up @@ -605,7 +605,7 @@
// because no columnSpanOptions defined, then use contextual layout columns.
layoutEntry.columnSpan = area? area.$config.columnSpan : vm.gridColumns;
}

} else {

if(blockObject.config.columnSpanOptions.length > 0) {
Expand All @@ -621,7 +621,7 @@

// add layout entry at the decided location in layout.
if(parentBlock != null) {

if(!area) {
console.error("Could not find area in block creation");
}
Expand Down Expand Up @@ -678,7 +678,7 @@
}
return null;
}


// Used by umbblockgridentries.component to check how many block types that are available for creation in an area:
vm.getAllowedTypesOf = getAllowedTypesOf;
Expand All @@ -705,7 +705,7 @@
}
}
});
} else
} else
if(allowance.elementTypeKey) {
const blockType = vm.availableBlockTypes.find(x => x.blockConfigModel.contentElementTypeKey === allowance.elementTypeKey);
if(blockType && allowedElementTypes.indexOf(blockType) === -1) {
Expand Down Expand Up @@ -777,7 +777,7 @@
*/

var wasNotActiveBefore = blockObject.active !== true;

// don't open the editor overlay if block has hidden its content editor in overlays and we are requesting to open content, not settings.
if (openSettings !== true && blockObject.hideContentInOverlay === true) {
return;
Expand Down Expand Up @@ -860,7 +860,7 @@

const availableTypes = getAllowedTypesOf(parentBlock, areaKey);

if (availableTypes.length === 1) {
if (availableTypes.length === 1 && vm.clipboardItems.length === 0) {
var wasAdded = false;
var blockType = availableTypes[0];

Expand Down Expand Up @@ -896,7 +896,7 @@
}

const availableBlockGroups = vm.blockGroups.filter(group => !!availableTypes.find(item => item.blockConfigModel.groupKey === group.key));

var amountOfAvailableTypes = availableTypes.length;
var availableContentTypesAliases = modelObject.getAvailableAliasesOfElementTypeKeys(availableTypes.map(x => x.blockConfigModel.contentElementTypeKey));
var availableClipboardItems = vm.clipboardItems.filter(
Expand All @@ -917,7 +917,7 @@
createLabel = vm.createLabel;
}
const headline = createLabel || (amountOfAvailableTypes.length === 1 ? localizationService.tokenReplace(vm.labels.blockEditor_addThis, [availableTypes[0].elementTypeModel.name]) : vm.labels.grid_addElement);

var blockPickerModel = {
$parentScope: $scope, // pass in a $parentScope, this maintains the scope inheritance in infinite editing
$parentForm: vm.propertyForm, // pass in a $parentForm, this maintains the FormController hierarchy with the infinite editing view (if it contains a form)
Expand Down Expand Up @@ -959,7 +959,7 @@
},
close: function() {
// if opened by a inline creator button(index less than length), we want to move the focus away, to hide line-creator.

// add layout entry at the decided location in layout.
if(parentBlock != null) {
var area = parentBlock.layout.areas.find(x => x.key === areaKey);
Expand All @@ -976,7 +976,7 @@
vm.setBlockFocus(blockOfInterest);
}
}


editorService.close();
vm.blockTypePickerIsOpen = false;
Expand All @@ -997,7 +997,7 @@
}
function userFlowWhenBlockWasCreated(parentBlock, areaKey, createIndex) {
var blockObject;

if (parentBlock) {
var area = parentBlock.layout.areas.find(x => x.key === areaKey);
if (!area) {
Expand Down Expand Up @@ -1185,7 +1185,7 @@
if (initializeLayoutEntry(layoutEntry, parentBlock, areaKey) === null) {
return null;
}

if (layoutEntry.$block === null) {
// Initialization of the Block Object didn't go well, therefor we will fail the paste action.
return null;
Expand Down Expand Up @@ -1224,14 +1224,14 @@
vm.layout.push(layoutEntry);
}
}

return {layoutEntry, failed: nestedBlockFailed};
}

function requestPasteFromClipboard(parentBlock, areaKey, index, pasteEntry, pasteType) {

const data = pasteClipboardEntry(parentBlock, areaKey, index, pasteEntry, pasteType);
if(data) {
if(data) {
if(data.failed === true) {
// one or more of nested block creation failed.
// Ask wether the user likes to continue:
Expand All @@ -1245,16 +1245,16 @@
closeButtonLabel: localizations[2],
submitButtonLabel: localizations[3],
close: function () {
// revert:
// revert:
deleteBlock(blockToRevert);
overlayService.close();
},
submit: function () {
// continue:
// continue:
overlayService.close();
}
};

overlayService.open(overlay);
});
} else {
Expand Down Expand Up @@ -1351,14 +1351,14 @@

document.documentElement.style.setProperty("--umb-block-grid--dragging-mode", ' ');
firstLayoutContainer.style.minHeight = firstLayoutContainer.getBoundingClientRect().height + "px";

}
vm.exitDraggingMode = exitDraggingMode;
function exitDraggingMode() {

document.documentElement.style.setProperty("--umb-block-grid--dragging-mode", 'initial');
firstLayoutContainer.style.minHeight = "";

}

function onAmountOfBlocksChanged() {
Expand Down
Loading