Skip to content

Commit ed0e0f5

Browse files
smg6511opengeek
andauthored
Fix Template Access grid being initially empty when creating a new TV (#16678)
### What does it do? Adds base grid method to differentiate the intent of the category URL param, between being the value of a grid filter and that of the target category for a new Element (when choosing _Create a [Element] Here_ via the contextual menu), and applies the appropriate value for each context. ### Why is it needed? The Template Access grid initially is empty when a new Element is created in the root (i.e., it has no category), because the value of the category param is 'undefined'. ### How to test 1. Create new Elements of each type to verify normal operation. 2. Pay specific attention to the Template and TV Elements, where each has an assignment grid (Template Variables and Template Access tabs respectively). Verify these grids show as expected and are unfiltered when creating a new Element and when editing an existing one. 3. On an existing Template and TV, go to the respective assignment grid tab and use its category filter. Copy and paste the resulting URL (in the browser URL bar) and copy that into a new browser tab. Verify that the view in this new tab is the same as the previous tab where you applied the filter. (This is to ensure the somewhat new feature of grid filtering persistence via the URL still operates correctly.) ### Related issue(s)/PR(s) Resolves #16677 --------- Co-authored-by: Jason Coward <[email protected]>
1 parent 1842b9d commit ed0e0f5

File tree

5 files changed

+439
-363
lines changed

5 files changed

+439
-363
lines changed

Diff for: manager/assets/modext/modx.jsgrps-min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: manager/assets/modext/widgets/core/modx.grid.js

+12
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,18 @@ Ext.extend(MODx.grid.Grid,Ext.grid.EditorGridPanel,{
12921292
}
12931293
return config;
12941294
}
1295+
1296+
/**
1297+
* Get the request value for a grid's category filtering. Derives whether the category param is to be applied to a
1298+
* grid and its category filter based on the existence of the tab param in the GET request. Needed where the same
1299+
* category processor is used for different purposes within the same editing panel (notably the Template and TV panels).
1300+
*/
1301+
,getCategoryFilterValue: () => {
1302+
if (typeof MODx.request.tab === 'undefined' || typeof MODx.request.category === 'undefined') {
1303+
return null;
1304+
}
1305+
return Math.abs(parseInt(MODx.request.category, 10));
1306+
}
12951307
});
12961308

12971309
/* local grid */

Diff for: manager/assets/modext/widgets/element/modx.grid.template.tv.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ MODx.grid.TemplateTV = function(config = {}) {
3232
action: 'Element/Template/TemplateVar/GetList',
3333
template: config.template,
3434
sort: 'tv_rank',
35-
category: MODx.request.category || null
35+
category: this.getCategoryFilterValue()
3636
},
3737
saveParams: {
3838
template: config.template
@@ -94,7 +94,7 @@ MODx.grid.TemplateTV = function(config = {}) {
9494
xtype: 'modx-combo-category',
9595
itemId: 'filter-category',
9696
emptyText: _('filter_by_category'),
97-
value: MODx.request.category !== 'undefined' ? MODx.request.category : null,
97+
value: this.getCategoryFilterValue(),
9898
submitValue: false,
9999
hiddenName: '',
100100
width: 200,

Diff for: manager/assets/modext/widgets/element/modx.grid.tv.template.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ MODx.grid.TemplateVarTemplate = function(config = {}) {
3030
baseParams: {
3131
action: 'Element/TemplateVar/Template/GetList',
3232
tv: config.tv,
33-
category: MODx.request.category || null
33+
category: this.getCategoryFilterValue()
3434
},
3535
saveParams: {
3636
tv: config.tv
@@ -68,7 +68,7 @@ MODx.grid.TemplateVarTemplate = function(config = {}) {
6868
xtype: 'modx-combo-category',
6969
itemId: 'filter-category',
7070
emptyText: _('filter_by_category'),
71-
value: MODx.request.category !== 'undefined' ? MODx.request.category : null,
71+
value: this.getCategoryFilterValue(),
7272
submitValue: false,
7373
hiddenName: '',
7474
width: 200,

0 commit comments

Comments
 (0)