Skip to content

Commit 0d399a6

Browse files
authored
Revert "Allow restricting subtypes and classes in link edit panel (#1057)" (#1075)
This reverts commit b6cb5e3.
1 parent b6cb5e3 commit 0d399a6

4 files changed

Lines changed: 7 additions & 104 deletions

File tree

public/js/pimcore/helpers.js

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,41 +1895,11 @@ pimcore.helpers.editmode = {};
18951895
pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) {
18961896
const TARGETS = ["", "_blank", "_self", "_top", "_parent"];
18971897
const TYPES = ["asset", "document", "object"];
1898-
const SUBTYPES = {
1899-
document: pimcore.globalmanager.get("document_search_types").filter(v => v !== "folder"),
1900-
asset: pimcore.globalmanager.get("asset_search_types").filter(v => v !== "folder"),
1901-
object: pimcore.globalmanager.get("object_search_types").filter(v => v !== "folder"),
1902-
};
19031898

19041899
config = config || {};
19051900
const disabledFields = config.disabledFields || [];
19061901
const allowedTargets = Ext.Array.intersect(TARGETS, config.allowedTargets || TARGETS);
19071902
const allowedTypes = Ext.Array.intersect(TYPES, config.allowedTypes || TYPES);
1908-
const allowedSubtypes = Object.fromEntries(Object.entries(SUBTYPES).map(([key, value]) => [
1909-
key,
1910-
config.allowedSubtypes?.[key]?.filter(v => v !== "folder").length
1911-
? Ext.Array.intersect(value, config.allowedSubtypes[key])
1912-
: value
1913-
]));
1914-
const allowedClasses = config.allowedClasses;
1915-
1916-
const dndAllowed = (data) => {
1917-
const type = data.elementType;
1918-
1919-
if (!allowedTypes.includes(type)) {
1920-
return false;
1921-
}
1922-
1923-
if (Array.isArray(allowedSubtypes?.[type]) && !allowedSubtypes[type].includes(data.type)) {
1924-
return false;
1925-
}
1926-
1927-
if (type === "object" && Array.isArray(allowedClasses) && !allowedClasses.includes(data.className)) {
1928-
return false;
1929-
}
1930-
1931-
return true;
1932-
};
19331903

19341904
const internalTypeField = new Ext.form.Hidden({
19351905
fieldLabel: 'internalType',
@@ -1982,7 +1952,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) {
19821952
}
19831953

19841954
data = data.records[0].data;
1985-
if (dndAllowed(data)) {
1955+
if (data.type !== "folder" && allowedTypes.includes(data.elementType)) {
19861956
return Ext.dd.DropZone.prototype.dropAllowed;
19871957
}
19881958
}.bind(this),
@@ -1993,7 +1963,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) {
19931963
}
19941964

19951965
data = data.records[0].data;
1996-
if (dndAllowed(data)) {
1966+
if (data.type !== "folder" && allowedTypes.includes(data.elementType)) {
19971967
internalTypeField.setValue(data.elementType);
19981968
linkTypeField.setValue('internal');
19991969
pathField.setValue(data.path);
@@ -2028,11 +1998,7 @@ pimcore.helpers.editmode.openLinkEditPanel = function (data, callback, config) {
20281998
return true;
20291999
}
20302000
}, {
2031-
type: allowedTypes,
2032-
subtype: allowedSubtypes,
2033-
specific: {
2034-
classes: allowedClasses,
2035-
},
2001+
type: allowedTypes
20362002
});
20372003
}
20382004
});

public/js/pimcore/object/classes/data/link.js

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -57,62 +57,18 @@ pimcore.object.classes.data.link = Class.create(pimcore.object.classes.data.data
5757
fieldLabel: t("allowed_types") + '<br />' + t('allowed_types_hint'),
5858
name: "allowedTypes",
5959
id: 'allowedTypes',
60-
store: this.types.map((text) => ({text})),
60+
store: this.types,
6161
value: this.datax.allowedTypes,
6262
displayField: "text",
6363
valueField: "text",
6464
width: 400
6565
},
66-
{
67-
xtype: "multiselect",
68-
fieldLabel: t("allowed_asset_subtypes") + '<br />' + t('allowed_types_hint'),
69-
name: "allowedAssetSubtypes",
70-
id: 'allowedAssetSubtypes',
71-
store: pimcore.globalmanager.get('asset_search_types').filter(v => v !== "folder").map((text) => ({text})),
72-
value: this.datax.allowedAssetSubtypes,
73-
displayField: "text",
74-
valueField: "text",
75-
width: 400
76-
},
77-
{
78-
xtype: "multiselect",
79-
fieldLabel: t("allowed_document_subtypes") + '<br />' + t('allowed_types_hint'),
80-
name: "allowedDocumentSubtypes",
81-
id: 'allowedDocumentSubtypes',
82-
store: pimcore.globalmanager.get('document_search_types').filter(v => v !== "folder").map((text) => ({text})),
83-
value: this.datax.allowedDocumentSubtypes,
84-
displayField: "text",
85-
valueField: "text",
86-
width: 400
87-
},
88-
{
89-
xtype: "multiselect",
90-
fieldLabel: t("allowed_object_subtypes") + '<br />' + t('allowed_types_hint'),
91-
name: "allowedObjectSubtypes",
92-
id: 'allowedObjectSubtypes',
93-
store: pimcore.globalmanager.get('object_search_types').filter(v => v !== "folder").map((text) => ({text})),
94-
value: this.datax.allowedObjectSubtypes,
95-
displayField: "text",
96-
valueField: "text",
97-
width: 400
98-
},
99-
{
100-
xtype: "multiselect",
101-
fieldLabel: t("allowed_classes") + '<br />' + t('allowed_types_hint'),
102-
name: "allowedClasses",
103-
id: 'allowedClasses',
104-
store: pimcore.globalmanager.get("object_types_store"),
105-
value: this.datax.allowedClasses,
106-
displayField: "text",
107-
valueField: "text",
108-
width: 400
109-
},
11066
{
11167
xtype: "multiselect",
11268
fieldLabel: t("allowed_targets") + '<br />' + t('allowed_types_hint'),
11369
name: "allowedTargets",
11470
id: 'allowedTargets',
115-
store: this.targets.map((text) => ({text})),
71+
store: this.targets,
11672
value: this.datax.allowedTargets,
11773
displayField: "text",
11874
valueField: "text",
@@ -123,7 +79,7 @@ pimcore.object.classes.data.link = Class.create(pimcore.object.classes.data.data
12379
fieldLabel: t("disabled_fields") + '<br />' + t('allowed_types_hint'),
12480
name: "disabledFields",
12581
id: 'disabledFields',
126-
store: this.fields.map((text) => ({text})),
82+
store: this.fields,
12783
value: this.datax.disabledFields,
12884
displayField: "text",
12985
valueField: "text",

public/js/pimcore/object/tags/link.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,11 @@ pimcore.object.tags.link = Class.create(pimcore.object.tags.abstract, {
139139
},
140140

141141
openEditor: function () {
142-
let config = {};
143-
let allowedSubtypes = {};
142+
let config = [];
144143

145144
if (!empty(this.fieldConfig.allowedTypes)){
146145
config['allowedTypes'] = this.fieldConfig.allowedTypes;
147146
}
148-
if (!empty(this.fieldConfig.allowedAssetSubtypes)){
149-
allowedSubtypes['asset'] = this.fieldConfig.allowedAssetSubtypes;
150-
}
151-
if (!empty(this.fieldConfig.allowedDocumentSubtypes)){
152-
allowedSubtypes['document'] = this.fieldConfig.allowedDocumentSubtypes;
153-
}
154-
if (!empty(this.fieldConfig.allowedObjectSubtypes)){
155-
allowedSubtypes['object'] = this.fieldConfig.allowedObjectSubtypes;
156-
}
157-
if (!empty(allowedSubtypes)) {
158-
config['allowedSubtypes'] = allowedSubtypes;
159-
}
160-
if (!empty(this.fieldConfig.allowedClasses)){
161-
config['allowedClasses'] = this.fieldConfig.allowedClasses;
162-
}
163147
if (!empty(this.fieldConfig.allowedTargets)){
164148
config['allowedTargets'] = this.fieldConfig.allowedTargets;
165149
}

translations/admin_ext.en.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ visibility_of_system_properties: Visibility of system properties
250250
translate: translate
251251
translations_admin_hint: 'HINT: Please Reload UI to apply translation changes!'
252252
allowed_types: Allowed Types
253-
allowed_asset_subtypes: Allowed Subtypes for Assets
254-
allowed_document_subtypes: Allowed Subtypes for Documents
255-
allowed_object_subtypes: Allowed Subtypes for Objects
256253
allowed_targets: Allowed Targets
257254
disabled_fields: Disabled Fields
258255
columnlength: Columnlength

0 commit comments

Comments
 (0)