From 0aca5bcf242a750c1e49b8888bff9328d021e814 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Tue, 18 Nov 2025 17:10:12 +0100 Subject: [PATCH 1/3] Enhance `pimcore.helpers.editmode.openLinkEditPanel` with subtype and class-specific filters --- public/js/pimcore/helpers.js | 40 +++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/public/js/pimcore/helpers.js b/public/js/pimcore/helpers.js index abce47409..b6cce8720 100644 --- a/public/js/pimcore/helpers.js +++ b/public/js/pimcore/helpers.js @@ -1893,11 +1893,41 @@ 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', @@ -1950,7 +1980,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) { } data = data.records[0].data; - if (data.type !== "folder" && allowedTypes.includes(data.elementType)) { + if (dndAllowed(data)) { return Ext.dd.DropZone.prototype.dropAllowed; } }.bind(this), @@ -1961,7 +1991,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) { } data = data.records[0].data; - if (data.type !== "folder" && allowedTypes.includes(data.elementType)) { + if (dndAllowed(data)) { internalTypeField.setValue(data.elementType); linkTypeField.setValue('internal'); pathField.setValue(data.path); @@ -1996,7 +2026,11 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) { return true; } }, { - type: allowedTypes + type: allowedTypes, + subtype: allowedSubtypes, + specific: { + classes: allowedClasses, + }, }); } }); From 757cfb3be584138d5eb0900bf6e87576ae9dec50 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Tue, 18 Nov 2025 19:06:40 +0100 Subject: [PATCH 2/3] Add support for the "link" field type in objects --- public/js/pimcore/object/classes/data/link.js | 50 +++++++++++++++++-- public/js/pimcore/object/tags/link.js | 16 ++++++ translations/admin_ext.en.yaml | 3 ++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/public/js/pimcore/object/classes/data/link.js b/public/js/pimcore/object/classes/data/link.js index f60f9769e..3bc253295 100644 --- a/public/js/pimcore/object/classes/data/link.js +++ b/public/js/pimcore/object/classes/data/link.js @@ -57,18 +57,62 @@ 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, + store: this.types.map((text) => ({text})), 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, + store: this.targets.map((text) => ({text})), value: this.datax.allowedTargets, displayField: "text", valueField: "text", @@ -79,7 +123,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, + store: this.fields.map((text) => ({text})), 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 bc182d320..45c3c8b51 100644 --- a/public/js/pimcore/object/tags/link.js +++ b/public/js/pimcore/object/tags/link.js @@ -140,10 +140,26 @@ pimcore.object.tags.link = Class.create(pimcore.object.tags.abstract, { openEditor: function () { let config = []; + let allowedSubtypes = {}; 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 c6457fa0d..f5ebb6ff9 100644 --- a/translations/admin_ext.en.yaml +++ b/translations/admin_ext.en.yaml @@ -254,6 +254,9 @@ 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 From 98b419e06099c0242c7995ee97f0477d2aa2fd14 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Tue, 18 Nov 2025 19:25:26 +0100 Subject: [PATCH 3/3] Fix link editor initialization by replacing array with object for `config` --- public/js/pimcore/object/tags/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/pimcore/object/tags/link.js b/public/js/pimcore/object/tags/link.js index 45c3c8b51..a970b3cfc 100644 --- a/public/js/pimcore/object/tags/link.js +++ b/public/js/pimcore/object/tags/link.js @@ -139,7 +139,7 @@ pimcore.object.tags.link = Class.create(pimcore.object.tags.abstract, { }, openEditor: function () { - let config = []; + let config = {}; let allowedSubtypes = {}; if (!empty(this.fieldConfig.allowedTypes)){