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

Settings grid adjustments for Extras support #16414

Merged
merged 2 commits into from
Aug 29, 2023
Merged
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
4 changes: 2 additions & 2 deletions manager/assets/modext/modx.jsgrps-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion manager/assets/modext/util/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ MODx.util.url = {
*/
clearParams: function(stateData = {}) {
if (typeof window.history.replaceState !== 'undefined') {
const preserve = ['a', 'id', 'key'],
const preserve = ['a', 'id', 'key', 'namespace'],
preserved = [],
urlParts = window.location.href.split('?'),
params = urlParts[1].split('&')
Expand Down
16 changes: 16 additions & 0 deletions manager/assets/modext/widgets/core/modx.grid.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ MODx.grid.SettingsGrid = function(config) {
config.tbar.push(
'->'
,{
/**
* @deprecated use of id config property deprecated in 3.0, to be removed in 3.1
*
* To access this combo in the future, get a reference to the topToolbar and use
* the getComponent method ( e.g., [gridObj].getTopToolbar().getComponent([itemId]) )
*
* Also, itemId to be renamed 'filter-namespace' in 3.1
*/
xtype: 'modx-combo-namespace'
,id: 'modx-filter-namespace'
,itemId: 'filter-ns'
,emptyText: _('namespace_filter')
,allowBlank: false
Expand Down Expand Up @@ -65,7 +74,14 @@ MODx.grid.SettingsGrid = function(config) {
}
}
},{
/**
* @deprecated use of id config property deprecated in 3.0, to be removed in 3.1
*
* To access this combo in the future, get a reference to the topToolbar and use
* the getComponent method ( e.g., [gridObj].getTopToolbar().getComponent([itemId]) )
*/
xtype: 'modx-combo-area'
,id: 'modx-filter-area'
,itemId: 'filter-area'
,emptyText: _('area_filter')
,value: MODx.request.area || null
Expand Down
56 changes: 43 additions & 13 deletions manager/assets/modext/widgets/core/modx.tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ MODx.Tabs = function(config) {
this.config = config;
this.on({
afterrender: function(tabPanel) {
if (MODx.request && MODx.request.hasOwnProperty('tab')){
const tabId = parseInt(MODx.request.tab);
this.setActiveTab(tabId);
if (MODx.request && Object.prototype.hasOwnProperty.call(MODx.request, 'tab')) {
const tabId = parseInt(MODx.request.tab, 10);
// Ensure tab panels other than the main one are unaffected
if (this.id !== 'modx-leftbar-tabpanel') {
this.setActiveTab(tabId);
}
}

/* Placing listener here because we only want to listen after the initial panel has loaded */
tabPanel.on({
beforetabchange: function(tabPanel, newTab, currentTab) {
beforetabchange: function(tabPanelCmp, newTab, currentTab) {
/*
Only proceed with the clearing process if the tab has changed.
This is needed to prevent clearing when a URL has been typed in.
Expand All @@ -44,22 +48,30 @@ MODx.Tabs = function(config) {
gridObj = null
;
if (resetVerticalTabPanelFilters) {
itemsSource = changedBetweenVtabs ? currentTab.items : currentTab.items.items[0].activeTab.items ;
itemsSource = changedBetweenVtabs
? currentTab.items
: currentTab.items.items[0].activeTab.items;
} else {
itemsSource = currentTab.items;
}
if (itemsSource.length > 0) {
gridObj = itemsSource.find(obj => {
return Object.entries(obj).find(([key, value]) => key == 'xtype' && value.includes('modx-grid'));
});
gridObj = this.findGridObject(itemsSource);
/*
Grids placed in an atypical structure, such as the ACLs User Group grid that
is activated via the User Groups tree, require further searching
*/
if (!gridObj && itemsSource?.map['modx-tree-panel-usergroup']) {
itemsSource = itemsSource.map['modx-tree-panel-usergroup'].items;
gridObj = this.findGridObject(itemsSource);
}
}
if (gridObj) {
const toolbar = gridObj.getTopToolbar(),
filterIds = []
;
if (toolbar && toolbar.items.items.length > 0) {
toolbar.items.items.forEach(cmp => {
if (cmp.xtype && (cmp.xtype.includes('combo') || cmp.xtype == 'textfield') && cmp.itemId) {
if (cmp.xtype && (cmp.xtype.includes('combo') || cmp.xtype === 'textfield') && cmp.itemId) {
filterIds.push(cmp.itemId);
}
});
Expand All @@ -74,8 +86,26 @@ MODx.Tabs = function(config) {
}
});
};
Ext.extend(MODx.Tabs,Ext.TabPanel);
Ext.reg('modx-tabs',MODx.Tabs);
Ext.extend(MODx.Tabs, Ext.TabPanel, {
/**
* @property {Function} findGridObject - Search for and return a grid object with a given items array
*
* @param {String} itemsSource - The config items array to search within
* @return {MODx.grid.Grid|undefined}
*/
findGridObject: function(itemsSource) {
const grid = itemsSource.find(obj => Object.entries(obj).find(([key, value]) => key === 'xtype' && value.includes('-grid-')));
if (grid) {
return grid;
}
const nextItemsSource = itemsSource?.items;
if (nextItemsSource) {
this.findGridObject(nextItemsSource);
}
return undefined;
}
});
Ext.reg('modx-tabs', MODx.Tabs);

MODx.VerticalTabs = function(config) {
config = config || {};
Expand All @@ -94,8 +124,8 @@ MODx.VerticalTabs = function(config) {
MODx.VerticalTabs.superclass.constructor.call(this,config);
this.config = config;
this.on('afterrender', function() {
if (MODx.request && MODx.request.hasOwnProperty('vtab')){
const tabId = parseInt(MODx.request.vtab);
if (MODx.request && Object.prototype.hasOwnProperty.call(MODx.request, 'vtab')) {
const tabId = parseInt(MODx.request.vtab, 10);
this.setActiveTab(tabId);
}
});
Expand Down