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

Grid filtering refactor for improved accuracy and persistence via URL parameters #16369

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
04467c6
Progress round 2, manual conflict resolution on base grid and tabs cl…
Jan 28, 2023
293e587
Progress round 2, manual conflict resolution for usergroup acls panels
Jan 28, 2023
a99c476
Revert "Progress round 2, manual conflict resolution on base grid and…
Jan 28, 2023
302ec13
Base class updates required for grid enhancements
Jan 30, 2023
2604a77
Filter Persistence: Policies and Policy Templates
Jan 30, 2023
06af747
Filter Persistence: Deleted Resources Manager (Trash)
Jan 30, 2023
265e845
Update user group permissions, category grid
Jan 30, 2023
b7df565
Update user group permissions, contexts grid
Jan 30, 2023
62203a7
Update user group permissions, namespace grid
Jan 30, 2023
df21190
Update user group permissions, resource groups grid
Jan 30, 2023
dbd98a6
Update user group permissions, media sources grid
Jan 30, 2023
1131e9c
Filter Persistence: Plugin Events Grid
Jan 30, 2023
b9c9131
Move resource panel-specific tabchange listener
Jan 30, 2023
a4bf921
Filter Persistence: Namespaces Grid
Jan 30, 2023
010f2a7
Filter Persistence: Contexts Grid
Jan 30, 2023
6da4c35
Filter Persistence: Form Customization Profiles Grid
Jan 30, 2023
da11cf9
Filter Persistence: Form Customization Sets Grid
Jan 30, 2023
b41b698
Filter Persistence: Dashboards Grid
Jan 31, 2023
dad621f
Filter Persistence: Dashboard Widgets Grid
Jan 31, 2023
af24d14
Filter Persistence: Packages Grid
Jan 31, 2023
7e7bfa0
Filter Persistence: Media Sources Grid
Jan 31, 2023
b7f4d2e
Update related to commit 0e0778d
Jan 31, 2023
e4c6f4d
Update related to commit c7fd92b
Jan 31, 2023
cfde395
Filter Persistence: Users Grid
Jan 31, 2023
dc219fb
Filter Persistence: Groups Panel and Users Grid
Jan 31, 2023
77193ca
Filter Persistence: Template TVs Grid
Jan 31, 2023
ea98679
Filter Persistence: TV Templates Grid
Jan 31, 2023
c7e8bba
Filter Persistence: User Messages Grid
Feb 2, 2023
5f40560
Filter Persistence: Settings Grids (4)
Feb 17, 2023
bfc8b46
Filter Persistence: System Events Grid
Feb 17, 2023
9af2ea2
Filter Persistence: Lexicons Grid
Feb 19, 2023
9d8308c
Update UserGroup Namespaces Access Grid
Feb 20, 2023
fafe721
Remove Ext Statefulness from TVs Panel
Feb 20, 2023
53e86ff
Minor refinements for better Extras suppport
Mar 14, 2023
ce7907f
Fix code quality issues
Apr 4, 2023
1ebaa55
Fix one missed CQ problem
Apr 4, 2023
92265d1
Make requested review change
Apr 4, 2023
90d0047
Update modx.panel.template.js
smg6511 Sep 10, 2023
91219e4
Required base class and utilities updates
smg6511 Sep 13, 2023
560f48e
Settings grid updates
smg6511 Sep 13, 2023
68265c2
ACL tab content updates
smg6511 Sep 13, 2023
c1c0d23
Dashboards grid fixes
smg6511 Sep 13, 2023
d6b3bda
ACLs - User Group Permissions fixes
smg6511 Sep 13, 2023
1fc4312
Post-review fixes for system settings grids
smg6511 Oct 25, 2023
dd91b49
Post-review fixes for packages grid
smg6511 Oct 25, 2023
38992d1
UG Category tweaks
smg6511 Oct 30, 2023
334d553
Base class updates
smg6511 Oct 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion _build/templates/default/sass/_toolbars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,25 @@
/* top toolbars */
.x-panel-tbar {
overflow: visible; /* prevent cut off box-shadows in FF */
padding-bottom: 2px;
padding-bottom: 4px;

.x-toolbar {
/*background-color: #F5F5F5;*/
border: 0;
padding: 5px 0;
overflow: visible; /* prevent cut off box-shadows in FF */

td {
vertical-align: bottom;
}

input {
&.filter-query {
/* fix positioning issue with query field */
position: relative;
bottom: -1px;
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/lexicon/en/dashboards.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$_lang['dashboards'] = 'Dashboards';
$_lang['dashboards.intro_msg'] = 'Here you can manage all the available Dashboards for this MODX manager.';
$_lang['rank'] = 'Rank';
$_lang['user_group_filter'] = 'By User Group';
$_lang['user_group_filter'] = 'Filter by User Group...';
$_lang['widget'] = 'Widget';
$_lang['widget_content'] = 'Widget Content';
$_lang['widget_err_ae_name'] = 'A widget with the name "[[+name]]" already exists! Please try another name.';
Expand Down Expand Up @@ -99,4 +99,4 @@
$_lang['w_whosonline'] = 'Who\'s Online';
$_lang['w_whosonline_desc'] = 'Shows a list of online users.';
$_lang['w_view_all'] = 'View all';
$_lang['w_no_data'] = 'No data to display';
$_lang['w_no_data'] = 'No data to display';
3 changes: 2 additions & 1 deletion core/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
$_lang['filter_clear'] = 'Clear Filter';
$_lang['filter_by_key'] = 'Filter by Key...';
$_lang['filter_by_name'] = 'Filter by name...';
$_lang['filter_by_event_group'] = 'Filter by event group...';
$_lang['filter_by_username'] = 'Filter by user name...';
$_lang['finish'] = 'Finish';
$_lang['folder'] = 'Folder';
Expand Down Expand Up @@ -314,7 +315,7 @@
$_lang['orm_container_rename'] = 'Rename Container';
$_lang['orm_container_remove'] = 'Delete Container';
$_lang['orm_container_remove_confirm'] = 'Are you sure you want to delete this container and all attributes below it? This is irreversible.';
$_lang['pagetitle'] = 'Resource\'s title';
$_lang['pagetitle'] = 'Resource\'s Title';
$_lang['page_title'] = 'Resource Title';
$_lang['parameter'] = 'Parameter';
$_lang['parameters'] = 'Parameters';
Expand Down
59 changes: 39 additions & 20 deletions core/src/Revolution/Processors/Context/GetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use MODX\Revolution\modContext;
use MODX\Revolution\modAccessContext;
use MODX\Revolution\modResource;
use MODX\Revolution\modUserGroup;
use MODX\Revolution\Processors\Model\GetListProcessor;
use xPDO\Om\xPDOObject;
Expand Down Expand Up @@ -53,7 +54,7 @@
{
$initialized = parent::initialize();
$this->setDefaultProperties([
'search' => '',
'query' => '',
'exclude' => '',
]);
$this->canCreate = $this->modx->hasPermission('new_context');
Expand All @@ -71,11 +72,11 @@
*/
public function prepareQueryBeforeCount(xPDOQuery $c)
{
$search = $this->getProperty('search');
if (!empty($search)) {
$query = $this->getProperty('query');
if (!empty($query)) {
$c->where([
'key:LIKE' => '%' . $search . '%',
'OR:description:LIKE' => '%' . $search . '%',
'key:LIKE' => '%' . $query . '%',
'OR:description:LIKE' => '%' . $query . '%',

Check warning on line 79 in core/src/Revolution/Processors/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Context/GetList.php#L78-L79

Added lines #L78 - L79 were not covered by tests
]);
}
$exclude = $this->getProperty('exclude');
Expand All @@ -89,21 +90,39 @@
limit results to only those contexts present in the current grid.
*/
if ($this->isGridFilter) {
if ($userGroup = $this->getProperty('usergroup', false)) {
$c->innerJoin(
modAccessContext::class,
'modAccessContext',
[
'`modAccessContext`.`target` = `modContext`.`key`',
'`modAccessContext`.`principal` = ' . (int)$userGroup,
'`modAccessContext`.`principal_class` = ' . $this->modx->quote(modUserGroup::class)
]
);
if ($policy = $this->getProperty('policy', false)) {
$c->where([
'`modAccessContext`.`policy`' => (int)$policy
]);
}
$targetGrid = $this->getProperty('targetGrid', '');

Check warning on line 93 in core/src/Revolution/Processors/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Context/GetList.php#L93

Added line #L93 was not covered by tests
switch ($targetGrid) {
case 'MODx.grid.UserGroupContext':
if ($userGroup = $this->getProperty('usergroup', false)) {
$c->innerJoin(
modAccessContext::class,
'modAccessContext',
[
'`modAccessContext`.`target` = `modContext`.`key`',
'`modAccessContext`.`principal` = ' . (int)$userGroup,
'`modAccessContext`.`principal_class` = ' . $this->modx->quote(modUserGroup::class)
]
);
if ($policy = $this->getProperty('policy', false)) {
$c->where([
'`modAccessContext`.`policy`' => (int)$policy
]);

Check warning on line 109 in core/src/Revolution/Processors/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Context/GetList.php#L95-L109

Added lines #L95 - L109 were not covered by tests
}
}
break;

Check warning on line 112 in core/src/Revolution/Processors/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Context/GetList.php#L112

Added line #L112 was not covered by tests

case 'MODx.grid.Trash':
$c->innerJoin(
modResource::class,
'modResource',
[
'`modResource`.`context_key` = `modContext`.`key`',
'`modResource`.`deleted` = 1'
]
);
break;

Check warning on line 123 in core/src/Revolution/Processors/Context/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Context/GetList.php#L114-L123

Added lines #L114 - L123 were not covered by tests

// no default case
}
}
return $c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function prepareQueryBeforeCount(xPDOQuery $c)

public function prepareQueryAfterCount(xPDOQuery $c)
{
if ($this->getProperty('sort') == 'category') {
if (!$this->isGridFilter && $this->getProperty('sort') == 'category') {
$c->sortby('parent', $this->getProperty('dir', 'ASC'));
}
$id = $this->getProperty('id', '');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the MODX Revolution package.
*
Expand All @@ -10,7 +11,6 @@

namespace MODX\Revolution\Processors\Element\Plugin\Event;


use MODX\Revolution\modEvent;
use MODX\Revolution\Processors\ModelProcessor;
use MODX\Revolution\modPluginEvent;
Expand Down Expand Up @@ -49,13 +49,6 @@ public function process()
foreach ($data['results'] as $event) {
$eventArray = $event->toArray();
$eventArray['enabled'] = $event->get('enabled') ? 1 : 0;

$eventArray['menu'] = [
[
'text' => $this->modx->lexicon('edit'),
'handler' => 'this.updateEvent',
],
];
$list[] = $eventArray;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the MODX Revolution package.
*
Expand All @@ -10,10 +11,11 @@

namespace MODX\Revolution\Processors\Element\Template\TemplateVar;


use MODX\Revolution\Processors\Model\GetListProcessor;
use MODX\Revolution\modTemplate;
use MODX\Revolution\modTemplateVar;
use xPDO\Om\xPDOObject;
use xPDO\Om\xPDOQuery;

/**
* Gets a list of TVs, marking ones associated with the template.
Expand All @@ -36,26 +38,41 @@
public $permission = ['view_tv' => true, 'view_template' => true];
public $languageTopics = ['template'];

protected $category = 0;
protected $query = '';
protected $isFiltered = false;

/**
* {@inheritDoc}
*/
public function initialize()

Check warning on line 48 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L48

Added line #L48 was not covered by tests
{
$this->category = (int)$this->getProperty('category', 0);
$this->query = $this->getProperty('query', '');
$this->isFiltered = $this->category > 0 || $this->query;
return parent::initialize();

Check warning on line 53 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L50-L53

Added lines #L50 - L53 were not covered by tests
}

/**
* Prepare conditions for TV list
*
* @return array
*/
public function prepareConditions()
public function prepareConditions(): array

Check warning on line 59 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L59

Added line #L59 was not covered by tests
{
$conditions = [];

$category = (integer)$this->getProperty('category', 0);
if ($category) {
$conditions[] = ['category' => $category];
if (!$this->isFiltered) {
return $conditions;

Check warning on line 64 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L63-L64

Added lines #L63 - L64 were not covered by tests
}

if ($this->category) {
$conditions[] = ['category' => $this->category];

Check warning on line 68 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L67-L68

Added lines #L67 - L68 were not covered by tests
}

$query = $this->getProperty('query', '');
if (!empty($query)) {
if (!empty($this->query)) {

Check warning on line 71 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L71

Added line #L71 was not covered by tests
$conditions[] = [
'name:LIKE' => '%' . $query . '%',
'OR:caption:LIKE' => '%' . $query . '%',
'OR:description:LIKE' => '%' . $query . '%',
'name:LIKE' => '%' . $this->query . '%',
'OR:caption:LIKE' => '%' . $this->query . '%',
'OR:description:LIKE' => '%' . $this->query . '%'

Check warning on line 75 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L73-L75

Added lines #L73 - L75 were not covered by tests
];
}

Expand All @@ -79,37 +96,71 @@
}

/**
* {@inheritdoc}
* @return array
* {@inheritDoc}
*/
public function getData()
public function getData(): array

Check warning on line 101 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L101

Added line #L101 was not covered by tests
{
$sort = $this->getProperty('sort');
$dir = $this->getProperty('dir');
$limit = intval($this->getProperty('limit'));
$start = intval($this->getProperty('start'));
$limit = (int)$this->getProperty('limit');
$start = (int)$this->getProperty('start');

Check warning on line 106 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L105-L106

Added lines #L105 - L106 were not covered by tests
$conditions = $this->prepareConditions();

$template = $this->loadTemplate();
$tvList = $template->getTemplateVarList([$sort => $dir], $limit, $start, $conditions);

$data = [
'total' => $tvList['total'],
'total' => $this->isFiltered ? $this->getFilteredCount() : $tvList['total'],

Check warning on line 113 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L113

Added line #L113 was not covered by tests
'results' => $tvList['collection'],
];

return $data;
}

/**
* {@inheritdoc}
* @param xPDOObject $object
*
* @return array|mixed
* Workaround to get correct total count when list is filtered
*/
public function getFilteredCount(): int

Check warning on line 123 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L123

Added line #L123 was not covered by tests
{
$c = $this->modx->newQuery(modTemplateVar::class);
$c = $this->prepareQueryBeforeCount($c);
$filteredCount = $this->modx->getCount(modTemplateVar::class, $c);

Check warning on line 127 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L125-L127

Added lines #L125 - L127 were not covered by tests

return $filteredCount;

Check warning on line 129 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L129

Added line #L129 was not covered by tests
}

/**
* {@inheritDoc}
*/
public function prepareQueryBeforeCount(xPDOQuery $c)

Check warning on line 135 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L135

Added line #L135 was not covered by tests
{
if (!$this->isFiltered) {
return $c;

Check warning on line 138 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L137-L138

Added lines #L137 - L138 were not covered by tests
}

if ($this->category) {
$c->where(
['category' => $this->category]
);

Check warning on line 144 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L141-L144

Added lines #L141 - L144 were not covered by tests
}

if ($this->query) {
$c->where([
'name:LIKE' => '%' . $this->query . '%',
'OR:caption:LIKE' => '%' . $this->query . '%',
'OR:description:LIKE' => '%' . $this->query . '%',
]);

Check warning on line 152 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L147-L152

Added lines #L147 - L152 were not covered by tests
}
return $c;

Check warning on line 154 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L154

Added line #L154 was not covered by tests
}

/**
* {@inheritDoc}
*/
public function prepareRow(xPDOObject $object)
{
$tvArray = $object->get(['id', 'name', 'caption', 'tv_rank', 'category_name']);
$tvArray['access'] = (boolean)$object->get('access');
$tvArray['access'] = (bool)$object->get('access');

Check warning on line 163 in core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/Template/TemplateVar/GetList.php#L163

Added line #L163 was not covered by tests

$tvArray['perm'] = [];
if ($this->modx->hasPermission('edit_tv')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the MODX Revolution package.
*
Expand All @@ -10,7 +11,6 @@

namespace MODX\Revolution\Processors\Element\TemplateVar\Template;


use MODX\Revolution\modCategory;
use MODX\Revolution\Processors\Processor;
use MODX\Revolution\modTemplate;
Expand Down Expand Up @@ -82,10 +82,11 @@

/* query for templates */
$c = $this->modx->newQuery(modTemplate::class);
$query = $this->getProperty('query');
$query = $this->getProperty('query', '');

Check warning on line 85 in core/src/Revolution/Processors/Element/TemplateVar/Template/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/TemplateVar/Template/GetList.php#L85

Added line #L85 was not covered by tests
if (!empty($query)) {
$c->where([
'templatename:LIKE' => "%$query%",
'templatename:LIKE' => '%' . $query . '%',
'OR:description:LIKE' => '%' . $query . '%'

Check warning on line 89 in core/src/Revolution/Processors/Element/TemplateVar/Template/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/TemplateVar/Template/GetList.php#L88-L89

Added lines #L88 - L89 were not covered by tests
]);
}
$c->leftJoin(modCategory::class, 'Category');
Expand All @@ -107,8 +108,12 @@
$c->select([
'category_name' => 'Category.category',
]);
$c->select($this->modx->getSelectColumns(modTemplateVarTemplate::class, 'TemplateVarTemplates', '',
['tmplvarid']));
$c->select($this->modx->getSelectColumns(
modTemplateVarTemplate::class,
'TemplateVarTemplates',
'',
['tmplvarid']
));

Check warning on line 116 in core/src/Revolution/Processors/Element/TemplateVar/Template/GetList.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Element/TemplateVar/Template/GetList.php#L111-L116

Added lines #L111 - L116 were not covered by tests
$c->select(['access' => 'TemplateVarTemplates.tmplvarid']);
$c->sortby($this->getProperty('sort'), $this->getProperty('dir'));
if ($isLimit) {
Expand Down
Loading
Loading