Skip to content

Commit

Permalink
Settings grid adjustments for Extras support (#16414)
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 9121214b1d1f1c093de9779fafb2004497a38a28
Author: Jason Coward <jason@opengeek.com>
Date:   Tue Aug 29 14:13:36 2023 -0600

    grunt build

commit 3a32455b58247735ab67adf362eeb2bebfbc8122
Author: Jim Graham <info@sparkmediagroup.com>
Date:   Tue Apr 4 16:25:45 2023 -0400

    Settings grid adjustments for Extras support
  • Loading branch information
opengeek committed Aug 29, 2023
1 parent 7b06b49 commit 09676ea
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
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

0 comments on commit 09676ea

Please sign in to comment.