Skip to content

Commit

Permalink
- [#227] Improved performance of the grid with options in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bezumkin committed Sep 14, 2016
1 parent 5622a3b commit eb0037e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 44 deletions.
53 changes: 33 additions & 20 deletions assets/components/minishop2/js/mgr/settings/option/grid.js
Expand Up @@ -33,7 +33,7 @@ Ext.extend(miniShop2.grid.Option, miniShop2.grid.Default, {
getFields: function () {
return [
'id', 'key', 'caption', 'description', 'measure_unit',
'category', 'type', 'properties', 'rank', 'categories', 'actions'
'category', 'type', 'properties', 'rank', 'actions'
];
},

Expand Down Expand Up @@ -124,31 +124,44 @@ Ext.extend(miniShop2.grid.Option, miniShop2.grid.Default, {
if (w) {
w.close();
}
w = MODx.load({
xtype: 'minishop2-window-option-update',
id: 'minishop2-window-option-update',
title: this.menu.record['caption'],
record: this.menu.record,
MODx.Ajax.request({
url: this.config.url,
params: {
action: 'mgr/settings/option/get',
id: this.menu.record.id
},
listeners: {
afterrender: function () {
var combo = Ext.getCmp(this.config.id + '-types');
combo.getStore().on('load', function () {
var row = combo.findRecord('name', combo.getValue());
if (row && row.data['xtype']) {
w.onSelectType(combo, row);
}
});
},
success: {
fn: function () {
this.refresh();
fn: function (r) {
w = MODx.load({
xtype: 'minishop2-window-option-update',
id: 'minishop2-window-option-update',
title: r.object['caption'],
record: r.object,
listeners: {
afterrender: function () {
var combo = Ext.getCmp(this.config.id + '-types');
combo.getStore().on('load', function () {
var row = combo.findRecord('name', combo.getValue());
if (row && row.data['xtype']) {
w.onSelectType(combo, row);
}
});
},
success: {
fn: function () {
this.refresh();
}, scope: this
}
}
});
w.fp.getForm().reset();
w.fp.getForm().setValues(r.object);
w.show(e.target);
}, scope: this
}
}
});
w.fp.getForm().reset();
w.fp.getForm().setValues(this.menu.record);
w.show(e.target);
},

removeOption: function () {
Expand Down
1 change: 1 addition & 0 deletions core/components/minishop2/docs/changelog.txt
Expand Up @@ -6,6 +6,7 @@ Changelog for miniShop2.
- [#236] Ability to display category columns of an ordered product.
- [#231] Snippet msOptions now transfers id of a product into a chunk.
- [#228] Possible fix for "empty file" in product gallery on some server configurations.
- [#227] Improved performance of the grid with options in settings.

2.4.2 pl
==============
Expand Down
Expand Up @@ -45,8 +45,17 @@ public function beforeOutput()
}
$this->object->set('categories', $data);

$properties = $this->object->getInputProperties();
$this->object->set('properties', $properties);
$data = array();
$categories = $this->object->getIterator('OptionCategories');
/** @var msCategoryOption $cat */
foreach ($categories as $cat) {
$category = $cat->getOne('Category');
if ($category) {
$data[] = $category->get('id');
}
}
$this->object->set('categories', json_encode($data));
$this->object->set('properties', $this->object->getInputProperties());
}
}

Expand Down
Expand Up @@ -63,29 +63,7 @@ public function prepareRow(xPDOObject $object)
{
$data = $object->toArray();

$categories = $object->getMany('OptionCategories');
$data['categories'] = array();
/** @var msCategoryOption $cat */
foreach ($categories as $cat) {
$category = $cat->getOne('Category');
if ($category) {
$data['categories'][] = $category->get('id');
}
}
$data['categories'] = json_encode($data['categories']);

$data['actions'] = array(
/*
array(
'cls' => '',
'icon' => 'icon icon-check',
'title' => $this->modx->lexicon('ms2_menu_assign'),
'multiple' => $this->modx->lexicon('ms2_menu_assign'),
'action' => 'assignOption',
'button' => true,
'menu' => true,
),
*/
array(
'cls' => '',
'icon' => 'icon icon-edit',
Expand Down

0 comments on commit eb0037e

Please sign in to comment.