Skip to content

Commit 1abb389

Browse files
committed
Add support for the "link" field type in objects
1 parent 398b52f commit 1abb389

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

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

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,62 @@ pimcore.object.classes.data.link = Class.create(pimcore.object.classes.data.data
6060
fieldLabel: t("allowed_types") + '<br />' + t('allowed_types_hint'),
6161
name: "allowedTypes",
6262
id: 'allowedTypes',
63-
store: this.types,
63+
store: this.types.map((text) => ({text})),
6464
value: this.datax.allowedTypes,
6565
displayField: "text",
6666
valueField: "text",
6767
width: 400
6868
},
69+
{
70+
xtype: "multiselect",
71+
fieldLabel: t("allowed_asset_subtypes") + '<br />' + t('allowed_types_hint'),
72+
name: "allowedAssetSubtypes",
73+
id: 'allowedAssetSubtypes',
74+
store: pimcore.globalmanager.get('asset_search_types').filter(v => v !== "folder").map((text) => ({text})),
75+
value: this.datax.allowedAssetSubtypes,
76+
displayField: "text",
77+
valueField: "text",
78+
width: 400
79+
},
80+
{
81+
xtype: "multiselect",
82+
fieldLabel: t("allowed_document_subtypes") + '<br />' + t('allowed_types_hint'),
83+
name: "allowedDocumentSubtypes",
84+
id: 'allowedDocumentSubtypes',
85+
store: pimcore.globalmanager.get('document_search_types').filter(v => v !== "folder").map((text) => ({text})),
86+
value: this.datax.allowedDocumentSubtypes,
87+
displayField: "text",
88+
valueField: "text",
89+
width: 400
90+
},
91+
{
92+
xtype: "multiselect",
93+
fieldLabel: t("allowed_object_subtypes") + '<br />' + t('allowed_types_hint'),
94+
name: "allowedObjectSubtypes",
95+
id: 'allowedObjectSubtypes',
96+
store: pimcore.globalmanager.get('object_search_types').filter(v => v !== "folder").map((text) => ({text})),
97+
value: this.datax.allowedObjectSubtypes,
98+
displayField: "text",
99+
valueField: "text",
100+
width: 400
101+
},
102+
{
103+
xtype: "multiselect",
104+
fieldLabel: t("allowed_classes") + '<br />' + t('allowed_types_hint'),
105+
name: "allowedClasses",
106+
id: 'allowedClasses',
107+
store: pimcore.globalmanager.get("object_types_store"),
108+
value: this.datax.allowedClasses,
109+
displayField: "text",
110+
valueField: "text",
111+
width: 400
112+
},
69113
{
70114
xtype: "multiselect",
71115
fieldLabel: t("allowed_targets") + '<br />' + t('allowed_types_hint'),
72116
name: "allowedTargets",
73117
id: 'allowedTargets',
74-
store: this.targets,
118+
store: this.targets.map((text) => ({text})),
75119
value: this.datax.allowedTargets,
76120
displayField: "text",
77121
valueField: "text",
@@ -82,7 +126,7 @@ pimcore.object.classes.data.link = Class.create(pimcore.object.classes.data.data
82126
fieldLabel: t("disabled_fields") + '<br />' + t('allowed_types_hint'),
83127
name: "disabledFields",
84128
id: 'disabledFields',
85-
store: this.fields,
129+
store: this.fields.map((text) => ({text})),
86130
value: this.datax.disabledFields,
87131
displayField: "text",
88132
valueField: "text",

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,26 @@ pimcore.object.tags.link = Class.create(pimcore.object.tags.abstract, {
143143

144144
openEditor: function () {
145145
let config = [];
146+
let allowedSubtypes = {};
146147

147148
if (!empty(this.fieldConfig.allowedTypes)){
148149
config['allowedTypes'] = this.fieldConfig.allowedTypes;
149150
}
151+
if (!empty(this.fieldConfig.allowedAssetSubtypes)){
152+
allowedSubtypes['asset'] = this.fieldConfig.allowedAssetSubtypes;
153+
}
154+
if (!empty(this.fieldConfig.allowedDocumentSubtypes)){
155+
allowedSubtypes['document'] = this.fieldConfig.allowedDocumentSubtypes;
156+
}
157+
if (!empty(this.fieldConfig.allowedObjectSubtypes)){
158+
allowedSubtypes['object'] = this.fieldConfig.allowedObjectSubtypes;
159+
}
160+
if (!empty(allowedSubtypes)) {
161+
config['allowedSubtypes'] = allowedSubtypes;
162+
}
163+
if (!empty(this.fieldConfig.allowedClasses)){
164+
config['allowedClasses'] = this.fieldConfig.allowedClasses;
165+
}
150166
if (!empty(this.fieldConfig.allowedTargets)){
151167
config['allowedTargets'] = this.fieldConfig.allowedTargets;
152168
}

translations/admin_ext.en.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ 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
253256
allowed_targets: Allowed Targets
254257
disabled_fields: Disabled Fields
255258
columnlength: Columnlength

0 commit comments

Comments
 (0)