Skip to content

Commit c301e70

Browse files
committed
SW-15412 - Merge config and base combobox and ensure usage of unique store instance
This commits improves the base combo box `Shopware.apps.Config.view.element.Select`, which is used e.g. when viewing plugin configuration forms via the settings module, to allow passing a store ID as the `store` parameter. This is escpecially usefull when providing selections of e.g. payment methods (`Shopware.apps.Base.store.Payment`) or dispatch methods (`Shopware.apps.Base.store.Dispatch`). In order to avoid side effects of other backend modules using the same store instance (and e.g. setting filters on it), the combo box does not use the instance that is registered by the passed store ID, but creates and uses a new instance of that store instead. See also PR #525 for the original change of the `base` combo box, which is used when viewing plugin config forms in the plugin manager. This commit fixes the viewing of the same plugin config forms in the settings module. Furthermore it already includes the latest fix to support old storeIDs (22f5cac). This commit does not introduce any breaking changes.
1 parent b12c51c commit c301e70

File tree

2 files changed

+8
-51
lines changed

2 files changed

+8
-51
lines changed

UPGRADE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ In this document you will find a changelog of the important changes related to t
398398
* `\Shopware\Bundle\StoreFrontBundle\Struct\ProductContext`
399399
* `\Shopware\Bundle\StoreFrontBundle\Struct\LocationContextInterface`
400400
* `\Shopware\Bundle\StoreFrontBundle\Struct\ProductContextInterface`
401-
401+
* Added support for loading a new store instance by ID in the config combo box `Shopware.apps.Config.view.element.Select`
402402

403403
## 5.1.6
404404
* The interface `Enlight_Components_Cron_Adapter` in `engine/Library/Enlight/Components/Cron/Adapter.php` got a new method `getJobByAction`. For default implementation see `engine/Library/Enlight/Components/Cron/Adapter/DBAL.php`.

themes/Backend/ExtJs/backend/config/view/element/select.js

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
* The licensing of the program under the AGPLv3 does not imply a
2020
* trademark license. Therefore any rights, title and interest in
2121
* our trademarks remain entirely with us.
22-
*/
23-
24-
/**
25-
* todo@all: Documentation
22+
*
23+
* @category Shopware
24+
* @package Config
25+
* @subpackage Component
26+
* @version $Id$
27+
* @author shopware AG
2628
*/
2729
Ext.define('Shopware.apps.Config.view.element.Select', {
28-
extend:'Ext.form.field.ComboBox',
30+
extend:'Shopware.apps.Base.view.element.Select',
2931
alias:[
3032
'widget.config-element-select',
3133
'widget.config-element-combo',
@@ -34,56 +36,11 @@ Ext.define('Shopware.apps.Config.view.element.Select', {
3436
],
3537

3638
queryMode:'remote',
37-
forceSelection: false,
38-
editable: true,
39-
valueField: 'id',
40-
displayField: 'name',
4139

4240
initComponent:function () {
4341
var me = this;
4442

45-
if (me.controller && me.action) {
46-
//me.value = parseInt(me.value);
47-
me.store = new Ext.data.Store({
48-
url:'{url controller=index}/' + me.controller + '/' + me.action,
49-
autoLoad:true,
50-
reader:new Ext.data.JsonReader({
51-
root:me.root || 'data',
52-
totalProperty:me.count || 'total',
53-
fields:me.fields
54-
})
55-
});
56-
// Remove value field for reasons of compatibility
57-
me.valueField = me.displayField;
58-
}
59-
// Eval the store string if it contains a statement.
60-
if (typeof(me.store) == 'string' && me.store.indexOf('new ') !== -1) {
61-
//me.value = parseInt(me.value);
62-
eval('me.store = ' + me.store + ';');
63-
// Remove value field for reasons of compatibility
64-
me.valueField = me.displayField;
65-
}
66-
6743
me.callParent(arguments);
6844
me.queryCaching = (me.store.$className == 'Ext.data.ArrayStore');
69-
},
70-
71-
setValue:function (value) {
72-
var me = this;
73-
74-
if (value !== null && !me.store.loading && me.store.getCount() == 0) {
75-
me.store.load({
76-
callback:function () {
77-
if(me.store.getCount() > 0) {
78-
me.setValue(value);
79-
} else {
80-
me.setValue(null);
81-
}
82-
}
83-
});
84-
return;
85-
}
86-
87-
me.callParent(arguments);
8845
}
8946
});

0 commit comments

Comments
 (0)