Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix grouping grid sorting - ACL grids #16529

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions core/src/Revolution/Processors/Model/GetListProcessor.php
Expand Up @@ -48,6 +48,9 @@
$this->setDefaultProperties([
'start' => 0,
'limit' => 20,
'isGroupingGrid' => false,
'groupBy' => null,
'groupDir' => 'ASC',
'sort' => $this->defaultSortField,
'dir' => $this->defaultSortDirection,
'combo' => false,
Expand Down Expand Up @@ -187,6 +190,42 @@
return $this->classKey;
}

/**
* Adds additional sortby criteria for grouping grids when the column being sorted is different than the one being grouped.
* Grouping is handled internally by Ext JS, so we do not (and should not) use groupby criteria in the query.
*
* @param xPDOQuery $c A reference to the current query being built
* @param string $sortBy The data index of the selected sorting column
* @param string $groupBy The data index of the selected grouping column
* @param string $groupKey The grouping column's fully qualified SQL column name
* @param string $gridCategory An identifier used when additional grid category-specific condition(s) are required
*
* @return void
*/
public function setGroupSort(xPDOQuery &$c, string $sortBy, string $groupBy, string $groupKey, string $gridCategory = '')

Check warning on line 205 in core/src/Revolution/Processors/Model/GetListProcessor.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Model/GetListProcessor.php#L205

Added line #L205 was not covered by tests
{
/*
When group sort and column sort are the same data index, sort the groups
based on the current column sort direction. Otherwise, add an initial sortby
to specify the group sort; the secondary (sorting within the groups) is subsequently
added later in the getData method.
*/
switch ($gridCategory) {
case 'usergroup-acl':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this logic be in the generic GetListProcessor or something ACL related?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose the placement of the logic based on looking to support other grouping grids down the road (e.g., the Settings one [which could use some work as mentioned in the opening comments], or any Extras that might make use of that type of grid). That said, let me know if you think there's a more appropriate place; perhaps a new processor extending the main GetListProcessor.

Copy link
Collaborator Author

@smg6511 smg6511 Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mark-H - Hey, it's been a while since you made this comment; let me know what your thoughts are on my response above... Thx ;-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there needs to be an extra hook in the base getlist processor I don't have objections to that, but I do still think it's kinda weird to have a switch with values for specific implementations in a base class. That just seems like it's not architected properly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's not ideal; honestly there's a fair amount of wonkiness in the arch of the processors in general (e.g., there's inconsistency in how get data is handled [ two ways that I've come across ]) that makes it difficult to keep things DRY.

I can take a look at adding an intermediate class if you prefer.

$secondaryCondition = $sortBy === 'authority' && $groupBy === 'role_display';
break;

Check warning on line 216 in core/src/Revolution/Processors/Model/GetListProcessor.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Model/GetListProcessor.php#L214-L216

Added lines #L214 - L216 were not covered by tests
default:
$secondaryCondition = false;
break;

Check warning on line 219 in core/src/Revolution/Processors/Model/GetListProcessor.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Model/GetListProcessor.php#L218-L219

Added lines #L218 - L219 were not covered by tests
}

if ($sortBy === $groupBy || $secondaryCondition) {
$this->setProperty('groupDir', $this->getProperty('dir'));

Check warning on line 223 in core/src/Revolution/Processors/Model/GetListProcessor.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Model/GetListProcessor.php#L222-L223

Added lines #L222 - L223 were not covered by tests
} else {
$c->sortby($groupKey, $this->getProperty('groupDir'));

Check warning on line 225 in core/src/Revolution/Processors/Model/GetListProcessor.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Model/GetListProcessor.php#L225

Added line #L225 was not covered by tests
}
}

/**
* Can be used to adjust the query prior to the COUNT statement
*
Expand Down
Expand Up @@ -57,6 +57,13 @@
if (!empty($userGroup)) {
$this->userGroup = $this->modx->getObject(modUserGroup::class, $userGroup);
}
/*
Need to sort on the int field (authority) instead of the composite string field
(role_display) to order properly with the format of '[authority] - [role_name]'
*/
if ($this->getProperty('sort') == 'role_display') {
$this->setProperty('sort', 'authority');

Check warning on line 65 in core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php#L64-L65

Added lines #L64 - L65 were not covered by tests
}
return $initialized;
}

Expand Down Expand Up @@ -94,12 +101,32 @@
$c->leftJoin(modAccessPolicy::class, 'Policy');
$c->select($this->modx->getSelectColumns(modAccessNamespace::class, 'modAccessNamespace'));
$c->select([
'name' => 'Target.name',
'role_name' => 'Role.name',
'policy_name' => 'Policy.name',
'policy_data' => 'Policy.data',
'name' => '`Target`.`name`',
'policy_name' => '`Policy`.`name`',
'policy_data' => '`Policy`.`data`',
'role_display' => 'CONCAT_WS(\' - \',`modAccessNamespace`.`authority`,`Role`.`name`)'

Check warning on line 107 in core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php#L104-L107

Added lines #L104 - L107 were not covered by tests
]);

if ($this->getProperty('isGroupingGrid')) {
$groupBy = $this->getProperty('groupBy');
$sortBy = $this->getProperty('sort');
if (!empty($groupBy)) {

Check warning on line 112 in core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php#L109-L112

Added lines #L109 - L112 were not covered by tests
switch ($groupBy) {
case 'name':
$groupKey = '`Target`.`name`';
break;
case 'role_display':
$groupKey = '`modAccessNamespace`.`authority`';
break;
case 'policy_name':
$groupKey = '`Policy`.`name`';
break;

Check warning on line 122 in core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php#L114-L122

Added lines #L114 - L122 were not covered by tests
default:
$groupKey = '`modAccessNamespace`.`' . $groupBy . '`';
break;

Check warning on line 125 in core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php#L124-L125

Added lines #L124 - L125 were not covered by tests
}
$this->setGroupSort($c, $sortBy, $groupBy, $groupKey, 'usergroup-acl');

Check warning on line 127 in core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/AccessNamespace/GetList.php#L127

Added line #L127 was not covered by tests
}
}
return $c;
}

Expand Down
Expand Up @@ -58,7 +58,13 @@
if (!empty($userGroup)) {
$this->userGroup = $this->modx->getObject(modUserGroup::class, $userGroup);
}

/*
Need to sort on the int field (authority) instead of the composite string field
(role_display) to order properly with the format of '[authority] - [role_name]'
*/
if ($this->getProperty('sort') == 'role_display') {
$this->setProperty('sort', 'authority');

Check warning on line 66 in core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php#L65-L66

Added lines #L65 - L66 were not covered by tests
}
return $initialized;
}

Expand Down Expand Up @@ -96,12 +102,32 @@
$c->leftJoin(modAccessPolicy::class, 'Policy');
$c->select($this->modx->getSelectColumns(modAccessCategory::class, 'modAccessCategory'));
$c->select([
'name' => 'Target.category',
'role_name' => 'Role.name',
'policy_name' => 'Policy.name',
'policy_data' => 'Policy.data',
'name' => '`Target`.`category`',
'policy_name' => '`Policy`.`name`',
'policy_data' => '`Policy`.`data`',
'role_display' => 'CONCAT_WS(\' - \',`modAccessCategory`.`authority`,`Role`.`name`)'

Check warning on line 108 in core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php#L105-L108

Added lines #L105 - L108 were not covered by tests
]);

if ($this->getProperty('isGroupingGrid')) {
$groupBy = $this->getProperty('groupBy');
$sortBy = $this->getProperty('sort');
if (!empty($groupBy)) {

Check warning on line 113 in core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php#L110-L113

Added lines #L110 - L113 were not covered by tests
switch ($groupBy) {
case 'name':
$groupKey = '`Target`.`category`';
break;
case 'role_display':
$groupKey = '`modAccessCategory`.`authority`';
break;
case 'policy_name':
$groupKey = '`Policy`.`name`';
break;

Check warning on line 123 in core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php#L115-L123

Added lines #L115 - L123 were not covered by tests
default:
$groupKey = '`modAccessCategory`.`' . $groupBy . '`';
break;

Check warning on line 126 in core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php#L125-L126

Added lines #L125 - L126 were not covered by tests
}
$this->setGroupSort($c, $sortBy, $groupBy, $groupKey, 'usergroup-acl');

Check warning on line 128 in core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Category/GetList.php#L128

Added line #L128 was not covered by tests
}
}
return $c;
}

Expand All @@ -116,7 +142,6 @@
if (empty($objectArray['name'])) {
$objectArray['name'] = '(' . $this->modx->lexicon('none') . ')';
}
$objectArray['authority_name'] = !empty($objectArray['role_name']) ? $objectArray['role_name'] . ' - ' . $objectArray['authority'] : $objectArray['authority'];

/* get permissions list */
$data = $objectArray['policy_data'];
Expand Down
Expand Up @@ -56,6 +56,13 @@
if (!empty($userGroup)) {
$this->userGroup = $this->modx->getObject(modUserGroup::class, $userGroup);
}
/*
Need to sort on the int field (authority) instead of the composite string field
(role_display) to order properly with the format of '[authority] - [role_name]'
*/
if ($this->getProperty('sort') == 'role_display') {
$this->setProperty('sort', 'authority');

Check warning on line 64 in core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php#L63-L64

Added lines #L63 - L64 were not covered by tests
}
return $initialized;
}

Expand Down Expand Up @@ -91,10 +98,28 @@
$c->leftJoin(modAccessPolicy::class, 'Policy');
$c->select($this->modx->getSelectColumns(modAccessContext::class, 'modAccessContext'));
$c->select([
'role_name' => 'Role.name',
'policy_name' => 'Policy.name',
'policy_data' => 'Policy.data',
'policy_name' => '`Policy`.`name`',
'policy_data' => '`Policy`.`data`',
'role_display' => 'CONCAT_WS(\' - \',`modAccessContext`.`authority`,`Role`.`name`)'

Check warning on line 103 in core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php#L101-L103

Added lines #L101 - L103 were not covered by tests
]);
if ($this->getProperty('isGroupingGrid')) {
$groupBy = $this->getProperty('groupBy');
$sortBy = $this->getProperty('sort');
if (!empty($groupBy)) {

Check warning on line 108 in core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php#L105-L108

Added lines #L105 - L108 were not covered by tests
switch ($groupBy) {
case 'role_display':
$groupKey = '`modAccessContext`.`authority`';
break;
case 'policy_name':
$groupKey = '`Policy`.`name`';
break;

Check warning on line 115 in core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php#L110-L115

Added lines #L110 - L115 were not covered by tests
default:
$groupKey = '`modAccessContext`.`' . $groupBy . '`';
break;

Check warning on line 118 in core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php#L117-L118

Added lines #L117 - L118 were not covered by tests
}
$this->setGroupSort($c, $sortBy, $groupBy, $groupKey, 'usergroup-acl');

Check warning on line 120 in core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Context/GetList.php#L120

Added line #L120 was not covered by tests
}
}
return $c;
}

Expand All @@ -109,10 +134,6 @@
if (empty($objectArray['name'])) {
$objectArray['name'] = '(' . $this->modx->lexicon('none') . ')';
}
$objectArray['authority_name'] = !empty($objectArray['role_name'])
? $objectArray['role_name'] . ' - ' . $objectArray['authority']
: $objectArray['authority']
;

/* get permissions list */
$data = $objectArray['policy_data'];
Expand Down
Expand Up @@ -58,7 +58,13 @@
if (!empty($userGroup)) {
$this->userGroup = $this->modx->getObject(modUserGroup::class, $userGroup);
}

/*
Need to sort on the int field (authority) instead of the composite string field
(role_display) to order properly with the format of '[authority] - [role_name]'
*/
if ($this->getProperty('sort') == 'role_display') {
$this->setProperty('sort', 'authority');

Check warning on line 66 in core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php#L65-L66

Added lines #L65 - L66 were not covered by tests
}
return $initialized;
}

Expand Down Expand Up @@ -96,12 +102,32 @@
$c->leftJoin(modAccessPolicy::class, 'Policy');
$c->select($this->modx->getSelectColumns(modAccessResourceGroup::class, 'modAccessResourceGroup'));
$c->select([
'name' => 'Target.name',
'role_name' => 'Role.name',
'policy_name' => 'Policy.name',
'policy_data' => 'Policy.data',
'name' => '`Target`.`name`',
'policy_name' => '`Policy`.`name`',
'policy_data' => '`Policy`.`data`',
'role_display' => 'CONCAT_WS(\' - \',`modAccessResourceGroup`.`authority`,`Role`.`name`)'

Check warning on line 108 in core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php#L105-L108

Added lines #L105 - L108 were not covered by tests
]);

if ($this->getProperty('isGroupingGrid')) {
$groupBy = $this->getProperty('groupBy');
$sortBy = $this->getProperty('sort');
if (!empty($groupBy)) {

Check warning on line 113 in core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php#L110-L113

Added lines #L110 - L113 were not covered by tests
switch ($groupBy) {
case 'name':
$groupKey = '`Target`.`name`';
break;
case 'role_display':
$groupKey = '`modAccessResourceGroup`.`authority`';
break;
case 'policy_name':
$groupKey = '`Policy`.`name`';
break;

Check warning on line 123 in core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php#L115-L123

Added lines #L115 - L123 were not covered by tests
default:
$groupKey = '`modAccessResourceGroup`.`' . $groupBy . '`';
break;

Check warning on line 126 in core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php#L125-L126

Added lines #L125 - L126 were not covered by tests
}
$this->setGroupSort($c, $sortBy, $groupBy, $groupKey, 'usergroup-acl');

Check warning on line 128 in core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/ResourceGroup/GetList.php#L128

Added line #L128 was not covered by tests
}
}
return $c;
}

Expand All @@ -116,10 +142,6 @@
if (empty($objectArray['name'])) {
$objectArray['name'] = '(' . $this->modx->lexicon('none') . ')';
}
$objectArray['authority_name'] = !empty($objectArray['role_name'])
? $objectArray['role_name'] . ' - ' . $objectArray['authority']
: $objectArray['authority']
;

/* get permissions list */
$data = $objectArray['policy_data'];
Expand Down
Expand Up @@ -57,7 +57,13 @@
if (!empty($userGroup)) {
$this->userGroup = $this->modx->getObject(modUserGroup::class, $userGroup);
}

/*
Need to sort on the int field (authority) instead of the composite string field
(role_display) to order properly with the format of '[authority] - [role_name]'
*/
if ($this->getProperty('sort') == 'role_display') {
$this->setProperty('sort', 'authority');

Check warning on line 65 in core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php#L64-L65

Added lines #L64 - L65 were not covered by tests
}
return $initialized;
}

Expand Down Expand Up @@ -102,12 +108,32 @@
$c->leftJoin(modAccessPolicy::class, 'Policy');
$c->select($this->modx->getSelectColumns(modAccessMediaSource::class, 'modAccessMediaSource'));
$c->select([
'name' => 'Target.name',
'role_name' => 'Role.name',
'policy_name' => 'Policy.name',
'policy_data' => 'Policy.data',
'name' => '`Target`.`name`',
'policy_name' => '`Policy`.`name`',
'policy_data' => '`Policy`.`data`',
'role_display' => 'CONCAT_WS(\' - \',`modAccessMediaSource`.`authority`,`Role`.`name`)'

Check warning on line 114 in core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php#L111-L114

Added lines #L111 - L114 were not covered by tests
]);

if ($this->getProperty('isGroupingGrid')) {
$groupBy = $this->getProperty('groupBy');
$sortBy = $this->getProperty('sort');
if (!empty($groupBy)) {

Check warning on line 119 in core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php#L116-L119

Added lines #L116 - L119 were not covered by tests
switch ($groupBy) {
case 'name':
$groupKey = '`Target`.`name`';
break;
case 'role_display':
$groupKey = '`modAccessMediaSource`.`authority`';
break;
case 'policy_name':
$groupKey = '`Policy`.`name`';
break;

Check warning on line 129 in core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php#L121-L129

Added lines #L121 - L129 were not covered by tests
default:
$groupKey = '`modAccessMediaSource`.`' . $groupBy . '`';
break;

Check warning on line 132 in core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php#L131-L132

Added lines #L131 - L132 were not covered by tests
}
$this->setGroupSort($c, $sortBy, $groupBy, $groupKey, 'usergroup-acl');

Check warning on line 134 in core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Access/UserGroup/Source/GetList.php#L134

Added line #L134 was not covered by tests
}
}
return $c;
}

Expand Down
24 changes: 21 additions & 3 deletions manager/assets/modext/widgets/core/modx.grid.js
Expand Up @@ -224,6 +224,7 @@ Ext.extend(MODx.grid.Grid,Ext.grid.EditorGridPanel,{
this.getView().emptyText = `<div class="error-with-icon">${msg}</div>`;
this.getView().refresh(false);
}

,saveRecord: function(e) {
e.record.data.menu = null;
var p = this.config.saveParams || {};
Expand Down Expand Up @@ -406,14 +407,31 @@ Ext.extend(MODx.grid.Grid,Ext.grid.EditorGridPanel,{
,remoteSort: this.config.remoteSort || false
,remoteGroup: this.config.remoteGroup || false
,groupField: this.config.groupBy || 'name'
,groupDir: this.config.groupDir || 'ASC'
,storeId: this.config.storeId || Ext.id()
,autoDestroy: true
,listeners:{
load: function(){
,listeners: {
beforeload: function(store, options) {
const changedGroupDir = store.groupField === store.sortInfo.field && store.groupDir !== store.sortInfo.direction;
if (changedGroupDir) {
store.groupDir = store.sortInfo.direction;
store.baseParams.groupDir = store.sortInfo.direction;
}
},
load: function(store, records, options) {
const cmp = Ext.getCmp('modx-content');
if (cmp) {
cmp.doLayout();
}
},
groupchange: {
fn: function(store, groupField) {
store.groupDir = this.config.groupDir || 'ASC';
store.baseParams.groupDir = store.groupDir;
store.sortInfo.direction = this.config.sortDir || 'ASC';
store.load();
},
scope: this
}
}
});
Expand All @@ -428,7 +446,7 @@ Ext.extend(MODx.grid.Grid,Ext.grid.EditorGridPanel,{
,storeId: this.config.storeId || Ext.id()
,autoDestroy: true
,listeners:{
load: function(){
load: function() {
const cmp = Ext.getCmp('modx-content');
if (cmp) {
cmp.doLayout();
Expand Down