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

[Bug] JS Errors on Bricks with many-to-many relation and specific configuration #462

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
19 changes: 18 additions & 1 deletion public/js/pimcore/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3290,15 +3290,32 @@ pimcore.helpers.treeDragDropValidate = function (node, oldParent, newParent) {
if (disabledLayoutTypes.includes(newParent.data.editor.type)) {
return false;
}

return this.isComponentAsChildAllowed(newParent, node);
}

if (newParent.data.root) {
if (newParent.data.root && node.data.type !== 'layout') {
return false;
}

return true;
};

pimcore.helpers.isComponentAsChildAllowed = function (parentNode, childNode) {
const parentType = parentNode.data.editor.type;
const childType = childNode.data.editor.type;
const allowedChildren = pimcore.object.helpers.layout.getRawAllowedTypes();

if (allowedChildren[parentType] &&
allowedChildren[parentType].includes(childType) ||
(allowedChildren[parentType].includes('data') && childNode.data.type === 'data')
) {
return true
}

return false;
}

/**
* Building menu with priority
* @param items
Expand Down
26 changes: 15 additions & 11 deletions public/js/pimcore/object/helpers/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,24 @@ pimcore.object.helpers.layout = {
* specify which children a layout can have
* @param source
*/
getAllowedTypes : function (source) {
var allowedTypes = {
accordion: ["panel","region","tabpanel","text","iframe"],
fieldset: ["data","text","iframe"],
fieldcontainer: ["data","text","iframe"],
panel: ["data","region","tabpanel","button","accordion","fieldset", "fieldcontainer","panel","text","html", "iframe"],
region: ["panel","accordion","tabpanel","text","localizedfields","iframe"],
tabpanel: ["panel", "region", "accordion","text","localizedfields","iframe", "tabpabel"],
getRawAllowedTypes : function () {
return {
accordion: ["panel", "region", "tabpanel", "text", "iframe"],
fieldset: ["data", "text", "iframe"],
fieldcontainer: ["data", "text", "iframe"],
panel: ["data", "region", "tabpanel", "button", "accordion", "fieldset", "fieldcontainer", "panel", "text", "html", "iframe"],
region: ["panel", "accordion", "tabpanel", "text", "localizedfields", "iframe"],
tabpanel: ["panel", "region", "accordion", "text", "localizedfields", "iframe", "tabpabel"],
button: [],
text: [],
root: ["panel","region","tabpanel","accordion","text","iframe", "button","fieldcontainer", "fieldset"],
localizedfields: ["panel","tabpanel","accordion","fieldset", "fieldcontainer", "text","region","button","iframe"],
block: ["panel","tabpanel","accordion","fieldset", "fieldcontainer", "text","region","button","iframe"]
root: ["panel", "region", "tabpanel", "accordion", "text", "iframe", "button", "fieldcontainer", "fieldset"],
localizedfields: ["panel", "tabpanel", "accordion", "fieldset", "fieldcontainer", "text", "region", "button", "iframe"],
block: ["panel", "tabpanel", "accordion", "fieldset", "fieldcontainer", "text", "region", "button", "iframe"]
};
},

getAllowedTypes : function (source) {
const allowedTypes = this.getRawAllowedTypes();

const prepareClassLayoutContextMenu = new CustomEvent(pimcore.events.prepareClassLayoutContextMenu, {
detail: {
Expand Down
Loading