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

Bugfix: support drag & drop for custom field types #650

Conversation

BlackbitDevs
Copy link
Contributor

In

const allowedChildren = pimcore.object.helpers.layout.getRawAllowedTypes();
method getRawAllowedTypes() gets used. This only returns Pimcore's built-in field types, see
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: ["data", "panel", "tabpanel", "accordion", "fieldset", "fieldcontainer", "text", "region", "button", "iframe"],
block: ["data", "panel", "tabpanel", "accordion", "fieldset", "fieldcontainer", "text", "region", "button", "iframe"]
};
},

But if the application adds custom field types via prepareClassLayoutContextMenu event, the custom field type will be addable because in

var allowedTypes = pimcore.object.helpers.layout.getAllowedTypes(this);
getAllowedTypes() gets used but it is not possible to drag & drop custom fields because
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;
}
returns false when dropping the custom field.

Copy link

sonarcloud bot commented Aug 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
C Reliability Rating on New Code (required ≥ A)
E Maintainability Rating on New Code (required ≥ B)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@robertSt7 robertSt7 self-assigned this Aug 9, 2024
@robertSt7 robertSt7 added this to the 1.5.3 milestone Aug 9, 2024
@robertSt7 robertSt7 merged commit e1285c1 into pimcore:1.5 Aug 9, 2024
10 of 11 checks passed
@robertSt7
Copy link
Contributor

@BlackbitDevs Thanks a lot for the fix

@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants