Skip to content

Commit ef40365

Browse files
Merge pull request #2881 from aarongerig/4.1
[Resource Bundle] Add specific settings for Multiselect Datatype
2 parents 82fe726 + 7338aa3 commit ef40365

File tree

3 files changed

+98
-5
lines changed

3 files changed

+98
-5
lines changed

src/CoreShop/Bundle/IndexBundle/Worker/OpenSearchWorker.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ public function updateIndex(IndexInterface $index, IndexableInterface $object):
207207
])
208208
;
209209
} catch (\Exception $exception) {
210-
// If the exception is not a "Not Found" HTTP exception, we rethrow it
211210
if ($exception->getCode() !== 404) {
212211
throw $exception;
213212
}

src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/coreExtension/data/dataMultiselect.js

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,69 @@ coreshop.object.classes.data.dataMultiselect = Class.create(pimcore.object.class
3333
$super();
3434

3535
this.specificPanel.removeAll();
36+
const specificItems = this.getSpecificPanelItems(this.datax);
37+
this.specificPanel.add(specificItems);
3638

3739
return this.layout;
38-
}
40+
},
41+
42+
getSpecificPanelItems: function (datax) {
43+
if (typeof datax.options != "object") {
44+
datax.options = [];
45+
}
46+
47+
const stylingItems = [
48+
{
49+
xtype: "textfield",
50+
fieldLabel: t("width"),
51+
name: "width",
52+
value: datax.width,
53+
},
54+
{
55+
xtype: "displayfield",
56+
hideLabel: true,
57+
value: t('width_explanation'),
58+
},
59+
{
60+
xtype: "textfield",
61+
fieldLabel: t("height"),
62+
name: "height",
63+
value: datax.height,
64+
},
65+
{
66+
xtype: "displayfield",
67+
hideLabel: true,
68+
value: t('height_explanation'),
69+
},
70+
];
71+
72+
if (this.isInCustomLayoutEditor()) {
73+
return stylingItems;
74+
}
75+
76+
return stylingItems.concat([
77+
{
78+
xtype: "numberfield",
79+
fieldLabel: t("maximum_items"),
80+
name: "maxItems",
81+
value: datax.maxItems,
82+
minValue: 0,
83+
},
84+
{
85+
xtype: "combo",
86+
fieldLabel: t("multiselect_render_type"),
87+
name: "renderType",
88+
itemId: "renderType",
89+
mode: 'local',
90+
store: [
91+
['list', 'List'],
92+
['tags', 'Tags'],
93+
],
94+
value: datax["renderType"] ? datax["renderType"] : 'list',
95+
triggerAction: "all",
96+
editable: false,
97+
forceSelection: true,
98+
},
99+
]);
100+
},
39101
});

src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/coreExtension/tags/multiselect.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,26 @@ coreshop.object.tags.multiselect = Class.create(pimcore.object.tags.multiselect,
3636
queryMode: 'local',
3737
displayField: this.displayField,
3838
valueField: 'id',
39+
labelWidth: this.fieldConfig.labelWidth || 100,
3940
listeners: {
4041
beforerender: function () {
41-
if (!store.isLoaded() && !store.isLoading())
42+
if (!store.isLoaded() && !store.isLoading()) {
4243
store.load();
43-
}
44+
}
45+
},
46+
change: function (multiselect, newValue, oldValue) {
47+
if (this.fieldConfig.maxItems && multiselect.getValue().length > this.fieldConfig.maxItems) {
48+
// we need to set a timeout so setValue is applied when change event is totally finished
49+
// without this, multiselect won't be updated visually with oldValue (but internal value will be oldValue)
50+
setTimeout(function(multiselect, oldValue){
51+
multiselect.setValue(oldValue);
52+
}, 100, multiselect, oldValue);
53+
54+
Ext.Msg.alert(t('error'), t('limit_reached'));
55+
}
56+
57+
return true;
58+
}.bind(this),
4459
}
4560
};
4661

@@ -52,11 +67,28 @@ coreshop.object.tags.multiselect = Class.create(pimcore.object.tags.multiselect,
5267
options.height = this.fieldConfig.height;
5368
}
5469

70+
if (this.fieldConfig.labelAlign) {
71+
options.labelAlign = this.fieldConfig.labelAlign;
72+
}
73+
74+
if (!this.fieldConfig.labelAlign || 'left' === this.fieldConfig.labelAlign) {
75+
options.width = this.sumWidths(options.width, options.labelWidth);
76+
}
77+
5578
if (typeof this.data == 'string' || typeof this.data == 'number') {
5679
options.value = this.data;
5780
}
5881

59-
this.component = new Ext.ux.form.MultiSelect(options);
82+
if (this.fieldConfig.renderType === 'tags') {
83+
options.queryMode = 'local';
84+
options.editable = true;
85+
options.anyMatch = true;
86+
options.plugins = 'dragdroptag';
87+
88+
this.component = new Ext.form.field.Tag(options);
89+
} else {
90+
this.component = new Ext.ux.form.MultiSelect(options);
91+
}
6092

6193
return this.component;
6294
}

0 commit comments

Comments
 (0)