From 8314bcca58a68a68255fea85fbfc9ee89641ecbe Mon Sep 17 00:00:00 2001 From: JiaJia Ji Date: Mon, 19 Jan 2026 10:33:41 +0100 Subject: [PATCH] Revert "Allow restricting subtypes and classes in link edit panel (#1057)" This reverts commit b6cb5e3a6512b04d19c939994dddf6af06dbeee5. --- public/js/pimcore/helpers.js | 40 ++------------- public/js/pimcore/object/classes/data/link.js | 50 ++----------------- public/js/pimcore/object/tags/link.js | 18 +------ translations/admin_ext.en.yaml | 3 -- 4 files changed, 7 insertions(+), 104 deletions(-) diff --git a/public/js/pimcore/helpers.js b/public/js/pimcore/helpers.js index 45eb21f5e..946e57a14 100644 --- a/public/js/pimcore/helpers.js +++ b/public/js/pimcore/helpers.js @@ -1895,41 +1895,11 @@ pimcore.helpers.editmode = {}; pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) { const TARGETS = ["", "_blank", "_self", "_top", "_parent"]; const TYPES = ["asset", "document", "object"]; - const SUBTYPES = { - document: pimcore.globalmanager.get("document_search_types").filter(v => v !== "folder"), - asset: pimcore.globalmanager.get("asset_search_types").filter(v => v !== "folder"), - object: pimcore.globalmanager.get("object_search_types").filter(v => v !== "folder"), - }; config = config || {}; const disabledFields = config.disabledFields || []; const allowedTargets = Ext.Array.intersect(TARGETS, config.allowedTargets || TARGETS); const allowedTypes = Ext.Array.intersect(TYPES, config.allowedTypes || TYPES); - const allowedSubtypes = Object.fromEntries(Object.entries(SUBTYPES).map(([key, value]) => [ - key, - config.allowedSubtypes?.[key]?.filter(v => v !== "folder").length - ? Ext.Array.intersect(value, config.allowedSubtypes[key]) - : value - ])); - const allowedClasses = config.allowedClasses; - - const dndAllowed = (data) => { - const type = data.elementType; - - if (!allowedTypes.includes(type)) { - return false; - } - - if (Array.isArray(allowedSubtypes?.[type]) && !allowedSubtypes[type].includes(data.type)) { - return false; - } - - if (type === "object" && Array.isArray(allowedClasses) && !allowedClasses.includes(data.className)) { - return false; - } - - return true; - }; const internalTypeField = new Ext.form.Hidden({ fieldLabel: 'internalType', @@ -1982,7 +1952,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) { } data = data.records[0].data; - if (dndAllowed(data)) { + if (data.type !== "folder" && allowedTypes.includes(data.elementType)) { return Ext.dd.DropZone.prototype.dropAllowed; } }.bind(this), @@ -1993,7 +1963,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) { } data = data.records[0].data; - if (dndAllowed(data)) { + if (data.type !== "folder" && allowedTypes.includes(data.elementType)) { internalTypeField.setValue(data.elementType); linkTypeField.setValue('internal'); pathField.setValue(data.path); @@ -2028,11 +1998,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) { return true; } }, { - type: allowedTypes, - subtype: allowedSubtypes, - specific: { - classes: allowedClasses, - }, + type: allowedTypes }); } }); diff --git a/public/js/pimcore/object/classes/data/link.js b/public/js/pimcore/object/classes/data/link.js index 3bc253295..f60f9769e 100644 --- a/public/js/pimcore/object/classes/data/link.js +++ b/public/js/pimcore/object/classes/data/link.js @@ -57,62 +57,18 @@ pimcore.object.classes.data.link = Class.create(pimcore.object.classes.data.data fieldLabel: t("allowed_types") + '
' + t('allowed_types_hint'), name: "allowedTypes", id: 'allowedTypes', - store: this.types.map((text) => ({text})), + store: this.types, value: this.datax.allowedTypes, displayField: "text", valueField: "text", width: 400 }, - { - xtype: "multiselect", - fieldLabel: t("allowed_asset_subtypes") + '
' + t('allowed_types_hint'), - name: "allowedAssetSubtypes", - id: 'allowedAssetSubtypes', - store: pimcore.globalmanager.get('asset_search_types').filter(v => v !== "folder").map((text) => ({text})), - value: this.datax.allowedAssetSubtypes, - displayField: "text", - valueField: "text", - width: 400 - }, - { - xtype: "multiselect", - fieldLabel: t("allowed_document_subtypes") + '
' + t('allowed_types_hint'), - name: "allowedDocumentSubtypes", - id: 'allowedDocumentSubtypes', - store: pimcore.globalmanager.get('document_search_types').filter(v => v !== "folder").map((text) => ({text})), - value: this.datax.allowedDocumentSubtypes, - displayField: "text", - valueField: "text", - width: 400 - }, - { - xtype: "multiselect", - fieldLabel: t("allowed_object_subtypes") + '
' + t('allowed_types_hint'), - name: "allowedObjectSubtypes", - id: 'allowedObjectSubtypes', - store: pimcore.globalmanager.get('object_search_types').filter(v => v !== "folder").map((text) => ({text})), - value: this.datax.allowedObjectSubtypes, - displayField: "text", - valueField: "text", - width: 400 - }, - { - xtype: "multiselect", - fieldLabel: t("allowed_classes") + '
' + t('allowed_types_hint'), - name: "allowedClasses", - id: 'allowedClasses', - store: pimcore.globalmanager.get("object_types_store"), - value: this.datax.allowedClasses, - displayField: "text", - valueField: "text", - width: 400 - }, { xtype: "multiselect", fieldLabel: t("allowed_targets") + '
' + t('allowed_types_hint'), name: "allowedTargets", id: 'allowedTargets', - store: this.targets.map((text) => ({text})), + store: this.targets, value: this.datax.allowedTargets, displayField: "text", valueField: "text", @@ -123,7 +79,7 @@ pimcore.object.classes.data.link = Class.create(pimcore.object.classes.data.data fieldLabel: t("disabled_fields") + '
' + t('allowed_types_hint'), name: "disabledFields", id: 'disabledFields', - store: this.fields.map((text) => ({text})), + store: this.fields, value: this.datax.disabledFields, displayField: "text", valueField: "text", diff --git a/public/js/pimcore/object/tags/link.js b/public/js/pimcore/object/tags/link.js index a970b3cfc..bc182d320 100644 --- a/public/js/pimcore/object/tags/link.js +++ b/public/js/pimcore/object/tags/link.js @@ -139,27 +139,11 @@ pimcore.object.tags.link = Class.create(pimcore.object.tags.abstract, { }, openEditor: function () { - let config = {}; - let allowedSubtypes = {}; + let config = []; if (!empty(this.fieldConfig.allowedTypes)){ config['allowedTypes'] = this.fieldConfig.allowedTypes; } - if (!empty(this.fieldConfig.allowedAssetSubtypes)){ - allowedSubtypes['asset'] = this.fieldConfig.allowedAssetSubtypes; - } - if (!empty(this.fieldConfig.allowedDocumentSubtypes)){ - allowedSubtypes['document'] = this.fieldConfig.allowedDocumentSubtypes; - } - if (!empty(this.fieldConfig.allowedObjectSubtypes)){ - allowedSubtypes['object'] = this.fieldConfig.allowedObjectSubtypes; - } - if (!empty(allowedSubtypes)) { - config['allowedSubtypes'] = allowedSubtypes; - } - if (!empty(this.fieldConfig.allowedClasses)){ - config['allowedClasses'] = this.fieldConfig.allowedClasses; - } if (!empty(this.fieldConfig.allowedTargets)){ config['allowedTargets'] = this.fieldConfig.allowedTargets; } diff --git a/translations/admin_ext.en.yaml b/translations/admin_ext.en.yaml index a2971f274..2d0515cd3 100644 --- a/translations/admin_ext.en.yaml +++ b/translations/admin_ext.en.yaml @@ -250,9 +250,6 @@ visibility_of_system_properties: Visibility of system properties translate: translate translations_admin_hint: 'HINT: Please Reload UI to apply translation changes!' allowed_types: Allowed Types -allowed_asset_subtypes: Allowed Subtypes for Assets -allowed_document_subtypes: Allowed Subtypes for Documents -allowed_object_subtypes: Allowed Subtypes for Objects allowed_targets: Allowed Targets disabled_fields: Disabled Fields columnlength: Columnlength