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 for Template Access grid being initially empty when creating a new TV #16678

Open
wants to merge 2 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions manager/assets/modext/widgets/core/modx.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,18 @@ Ext.extend(MODx.grid.Grid,Ext.grid.EditorGridPanel,{
}
return config;
}

/**
* Get the request value for a grid's category filtering. Derives whether the category param is to be applied to a
* grid and its category filter based on the existence of the tab param in the GET request. Needed where the same
* category processor is used for different purposes within the same editing panel (notably the Template and TV panels).
*/
,getCategoryFilterValue: () => {
if (typeof MODx.request.tab === 'undefined' || typeof MODx.request.category === 'undefined') {
return null;
}
return Math.abs(parseInt(MODx.request.category, 10));
}
});

/* local grid */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MODx.grid.TemplateTV = function(config = {}) {
action: 'Element/Template/TemplateVar/GetList',
template: config.template,
sort: 'tv_rank',
category: MODx.request.category || null
category: this.getCategoryFilterValue()
},
saveParams: {
template: config.template
Expand Down Expand Up @@ -94,7 +94,7 @@ MODx.grid.TemplateTV = function(config = {}) {
xtype: 'modx-combo-category',
itemId: 'filter-category',
emptyText: _('filter_by_category'),
value: MODx.request.category !== 'undefined' ? MODx.request.category : null,
value: this.getCategoryFilterValue(),
submitValue: false,
hiddenName: '',
width: 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MODx.grid.TemplateVarTemplate = function(config = {}) {
baseParams: {
action: 'Element/TemplateVar/Template/GetList',
tv: config.tv,
category: MODx.request.category || null
category: this.getCategoryFilterValue()
},
saveParams: {
tv: config.tv
Expand Down Expand Up @@ -68,7 +68,7 @@ MODx.grid.TemplateVarTemplate = function(config = {}) {
xtype: 'modx-combo-category',
itemId: 'filter-category',
emptyText: _('filter_by_category'),
value: MODx.request.category !== 'undefined' ? MODx.request.category : null,
value: this.getCategoryFilterValue(),
submitValue: false,
hiddenName: '',
width: 200,
Expand Down
Loading