Skip to content
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
40 changes: 3 additions & 37 deletions public/js/pimcore/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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),
Expand All @@ -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);
Expand Down Expand Up @@ -2028,11 +1998,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) {
return true;
}
}, {
type: allowedTypes,
subtype: allowedSubtypes,
specific: {
classes: allowedClasses,
},
type: allowedTypes
});
}
});
Expand Down
50 changes: 3 additions & 47 deletions public/js/pimcore/object/classes/data/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,62 +57,18 @@ pimcore.object.classes.data.link = Class.create(pimcore.object.classes.data.data
fieldLabel: t("allowed_types") + '<br />' + 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") + '<br />' + 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") + '<br />' + 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") + '<br />' + 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") + '<br />' + 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") + '<br />' + 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",
Expand All @@ -123,7 +79,7 @@ pimcore.object.classes.data.link = Class.create(pimcore.object.classes.data.data
fieldLabel: t("disabled_fields") + '<br />' + 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",
Expand Down
18 changes: 1 addition & 17 deletions public/js/pimcore/object/tags/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 0 additions & 3 deletions translations/admin_ext.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading