From 331bce57805b4ee1bcbd53082f4f00714d380c66 Mon Sep 17 00:00:00 2001 From: Jim Graham Date: Sun, 18 Feb 2024 12:34:31 -0500 Subject: [PATCH] Cleanup code formatting Formatting, var naming, and other stylistic changes only; no functional changes. --- .../security/modx.grid.user.group.category.js | 468 ++++++++--------- .../security/modx.grid.user.group.context.js | 423 ++++++++-------- .../modx.grid.user.group.namespace.js | 444 ++++++++-------- .../security/modx.grid.user.group.resource.js | 475 +++++++++--------- .../security/modx.grid.user.group.source.js | 442 ++++++++-------- 5 files changed, 1154 insertions(+), 1098 deletions(-) diff --git a/manager/assets/modext/widgets/security/modx.grid.user.group.category.js b/manager/assets/modext/widgets/security/modx.grid.user.group.category.js index 4fc422b7b26..182c785c5b3 100644 --- a/manager/assets/modext/widgets/security/modx.grid.user.group.category.js +++ b/manager/assets/modext/widgets/security/modx.grid.user.group.category.js @@ -10,17 +10,17 @@ MODx.grid.UserGroupCategory = function(config = {}) { lazyRender: false, enableCaching: false }); - Ext.applyIf(config,{ - id: 'modx-grid-user-group-categories' - ,url: MODx.config.connector_url - ,baseParams: { - action: 'Security/Access/UserGroup/Category/GetList' - ,usergroup: config.usergroup - ,category: MODx.request.category || null - ,policy: this.applyRequestFilter(2) - ,isGroupingGrid: true - } - ,fields: [ + Ext.applyIf(config, { + id: 'modx-grid-user-group-categories', + url: MODx.config.connector_url, + baseParams: { + action: 'Security/Access/UserGroup/Category/GetList', + usergroup: config.usergroup, + category: MODx.request.category || null, + policy: this.applyRequestFilter(2), + isGroupingGrid: true + }, + fields: [ 'id', 'target', 'name', @@ -32,73 +32,73 @@ MODx.grid.UserGroupCategory = function(config = {}) { 'context_key', 'permissions', 'cls' - ] - ,grouping: true - ,groupBy: 'role_display' - ,remoteGroup: true - ,sortBy: 'name' - ,remoteSort: true - ,paging: true - ,hideMode: 'offsets' - ,singleText: _('policy') - ,pluralText: _('policies') - ,plugins: [this.exp] - ,columns: [ + ], + grouping: true, + groupBy: 'role_display', + remoteGroup: true, + sortBy: 'name', + remoteSort: true, + paging: true, + hideMode: 'offsets', + singleText: _('policy'), + pluralText: _('policies'), + plugins: [this.exp], + columns: [ this.exp, { - header: _('category') - ,dataIndex: 'name' - ,width: 120 - ,sortable: true - },{ - header: _('minimum_role') - ,dataIndex: 'role_display' - ,width: 100 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/permission', 'role_display') - },{ - header: _('policy') - ,dataIndex: 'policy_name' - ,width: 200 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { + header: _('category'), + dataIndex: 'name', + width: 120, + sortable: true + }, { + header: _('minimum_role'), + dataIndex: 'role_display', + width: 100, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/permission', 'role_display') + }, { + header: _('policy'), + dataIndex: 'policy_name', + width: 200, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { linkParams: [{ key: 'id', valueIndex: 'policy' }] }) - },{ - header: _('context') - ,dataIndex: 'context_key' - ,width: 150 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('context/update', 'context_key', { + }, { + header: _('context'), + dataIndex: 'context_key', + width: 150, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('context/update', 'context_key', { linkParams: [{ key: 'key', valueIndex: 'context_key' }] }) } - ] - ,tbar: [ + ], + tbar: [ { - text: _('category_add') - ,cls: 'primary-button' - ,scope: this - ,handler: this.createAcl + text: _('category_add'), + cls: 'primary-button', + scope: this, + handler: this.createAcl }, '->', { - xtype: 'modx-combo-category' - ,itemId: 'filter-category' - ,emptyText: _('filter_by_category') - ,width: 200 - ,allowBlank: true - ,displayField: 'category' - ,value: MODx.request.category || null - ,baseParams: { + xtype: 'modx-combo-category', + itemId: 'filter-category', + emptyText: _('filter_by_category'), + width: 200, + allowBlank: true, + displayField: 'category', + value: MODx.request.category || null, + baseParams: { action: 'Element/Category/GetList', isGridFilter: true, usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-policy-category', 'category', record.data.id); @@ -107,21 +107,21 @@ MODx.grid.UserGroupCategory = function(config = {}) { scope: this } } - },{ - xtype: 'modx-combo-policy' - ,itemId: 'filter-policy-category' - ,emptyText: _('filter_by_policy') - ,width: 180 - ,allowBlank: true - ,value: this.applyRequestFilter(2) - ,baseParams: { + }, { + xtype: 'modx-combo-policy', + itemId: 'filter-policy-category', + emptyText: _('filter_by_policy'), + width: 180, + allowBlank: true, + value: this.applyRequestFilter(2), + baseParams: { action: 'Security/Access/Policy/GetList', group: 'Element,Object', isGridFilter: true, targetGrid: 'MODx.grid.UserGroupCategory', usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-category', 'policy', record.data.id); @@ -137,9 +137,9 @@ MODx.grid.UserGroupCategory = function(config = {}) { ) ] }); - MODx.grid.UserGroupCategory.superclass.constructor.call(this,config); + MODx.grid.UserGroupCategory.superclass.constructor.call(this, config); - this.addEvents('createAcl','updateAcl'); + this.addEvents('createAcl', 'updateAcl'); const gridFilterData = [ { filterId: 'filter-policy-category', dependentParams: ['category'] }, @@ -148,12 +148,12 @@ MODx.grid.UserGroupCategory = function(config = {}) { this.on({ createAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, updateAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, @@ -162,11 +162,11 @@ MODx.grid.UserGroupCategory = function(config = {}) { } }); }; -Ext.extend(MODx.grid.UserGroupCategory,MODx.grid.Grid,{ - combos: {} - ,windows: {} +Ext.extend(MODx.grid.UserGroupCategory, MODx.grid.Grid, { + combos: {}, + windows: {}, - ,getMenu: function() { + getMenu: function() { const record = this.getSelectionModel().getSelected(), permissions = record.data.cls, menu = [] @@ -175,19 +175,19 @@ Ext.extend(MODx.grid.UserGroupCategory,MODx.grid.Grid,{ if (this.getSelectionModel().getCount() > 1) { // Currently not allowing bulk actions for this grid } else { - if (permissions.indexOf('pedit') != -1) { + if (permissions.indexOf('pedit') !== -1) { menu.push({ text: _('access_category_update'), handler: this.updateAcl }); } - if (permissions.indexOf('premove') != -1) { + if (permissions.indexOf('premove') !== -1) { if (menu.length > 0) { menu.push('-'); } menu.push({ text: _('access_category_remove'), - handler: this.remove.createDelegate(this,['confirm_remove','Security/Access/UserGroup/Category/Remove']) + handler: this.remove.createDelegate(this, ['confirm_remove', 'Security/Access/UserGroup/Category/Remove']) }); } } @@ -195,48 +195,54 @@ Ext.extend(MODx.grid.UserGroupCategory,MODx.grid.Grid,{ if (menu.length > 0) { this.addContextMenuItem(menu); } - } + }, - ,createAcl: function(itm,e) { - var r = { + createAcl: function(itm, e) { + const record = { principal: this.config.usergroup }; if (!this.windows.createAcl) { this.windows.createAcl = MODx.load({ - xtype: 'modx-window-user-group-category-create' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('createAcl',r); - },scope:this} + xtype: 'modx-window-user-group-category-create', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('createAcl', response); + }, + scope: this + } } }); } - this.windows.createAcl.setValues(r); + this.windows.createAcl.setValues(record); this.windows.createAcl.show(e.target); - } + }, - ,updateAcl: function(itm,e) { - var r = this.menu.record; + updateAcl: function(itm, e) { + const { record } = this.menu; if (!this.windows.updateAcl) { this.windows.updateAcl = MODx.load({ - xtype: 'modx-window-user-group-category-update' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('updateAcl',r); - },scope:this} + xtype: 'modx-window-user-group-category-update', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('updateAcl', response); + }, + scope: this + } } }); } - this.windows.updateAcl.setValues(r); + this.windows.updateAcl.setValues(record); this.windows.updateAcl.show(e.target); } }); -Ext.reg('modx-grid-user-group-category',MODx.grid.UserGroupCategory); +Ext.reg('modx-grid-user-group-category', MODx.grid.UserGroupCategory); /** * @class MODx.window.CreateUGCat @@ -245,128 +251,136 @@ Ext.reg('modx-grid-user-group-category',MODx.grid.UserGroupCategory); * @xtype modx-window-user-group-category-create */ MODx.window.CreateUGCat = function(config = {}) { - this.ident = config.ident || 'cugcat'+Ext.id(); - Ext.applyIf(config,{ - title: _('category_add') - ,url: MODx.config.connector_url - ,action: 'Security/Access/UserGroup/Category/Create' - ,fields: [{ - xtype: 'hidden' - ,name: 'id' - },{ - xtype: 'hidden' - ,name: 'principal' - ,hiddenName: 'principal' - },{ - xtype: 'hidden' - ,name: 'principal_class' - ,value: 'MODX\\Revolution\\modUserGroup' - },{ - xtype: 'modx-combo-category' - ,fieldLabel: _('category') - ,description: MODx.expandHelp ? '' : _('user_group_category_category_desc') - ,id: 'modx-'+this.ident+'-category' - ,name: 'target' - ,hiddenName: 'target' - ,editable: false - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-category' - ,html: _('user_group_category_category_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-context' - ,fieldLabel: _('context') - ,description: MODx.expandHelp ? '' : _('user_group_category_context_desc') - ,id: 'modx-'+this.ident+'-context' - ,name: 'context_key' - ,hiddenName: 'context_key' - ,editable: false - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-context' - ,html: _('user_group_category_context_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-authority' - ,fieldLabel: _('minimum_role') - ,description: MODx.expandHelp ? '' : _('user_group_category_policy_desc') - ,id: 'modx-'+this.ident+'-authority' - ,name: 'authority' - ,value: 0 - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-authority' - ,html: _('user_group_category_authority_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-policy' - ,fieldLabel: _('policy') - ,description: MODx.expandHelp ? '' : _('user_group_category_policy_desc') - ,id: 'modx-'+this.ident+'-policy' - ,name: 'policy' - ,hiddenName: 'policy' - ,baseParams: { - action: 'Security/Access/Policy/GetList' - ,group: 'Element,Object' - ,combo: true - } - ,anchor: '100%' - ,listeners: { - 'select':{fn:this.onPolicySelect,scope:this} + this.ident = config.ident || `cugcat${Ext.id()}`; + Ext.applyIf(config, { + title: _('category_add'), + url: MODx.config.connector_url, + action: 'Security/Access/UserGroup/Category/Create', + fields: [{ + xtype: 'hidden', + name: 'id' + }, { + xtype: 'hidden', + name: 'principal', + hiddenName: 'principal' + }, { + xtype: 'hidden', + name: 'principal_class', + value: 'MODX\\Revolution\\modUserGroup' + }, { + xtype: 'modx-combo-category', + fieldLabel: _('category'), + description: MODx.expandHelp ? '' : _('user_group_category_category_desc'), + id: `modx-${this.ident}-category`, + name: 'target', + hiddenName: 'target', + editable: false, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-category`, + html: _('user_group_category_category_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-context', + fieldLabel: _('context'), + description: MODx.expandHelp ? '' : _('user_group_category_context_desc'), + id: `modx-${this.ident}-context`, + name: 'context_key', + hiddenName: 'context_key', + editable: false, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-context`, + html: _('user_group_category_context_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-authority', + fieldLabel: _('minimum_role'), + description: MODx.expandHelp ? '' : _('user_group_category_policy_desc'), + id: `modx-${this.ident}-authority`, + name: 'authority', + value: 0, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-authority`, + html: _('user_group_category_authority_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-policy', + fieldLabel: _('policy'), + description: MODx.expandHelp ? '' : _('user_group_category_policy_desc'), + id: `modx-${this.ident}-policy`, + name: 'policy', + hiddenName: 'policy', + baseParams: { + action: 'Security/Access/Policy/GetList', + group: 'Element,Object', + combo: true + }, + anchor: '100%', + listeners: { + select: { + fn: this.onPolicySelect, + scope: this + } } - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-policy' - ,html: _('user_group_category_policy_desc') - ,cls: 'desc-under' - },{ - id: 'modx-'+this.ident+'-permissions-list-ct' - ,cls: 'modx-permissions-list' - ,defaults: {border: false} - ,autoHeight: true - ,hidden: true - ,anchor: '100%' - ,items: [{ - html: '

'+_('permissions_in_policy')+'

' - ,id: 'modx-'+this.ident+'-permissions-list-header' - },{ - id: 'modx-'+this.ident+'-permissions-list' - ,cls: 'modx-permissions-list-textarea' - ,xtype: 'textarea' - ,name: 'permissions' - ,grow: false - ,anchor: '100%' - ,height: 100 - ,width: '97%' - ,readOnly: true + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-policy`, + html: _('user_group_category_policy_desc'), + cls: 'desc-under' + }, { + id: `modx-${this.ident}-permissions-list-ct`, + cls: 'modx-permissions-list', + defaults: { border: false }, + autoHeight: true, + hidden: true, + anchor: '100%', + items: [{ + html: `

${_('permissions_in_policy')}

`, + id: `modx-${this.ident}-permissions-list-header` + }, { + id: `modx-${this.ident}-permissions-list`, + cls: 'modx-permissions-list-textarea', + xtype: 'textarea', + name: 'permissions', + grow: false, + anchor: '100%', + height: 100, + width: '97%', + readOnly: true }] }] }); - MODx.window.CreateUGCat.superclass.constructor.call(this,config); + MODx.window.CreateUGCat.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.CreateUGCat,MODx.Window,{ - onPolicySelect: function(cb,rec,idx) { - var s = cb.getStore(); - if (!s) return; - - var r = s.getAt(idx); - var lc = Ext.getCmp('modx-'+this.ident+'-permissions-list-ct'); - if (r && idx>0) { - lc.show(); - var pl = Ext.getCmp('modx-'+this.ident+'-permissions-list'); - var o = rec.data.permissions.join(', '); - pl.setValue(o); +Ext.extend(MODx.window.CreateUGCat, MODx.Window, { + onPolicySelect: function(cb, rec, idx) { + const store = cb.getStore(); + if (!store) { + return; + } + const + record = store.getAt(idx), + listContainer = Ext.getCmp(`modx-${this.ident}-permissions-list-ct`) + ; + if (record && idx > 0) { + listContainer.show(); + const + listCmp = Ext.getCmp(`modx-${this.ident}-permissions-list`), + list = rec.data.permissions.join(', ') + ; + listCmp.setValue(list); } else { - lc.hide(); + listContainer.hide(); } this.doLayout(); } }); -Ext.reg('modx-window-user-group-category-create',MODx.window.CreateUGCat); +Ext.reg('modx-window-user-group-category-create', MODx.window.CreateUGCat); /** * @class MODx.window.UpdateUGCat @@ -375,12 +389,12 @@ Ext.reg('modx-window-user-group-category-create',MODx.window.CreateUGCat); * @xtype modx-window-user-group-category-update */ MODx.window.UpdateUGCat = function(config = {}) { - this.ident = config.ident || 'updugcat'+Ext.id(); - Ext.applyIf(config,{ - title: _('access_category_update') - ,action: 'Security/Access/UserGroup/Category/Update' + this.ident = config.ident || `updugcat${Ext.id()}`; + Ext.applyIf(config, { + title: _('access_category_update'), + action: 'Security/Access/UserGroup/Category/Update' }); - MODx.window.UpdateUGCat.superclass.constructor.call(this,config); + MODx.window.UpdateUGCat.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.UpdateUGCat,MODx.window.CreateUGCat); -Ext.reg('modx-window-user-group-category-update',MODx.window.UpdateUGCat); +Ext.extend(MODx.window.UpdateUGCat, MODx.window.CreateUGCat); +Ext.reg('modx-window-user-group-category-update', MODx.window.UpdateUGCat); diff --git a/manager/assets/modext/widgets/security/modx.grid.user.group.context.js b/manager/assets/modext/widgets/security/modx.grid.user.group.context.js index 8c55f9e27f0..95edd465b8b 100644 --- a/manager/assets/modext/widgets/security/modx.grid.user.group.context.js +++ b/manager/assets/modext/widgets/security/modx.grid.user.group.context.js @@ -10,17 +10,17 @@ MODx.grid.UserGroupContext = function(config = {}) { lazyRender: false, enableCaching: false }); - Ext.applyIf(config,{ - id: 'modx-grid-user-group-contexts' - ,url: MODx.config.connector_url - ,baseParams: { - action: 'Security/Access/UserGroup/Context/GetList' - ,usergroup: config.usergroup - ,context: MODx.request.context || null - ,policy: this.applyRequestFilter(0) - ,isGroupingGrid: true - } - ,fields: [ + Ext.applyIf(config, { + id: 'modx-grid-user-group-contexts', + url: MODx.config.connector_url, + baseParams: { + action: 'Security/Access/UserGroup/Context/GetList', + usergroup: config.usergroup, + context: MODx.request.context || null, + policy: this.applyRequestFilter(0), + isGroupingGrid: true + }, + fields: [ 'id', 'target', 'principal', @@ -30,66 +30,66 @@ MODx.grid.UserGroupContext = function(config = {}) { 'policy_name', 'permissions', 'cls' - ] - ,grouping: true - ,groupBy: 'role_display' - ,remoteGroup: true - ,sortBy: 'target' - ,remoteSort: true - ,paging: true - ,hideMode: 'offsets' - ,singleText: _('policy') - ,pluralText: _('policies') - ,plugins: [this.exp] - ,columns: [ + ], + grouping: true, + groupBy: 'role_display', + remoteGroup: true, + sortBy: 'target', + remoteSort: true, + paging: true, + hideMode: 'offsets', + singleText: _('policy'), + pluralText: _('policies'), + plugins: [this.exp], + columns: [ this.exp, { - header: _('context') - ,dataIndex: 'target' - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('context/update', 'target', { - linkParams: [{ key: 'key', valueIndex: 'target'}] + header: _('context'), + dataIndex: 'target', + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('context/update', 'target', { + linkParams: [{ key: 'key', valueIndex: 'target' }] }) - },{ - header: _('minimum_role') - ,dataIndex: 'role_display' - ,width: 100 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/permission', 'role_display') - },{ - header: _('policy') - ,dataIndex: 'policy_name' - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { - linkParams: [{ key: 'id', valueIndex: 'policy'}] + }, { + header: _('minimum_role'), + dataIndex: 'role_display', + width: 100, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/permission', 'role_display') + }, { + header: _('policy'), + dataIndex: 'policy_name', + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { + linkParams: [{ key: 'id', valueIndex: 'policy' }] }) } - ] - ,tbar: [ + ], + tbar: [ { - text: _('context_add') - ,cls: 'primary-button' - ,scope: this - ,handler: this.createAcl + text: _('context_add'), + cls: 'primary-button', + scope: this, + handler: this.createAcl }, '->', { - xtype: 'modx-combo-context' - ,itemId: 'filter-context' - ,emptyText: _('filter_by_context') - ,width: 180 - ,allowBlank: true - ,value: MODx.request.context || null - ,baseParams: { + xtype: 'modx-combo-context', + itemId: 'filter-context', + emptyText: _('filter_by_context'), + width: 180, + allowBlank: true, + value: MODx.request.context || null, + baseParams: { action: 'Context/GetList', isGridFilter: true, targetGrid: 'MODx.grid.UserGroupContext', usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-policy-context', 'context', record.data.key); @@ -98,21 +98,21 @@ MODx.grid.UserGroupContext = function(config = {}) { scope: this } } - },{ - xtype: 'modx-combo-policy' - ,itemId: 'filter-policy-context' - ,emptyText: _('filter_by_policy') - ,width: 180 - ,allowBlank: true - ,value: this.applyRequestFilter(0) - ,baseParams: { + }, { + xtype: 'modx-combo-policy', + itemId: 'filter-policy-context', + emptyText: _('filter_by_policy'), + width: 180, + allowBlank: true, + value: this.applyRequestFilter(0), + baseParams: { action: 'Security/Access/Policy/GetList', group: 'Administrator,Context,Object', isGridFilter: true, targetGrid: 'MODx.grid.UserGroupContext', usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-context', 'policy', record.data.id); @@ -128,9 +128,9 @@ MODx.grid.UserGroupContext = function(config = {}) { ) ] }); - MODx.grid.UserGroupContext.superclass.constructor.call(this,config); + MODx.grid.UserGroupContext.superclass.constructor.call(this, config); - this.addEvents('createAcl','updateAcl'); + this.addEvents('createAcl', 'updateAcl'); const gridFilterData = [ { filterId: 'filter-policy-context', dependentParams: ['context'] }, @@ -139,12 +139,12 @@ MODx.grid.UserGroupContext = function(config = {}) { this.on({ createAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, updateAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, @@ -153,12 +153,12 @@ MODx.grid.UserGroupContext = function(config = {}) { } }); }; -Ext.extend(MODx.grid.UserGroupContext,MODx.grid.Grid,{ +Ext.extend(MODx.grid.UserGroupContext, MODx.grid.Grid, { - combos: {} - ,windows: {} + combos: {}, + windows: {}, - ,getMenu: function() { + getMenu: function() { const record = this.getSelectionModel().getSelected(), permissions = record.data.cls, menu = [] @@ -167,19 +167,19 @@ Ext.extend(MODx.grid.UserGroupContext,MODx.grid.Grid,{ if (this.getSelectionModel().getCount() > 1) { // Currently not allowing bulk actions for this grid } else { - if (permissions.indexOf('pedit') != -1) { + if (permissions.indexOf('pedit') !== -1) { menu.push({ text: _('access_context_update'), handler: this.updateAcl }); } - if (permissions.indexOf('premove') != -1) { + if (permissions.indexOf('premove') !== -1) { if (menu.length > 0) { menu.push('-'); } menu.push({ text: _('access_context_remove'), - handler: this.remove.createDelegate(this,['confirm_remove','Security/Access/UserGroup/Context/Remove']) + handler: this.remove.createDelegate(this, ['confirm_remove', 'Security/Access/UserGroup/Context/Remove']) }); } } @@ -187,49 +187,55 @@ Ext.extend(MODx.grid.UserGroupContext,MODx.grid.Grid,{ if (menu.length > 0) { this.addContextMenuItem(menu); } - } + }, - ,createAcl: function(itm,e) { - var r = { + createAcl: function(itm, e) { + const record = { principal: this.config.usergroup }; if (!this.windows.createAcl) { this.windows.createAcl = MODx.load({ - xtype: 'modx-window-user-group-context-create' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('createAcl',r); - },scope:this} + xtype: 'modx-window-user-group-context-create', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('createAcl', response); + }, + scope: this + } } }); } - this.windows.createAcl.setValues(r); + this.windows.createAcl.setValues(record); this.windows.createAcl.show(e.target); - } + }, - ,updateAcl: function(itm,e) { - var r = this.menu.record; + updateAcl: function(itm, e) { + const { record } = this.menu; if (!this.windows.updateAcl) { this.windows.updateAcl = MODx.load({ - xtype: 'modx-window-user-group-context-update' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('updateAcl',r); - },scope:this} + xtype: 'modx-window-user-group-context-update', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('updateAcl', response); + }, + scope: this + } } }); } - this.windows.updateAcl.setValues(r); + this.windows.updateAcl.setValues(record); this.windows.updateAcl.show(e.target); } }); -Ext.reg('modx-grid-user-group-context',MODx.grid.UserGroupContext); +Ext.reg('modx-grid-user-group-context', MODx.grid.UserGroupContext); /** * @class MODx.window.CreateUGAccessContext @@ -237,116 +243,120 @@ Ext.reg('modx-grid-user-group-context',MODx.grid.UserGroupContext); * @param {Object} config An object of options. * @xtype modx-window-user-group-context-create */ -MODx.window.CreateUGAccessContext = function(config) { - config = config || {}; - this.ident = config.ident || 'cugactx'+Ext.id(); - Ext.applyIf(config,{ - title: _('ugc_mutate') - ,url: MODx.config.connector_url - ,action: 'Security/Access/UserGroup/Context/Create' - ,fields: [{ - xtype: 'hidden' - ,name: 'id' - },{ - xtype: 'modx-combo-context' - ,fieldLabel: _('context') - ,description: MODx.expandHelp ? '' : _('user_group_context_context_desc') - ,id: 'modx-'+this.ident+'-context' - ,name: 'target' - ,hiddenName: 'target' - ,editable: false - ,allowBlank: false - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-context' - ,html: _('user_group_context_context_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-authority' - ,fieldLabel: _('minimum_role') - ,description: MODx.expandHelp ? '' : _('user_group_context_authority_desc') - ,id: 'modx-'+this.ident+'-authority' - ,name: 'authority' - ,value: 0 - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-authority' - ,html: _('user_group_context_authority_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-policy' - ,fieldLabel: _('policy') - ,description: MODx.expandHelp ? '' : _('user_group_context_policy_desc') - ,id: 'modx-'+this.ident+'-policy' - ,name: 'policy' - ,hiddenName: 'policy' - ,baseParams: { - action: 'Security/Access/Policy/GetList' - ,group: 'Administrator,Context,Object' - ,combo: true - } - ,allowBlank: false - ,anchor: '100%' - ,listeners: { +MODx.window.CreateUGAccessContext = function(config = {}) { + this.ident = config.ident || `cugactx${Ext.id()}`; + Ext.applyIf(config, { + title: _('ugc_mutate'), + url: MODx.config.connector_url, + action: 'Security/Access/UserGroup/Context/Create', + fields: [{ + xtype: 'hidden', + name: 'id' + }, { + xtype: 'modx-combo-context', + fieldLabel: _('context'), + description: MODx.expandHelp ? '' : _('user_group_context_context_desc'), + id: `modx-${this.ident}-context`, + name: 'target', + hiddenName: 'target', + editable: false, + allowBlank: false, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-context`, + html: _('user_group_context_context_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-authority', + fieldLabel: _('minimum_role'), + description: MODx.expandHelp ? '' : _('user_group_context_authority_desc'), + id: `modx-${this.ident}-authority`, + name: 'authority', + value: 0, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-authority`, + html: _('user_group_context_authority_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-policy', + fieldLabel: _('policy'), + description: MODx.expandHelp ? '' : _('user_group_context_policy_desc'), + id: `modx-${this.ident}-policy`, + name: 'policy', + hiddenName: 'policy', + baseParams: { + action: 'Security/Access/Policy/GetList', + group: 'Administrator,Context,Object', + combo: true + }, + allowBlank: false, + anchor: '100%', + listeners: { select: { fn: this.onPolicySelect, scope: this } } - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-policy' - ,html: _('user_group_context_policy_desc') - ,cls: 'desc-under' - },{ - xtype: 'hidden' - ,name: 'principal' - ,hiddenName: 'principal' - },{ - id: 'modx-'+this.ident+'-permissions-list-ct' - ,cls: 'modx-permissions-list' - ,defaults: {border: false} - ,autoHeight: true - ,hidden: true - ,anchor: '100%' - ,items: [{ - html: '

'+_('permissions_in_policy')+'

' - ,id: 'modx-'+this.ident+'-permissions-list-header' - },{ - id: 'modx-'+this.ident+'-permissions-list' - ,cls: 'modx-permissions-list-textarea' - ,xtype: 'textarea' - ,grow: false - ,anchor: '100%' - ,height: 150 - ,width: '97%' - ,readOnly: true + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-policy`, + html: _('user_group_context_policy_desc'), + cls: 'desc-under' + }, { + xtype: 'hidden', + name: 'principal', + hiddenName: 'principal' + }, { + id: `modx-${this.ident}-permissions-list-ct`, + cls: 'modx-permissions-list', + defaults: { border: false }, + autoHeight: true, + hidden: true, + anchor: '100%', + items: [{ + html: `

${_('permissions_in_policy')}

`, + id: `modx-${this.ident}-permissions-list-header` + }, { + id: `modx-${this.ident}-permissions-list`, + cls: 'modx-permissions-list-textarea', + xtype: 'textarea', + grow: false, + anchor: '100%', + height: 150, + width: '97%', + readOnly: true }] }] }); - MODx.window.CreateUGAccessContext.superclass.constructor.call(this,config); + MODx.window.CreateUGAccessContext.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.CreateUGAccessContext,MODx.Window,{ - onPolicySelect: function(cb,rec,idx) { - var s = cb.getStore(); - if (!s) return; - - var r = s.getAt(idx); - var lc = Ext.getCmp('modx-'+this.ident+'-permissions-list-ct'); - if (r && idx>0) { - lc.show(); - var pl = Ext.getCmp('modx-'+this.ident+'-permissions-list'); - var o = rec.data.permissions.join(', '); - pl.setValue(o); +Ext.extend(MODx.window.CreateUGAccessContext, MODx.Window, { + onPolicySelect: function(cb, rec, idx) { + const store = cb.getStore(); + if (!store) { + return; + } + const + record = store.getAt(idx), + listContainer = Ext.getCmp(`modx-${this.ident}-permissions-list-ct`) + ; + if (record && idx > 0) { + listContainer.show(); + const + listCmp = Ext.getCmp(`modx-${this.ident}-permissions-list`), + list = rec.data.permissions.join(', ') + ; + listCmp.setValue(list); } else { - lc.hide(); + listContainer.hide(); } this.doLayout(); } }); -Ext.reg('modx-window-user-group-context-create',MODx.window.CreateUGAccessContext); +Ext.reg('modx-window-user-group-context-create', MODx.window.CreateUGAccessContext); /** * @class MODx.window.UpdateUGAccessContext @@ -354,14 +364,13 @@ Ext.reg('modx-window-user-group-context-create',MODx.window.CreateUGAccessContex * @param {Object} config An object of options. * @xtype modx-window-user-group-context-update */ -MODx.window.UpdateUGAccessContext = function(config) { - config = config || {}; - this.ident = config.ident || 'uugactx'+Ext.id(); - Ext.applyIf(config,{ - title: _('ugc_mutate') - ,action: 'Security/Access/UserGroup/Context/Update' +MODx.window.UpdateUGAccessContext = function(config = {}) { + this.ident = config.ident || `uugactx${Ext.id()}`; + Ext.applyIf(config, { + title: _('ugc_mutate'), + action: 'Security/Access/UserGroup/Context/Update' }); - MODx.window.UpdateUGAccessContext.superclass.constructor.call(this,config); + MODx.window.UpdateUGAccessContext.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.UpdateUGAccessContext,MODx.window.CreateUGAccessContext); -Ext.reg('modx-window-user-group-context-update',MODx.window.UpdateUGAccessContext); +Ext.extend(MODx.window.UpdateUGAccessContext, MODx.window.CreateUGAccessContext); +Ext.reg('modx-window-user-group-context-update', MODx.window.UpdateUGAccessContext); diff --git a/manager/assets/modext/widgets/security/modx.grid.user.group.namespace.js b/manager/assets/modext/widgets/security/modx.grid.user.group.namespace.js index 0a3a8a64456..2ade935728c 100644 --- a/manager/assets/modext/widgets/security/modx.grid.user.group.namespace.js +++ b/manager/assets/modext/widgets/security/modx.grid.user.group.namespace.js @@ -10,17 +10,17 @@ MODx.grid.UserGroupNamespace = function(config = {}) { lazyRender: false, enableCaching: false }); - Ext.applyIf(config,{ - id: 'modx-grid-user-group-namespace' - ,url: MODx.config.connector_url - ,baseParams: { - action: 'Security/Access/UserGroup/AccessNamespace/GetList' - ,usergroup: config.usergroup - ,namespace: this.applyRequestFilter(4, 'ns') - ,policy: this.applyRequestFilter(4) - ,isGroupingGrid: true - } - ,fields: [ + Ext.applyIf(config, { + id: 'modx-grid-user-group-namespace', + url: MODx.config.connector_url, + baseParams: { + action: 'Security/Access/UserGroup/AccessNamespace/GetList', + usergroup: config.usergroup, + namespace: this.applyRequestFilter(4, 'ns'), + policy: this.applyRequestFilter(4), + isGroupingGrid: true + }, + fields: [ 'id', 'target', 'name', @@ -32,67 +32,67 @@ MODx.grid.UserGroupNamespace = function(config = {}) { 'context_key', 'permissions', 'cls' - ] - ,grouping: true - ,groupBy: 'role_display' - ,remoteGroup: true - ,sortBy: 'name' - ,remoteSort: true - ,paging: true - ,hideMode: 'offsets' - ,singleText: _('policy') - ,pluralText: _('policies') - ,plugins: [this.exp] - ,columns: [ + ], + grouping: true, + groupBy: 'role_display', + remoteGroup: true, + sortBy: 'name', + remoteSort: true, + paging: true, + hideMode: 'offsets', + singleText: _('policy'), + pluralText: _('policies'), + plugins: [this.exp], + columns: [ this.exp, { - header: _('namespace') - ,dataIndex: 'name' - ,width: 120 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('workspaces/namespace', 'name') - },{ - header: _('minimum_role') - ,dataIndex: 'role_display' - ,width: 100 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/permission', 'role_display') - },{ - header: _('policy') - ,dataIndex: 'policy_name' - ,width: 200 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { + header: _('namespace'), + dataIndex: 'name', + width: 120, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('workspaces/namespace', 'name') + }, { + header: _('minimum_role'), + dataIndex: 'role_display', + width: 100, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/permission', 'role_display') + }, { + header: _('policy'), + dataIndex: 'policy_name', + width: 200, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { linkParams: [{ key: 'id', valueIndex: 'policy' }] }) } - ] - ,tbar: [ + ], + tbar: [ { - text: _('namespace_add') - ,cls: 'primary-button' - ,scope: this - ,handler: this.createAcl + text: _('namespace_add'), + cls: 'primary-button', + scope: this, + handler: this.createAcl }, '->', { - xtype: 'modx-combo-namespace' - ,itemId: 'filter-namespace' - ,emptyText: _('filter_by_namespace') - ,editable: false - ,width: 200 - ,allowBlank: true - ,value: this.applyRequestFilter(4, 'ns') - ,baseParams: { + xtype: 'modx-combo-namespace', + itemId: 'filter-namespace', + emptyText: _('filter_by_namespace'), + editable: false, + width: 200, + allowBlank: true, + value: this.applyRequestFilter(4, 'ns'), + baseParams: { action: 'Workspace/PackageNamespace/GetList', isGridFilter: true, targetGrid: 'MODx.grid.UserGroupNamespace', usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-policy-namespace', 'namespace', record.data.name); @@ -106,21 +106,21 @@ MODx.grid.UserGroupNamespace = function(config = {}) { scope: this } } - },{ - xtype: 'modx-combo-policy' - ,itemId: 'filter-policy-namespace' - ,emptyText: _('filter_by_policy') - ,width: 180 - ,allowBlank: true - ,value: this.applyRequestFilter(4) - ,baseParams: { + }, { + xtype: 'modx-combo-policy', + itemId: 'filter-policy-namespace', + emptyText: _('filter_by_policy'), + width: 180, + allowBlank: true, + value: this.applyRequestFilter(4), + baseParams: { action: 'Security/Access/Policy/GetList', group: 'Namespace', isGridFilter: true, targetGrid: 'MODx.grid.UserGroupNamespace', usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-namespace', 'policy', record.data.id); @@ -136,9 +136,9 @@ MODx.grid.UserGroupNamespace = function(config = {}) { ) ] }); - MODx.grid.UserGroupNamespace.superclass.constructor.call(this,config); + MODx.grid.UserGroupNamespace.superclass.constructor.call(this, config); - this.addEvents('createAcl','updateAcl'); + this.addEvents('createAcl', 'updateAcl'); const gridFilterData = [ { filterId: 'filter-policy-namespace', dependentParams: ['namespace'] }, @@ -147,12 +147,12 @@ MODx.grid.UserGroupNamespace = function(config = {}) { this.on({ createAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, updateAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, @@ -161,11 +161,11 @@ MODx.grid.UserGroupNamespace = function(config = {}) { } }); }; -Ext.extend(MODx.grid.UserGroupNamespace,MODx.grid.Grid,{ - combos: {} - ,windows: {} +Ext.extend(MODx.grid.UserGroupNamespace, MODx.grid.Grid, { + combos: {}, + windows: {}, - ,getMenu: function() { + getMenu: function() { const record = this.getSelectionModel().getSelected(), permissions = record.data.cls, menu = [] @@ -174,19 +174,19 @@ Ext.extend(MODx.grid.UserGroupNamespace,MODx.grid.Grid,{ if (this.getSelectionModel().getCount() > 1) { // Currently not allowing bulk actions for this grid } else { - if (permissions.indexOf('pedit') != -1) { + if (permissions.indexOf('pedit') !== -1) { menu.push({ text: _('access_namespace_update'), handler: this.updateAcl }); } - if (permissions.indexOf('premove') != -1) { + if (permissions.indexOf('premove') !== -1) { if (menu.length > 0) { menu.push('-'); } menu.push({ text: _('access_namespace_remove'), - handler: this.remove.createDelegate(this,['confirm_remove','Security/Access/UserGroup/AccessNamespace/Remove']) + handler: this.remove.createDelegate(this, ['confirm_remove', 'Security/Access/UserGroup/AccessNamespace/Remove']) }); } } @@ -194,48 +194,54 @@ Ext.extend(MODx.grid.UserGroupNamespace,MODx.grid.Grid,{ if (menu.length > 0) { this.addContextMenuItem(menu); } - } + }, - ,createAcl: function(itm,e) { - var r = { + createAcl: function(itm, e) { + const record = { principal: this.config.usergroup }; if (!this.windows.createAcl) { this.windows.createAcl = MODx.load({ - xtype: 'modx-window-user-group-namespace-create' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('createAcl',r); - },scope:this} + xtype: 'modx-window-user-group-namespace-create', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('createAcl', response); + }, + scope: this + } } }); } - this.windows.createAcl.setValues(r); + this.windows.createAcl.setValues(record); this.windows.createAcl.show(e.target); - } + }, - ,updateAcl: function(itm,e) { - var r = this.menu.record; + updateAcl: function(itm, e) { + const { record } = this.menu; if (!this.windows.updateAcl) { this.windows.updateAcl = MODx.load({ - xtype: 'modx-window-user-group-namespace-update' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('updateAcl',r); - },scope:this} + xtype: 'modx-window-user-group-namespace-update', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('updateAcl', response); + }, + scope: this + } } }); } - this.windows.updateAcl.setValues(r); + this.windows.updateAcl.setValues(record); this.windows.updateAcl.show(e.target); } }); -Ext.reg('modx-grid-user-group-namespace',MODx.grid.UserGroupNamespace); +Ext.reg('modx-grid-user-group-namespace', MODx.grid.UserGroupNamespace); /** * @class MODx.window.CreateUGNamespace @@ -243,120 +249,127 @@ Ext.reg('modx-grid-user-group-namespace',MODx.grid.UserGroupNamespace); * @param {Object} config An object of options. * @xtype modx-window-user-group-namespace-create */ -MODx.window.CreateUGNamespace = function(config) { - config = config || {}; - this.ident = config.ident || 'cugnamespace'+Ext.id(); - Ext.applyIf(config,{ - title: _('namespace_add') - ,url: MODx.config.connector_url - ,action: 'Security/Access/UserGroup/AccessNamespace/Create' - ,fields: [{ - xtype: 'hidden' - ,name: 'id' - },{ - xtype: 'hidden' - ,name: 'principal' - ,hiddenName: 'principal' - },{ - xtype: 'hidden' - ,name: 'principal_class' - ,value: 'MODX\\Revolution\\modUserGroup' - },{ - xtype: 'hidden' - ,name: 'context_key' - ,hiddenName: 'context_key' - ,value: 'mgr' - },{ - xtype: 'modx-combo-namespace' - ,fieldLabel: _('namespace') - ,description: MODx.expandHelp ? '' : _('user_group_source_source_desc') - ,id: 'modx-'+this.ident+'-namespace' - ,name: 'target' - ,hiddenName: 'target' - ,editable: false - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-source' - ,html: _('user_group_source_source_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-authority' - ,fieldLabel: _('minimum_role') - ,description: MODx.expandHelp ? '' : _('user_group_source_authority_desc') - ,id: 'modx-'+this.ident+'-authority' - ,name: 'authority' - ,value: 0 - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-authority' - ,html: _('user_group_source_authority_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-policy' - ,fieldLabel: _('policy') - ,description: MODx.expandHelp ? '' : _('user_group_source_policy_desc') - ,id: 'modx-'+this.ident+'-policy' - ,name: 'policy' - ,hiddenName: 'policy' - ,baseParams: { - action: 'Security/Access/Policy/GetList' - ,group: 'Namespace' - } - ,anchor: '100%' - ,listeners: { - 'select':{fn:this.onPolicySelect,scope:this} +MODx.window.CreateUGNamespace = function(config = {}) { + this.ident = config.ident || `cugnamespace${Ext.id()}`; + Ext.applyIf(config, { + title: _('namespace_add'), + url: MODx.config.connector_url, + action: 'Security/Access/UserGroup/AccessNamespace/Create', + fields: [{ + xtype: 'hidden', + name: 'id' + }, { + xtype: 'hidden', + name: 'principal', + hiddenName: 'principal' + }, { + xtype: 'hidden', + name: 'principal_class', + value: 'MODX\\Revolution\\modUserGroup' + }, { + xtype: 'hidden', + name: 'context_key', + hiddenName: 'context_key', + value: 'mgr' + }, { + xtype: 'modx-combo-namespace', + fieldLabel: _('namespace'), + description: MODx.expandHelp ? '' : _('user_group_source_source_desc'), + id: `modx-${this.ident}-namespace`, + name: 'target', + hiddenName: 'target', + editable: false, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-source`, + html: _('user_group_source_source_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-authority', + fieldLabel: _('minimum_role'), + description: MODx.expandHelp ? '' : _('user_group_source_authority_desc'), + id: `modx-${this.ident}-authority`, + name: 'authority', + value: 0, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-authority`, + html: _('user_group_source_authority_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-policy', + fieldLabel: _('policy'), + description: MODx.expandHelp ? '' : _('user_group_source_policy_desc'), + id: `modx-${this.ident}-policy`, + name: 'policy', + hiddenName: 'policy', + baseParams: { + action: 'Security/Access/Policy/GetList', + group: 'Namespace' + }, + anchor: '100%', + listeners: { + select: { + fn: this.onPolicySelect, + scope: this + } } - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-policy' - ,html: _('user_group_source_policy_desc') - ,cls: 'desc-under' - },{ - id: 'modx-'+this.ident+'-permissions-list-ct' - ,cls: 'modx-permissions-list' - ,defaults: {border: false} - ,autoHeight: true - ,hidden: true - ,anchor: '100%' - ,items: [{ - html: '

'+_('permissions_in_policy')+'

' - ,id: 'modx-'+this.ident+'-permissions-list-header' - },{ - id: 'modx-'+this.ident+'-permissions-list' - ,cls: 'modx-permissions-list-textarea' - ,xtype: 'textarea' - ,name: 'permissions' - ,grow: false - ,anchor: '100%' - ,height: 100 - ,width: '97%' - ,readOnly: true + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-policy`, + html: _('user_group_source_policy_desc'), + cls: 'desc-under' + }, { + id: `modx-${this.ident}-permissions-list-ct`, + cls: 'modx-permissions-list', + defaults: { border: false }, + autoHeight: true, + hidden: true, + anchor: '100%', + items: [{ + html: `

${_('permissions_in_policy')}

`, + id: `modx-${this.ident}-permissions-list-header` + }, { + id: `modx-${this.ident}-permissions-list`, + cls: 'modx-permissions-list-textarea', + xtype: 'textarea', + name: 'permissions', + grow: false, + anchor: '100%', + height: 100, + width: '97%', + readOnly: true }] }] }); - MODx.window.CreateUGNamespace.superclass.constructor.call(this,config); + MODx.window.CreateUGNamespace.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.CreateUGNamespace,MODx.Window,{ - onPolicySelect: function(cb,rec,idx) { - var s = cb.getStore(); - if (!s) return; - - var r = s.getAt(idx); - var lc = Ext.getCmp('modx-'+this.ident+'-permissions-list-ct'); - if (r && idx>0) { - lc.show(); - var pl = Ext.getCmp('modx-'+this.ident+'-permissions-list'); - var o = rec.data.permissions.join(', '); - pl.setValue(o); +Ext.extend(MODx.window.CreateUGNamespace, MODx.Window, { + onPolicySelect: function(cb, rec, idx) { + const store = cb.getStore(); + if (!store) { + return; + } + const + record = store.getAt(idx), + listContainer = Ext.getCmp(`modx-${this.ident}-permissions-list-ct`) + ; + if (record && idx > 0) { + listContainer.show(); + const + listCmp = Ext.getCmp(`modx-${this.ident}-permissions-list`), + list = rec.data.permissions.join(', ') + ; + listCmp.setValue(list); } else { - lc.hide(); + listContainer.hide(); } this.doLayout(); } }); -Ext.reg('modx-window-user-group-namespace-create',MODx.window.CreateUGNamespace); +Ext.reg('modx-window-user-group-namespace-create', MODx.window.CreateUGNamespace); /** * @class MODx.window.UpdateUGNamespace @@ -364,14 +377,13 @@ Ext.reg('modx-window-user-group-namespace-create',MODx.window.CreateUGNamespace) * @param {Object} config An object of options. * @xtype modx-window-user-group-namespace-update */ -MODx.window.UpdateUGNamespace = function(config) { - config = config || {}; - this.ident = config.ident || 'updugsrc'+Ext.id(); - Ext.applyIf(config,{ - title: _('access_namespace_update') - ,action: 'Security/Access/UserGroup/AccessNamespace/Update' +MODx.window.UpdateUGNamespace = function(config = {}) { + this.ident = config.ident || `updugsrc${Ext.id()}`; + Ext.applyIf(config, { + title: _('access_namespace_update'), + action: 'Security/Access/UserGroup/AccessNamespace/Update' }); - MODx.window.UpdateUGNamespace.superclass.constructor.call(this,config); + MODx.window.UpdateUGNamespace.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.UpdateUGNamespace,MODx.window.CreateUGNamespace); -Ext.reg('modx-window-user-group-namespace-update',MODx.window.UpdateUGNamespace); +Ext.extend(MODx.window.UpdateUGNamespace, MODx.window.CreateUGNamespace); +Ext.reg('modx-window-user-group-namespace-update', MODx.window.UpdateUGNamespace); diff --git a/manager/assets/modext/widgets/security/modx.grid.user.group.resource.js b/manager/assets/modext/widgets/security/modx.grid.user.group.resource.js index 340207c93d6..3df30911716 100644 --- a/manager/assets/modext/widgets/security/modx.grid.user.group.resource.js +++ b/manager/assets/modext/widgets/security/modx.grid.user.group.resource.js @@ -10,17 +10,17 @@ MODx.grid.UserGroupResourceGroup = function(config = {}) { lazyRender: false, enableCaching: false }); - Ext.applyIf(config,{ - id: 'modx-grid-user-group-resource-groups' - ,url: MODx.config.connector_url - ,baseParams: { - action: 'Security/Access/UserGroup/ResourceGroup/GetList' - ,usergroup: config.usergroup - ,resourceGroup: MODx.request.resourceGroup || null - ,policy: this.applyRequestFilter(1) - ,isGroupingGrid: true - } - ,fields: [ + Ext.applyIf(config, { + id: 'modx-grid-user-group-resource-groups', + url: MODx.config.connector_url, + baseParams: { + action: 'Security/Access/UserGroup/ResourceGroup/GetList', + usergroup: config.usergroup, + resourceGroup: MODx.request.resourceGroup || null, + policy: this.applyRequestFilter(1), + isGroupingGrid: true + }, + fields: [ 'id', 'target', 'name', @@ -32,74 +32,74 @@ MODx.grid.UserGroupResourceGroup = function(config = {}) { 'context_key', 'permissions', 'cls' - ] - ,grouping: true - ,groupBy: 'role_display' - ,remoteGroup: true - ,sortBy: 'name' - ,remoteSort: true - ,paging: true - ,hideMode: 'offsets' - ,singleText: _('policy') - ,pluralText: _('policies') - ,plugins: [this.exp] - ,columns: [ + ], + grouping: true, + groupBy: 'role_display', + remoteGroup: true, + sortBy: 'name', + remoteSort: true, + paging: true, + hideMode: 'offsets', + singleText: _('policy'), + pluralText: _('policies'), + plugins: [this.exp], + columns: [ this.exp, { - header: _('resource_group') - ,dataIndex: 'name' - ,width: 120 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/resourcegroup', 'name') - },{ - header: _('minimum_role') - ,dataIndex: 'role_display' - ,width: 100 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/permission', 'role_display') - },{ - header: _('policy') - ,dataIndex: 'policy_name' - ,width: 200 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { - linkParams: [{ key: 'id', valueIndex: 'policy'}] + header: _('resource_group'), + dataIndex: 'name', + width: 120, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/resourcegroup', 'name') + }, { + header: _('minimum_role'), + dataIndex: 'role_display', + width: 100, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/permission', 'role_display') + }, { + header: _('policy'), + dataIndex: 'policy_name', + width: 200, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { + linkParams: [{ key: 'id', valueIndex: 'policy' }] }) - },{ - header: _('context') - ,dataIndex: 'context_key' - ,width: 150 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('context/update', 'context_key', { - linkParams: [{ key: 'key', valueIndex: 'context_key'}] + }, { + header: _('context'), + dataIndex: 'context_key', + width: 150, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('context/update', 'context_key', { + linkParams: [{ key: 'key', valueIndex: 'context_key' }] }) } - ] - ,tbar: [ + ], + tbar: [ { - text: _('resource_group_add') - ,cls:'primary-button' - ,scope: this - ,handler: this.createAcl + text: _('resource_group_add'), + cls: 'primary-button', + scope: this, + handler: this.createAcl }, '->', { - xtype: 'modx-combo-resourcegroup' - ,itemId: 'filter-resourceGroup' - ,emptyText: _('filter_by_resource_group') - ,width: 210 - ,allowBlank: true - ,value: MODx.request.resourceGroup || null - ,baseParams: { + xtype: 'modx-combo-resourcegroup', + itemId: 'filter-resourceGroup', + emptyText: _('filter_by_resource_group'), + width: 210, + allowBlank: true, + value: MODx.request.resourceGroup || null, + baseParams: { action: 'Security/ResourceGroup/GetList', isGridFilter: true, usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-policy-resourceGroup', 'resourceGroup', record.data.id); @@ -108,21 +108,21 @@ MODx.grid.UserGroupResourceGroup = function(config = {}) { scope: this } } - },{ - xtype: 'modx-combo-policy' - ,itemId: 'filter-policy-resourceGroup' - ,emptyText: _('filter_by_policy') - ,width: 180 - ,allowBlank: true - ,value: this.applyRequestFilter(1) - ,baseParams: { + }, { + xtype: 'modx-combo-policy', + itemId: 'filter-policy-resourceGroup', + emptyText: _('filter_by_policy'), + width: 180, + allowBlank: true, + value: this.applyRequestFilter(1), + baseParams: { action: 'Security/Access/Policy/GetList', group: 'Resource,Object', isGridFilter: true, targetGrid: 'MODx.grid.UserGroupResourceGroup', usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-resourceGroup', 'policy', record.data.id); @@ -138,9 +138,9 @@ MODx.grid.UserGroupResourceGroup = function(config = {}) { ) ] }); - MODx.grid.UserGroupResourceGroup.superclass.constructor.call(this,config); + MODx.grid.UserGroupResourceGroup.superclass.constructor.call(this, config); - this.addEvents('createAcl','updateAcl'); + this.addEvents('createAcl', 'updateAcl'); const gridFilterData = [ { filterId: 'filter-policy-resourceGroup', dependentParams: ['resourceGroup'] }, @@ -149,12 +149,12 @@ MODx.grid.UserGroupResourceGroup = function(config = {}) { this.on({ createAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, updateAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, @@ -163,12 +163,12 @@ MODx.grid.UserGroupResourceGroup = function(config = {}) { } }); }; -Ext.extend(MODx.grid.UserGroupResourceGroup,MODx.grid.Grid,{ +Ext.extend(MODx.grid.UserGroupResourceGroup, MODx.grid.Grid, { - combos: {} - ,windows: {} + combos: {}, + windows: {}, - ,getMenu: function() { + getMenu: function() { const record = this.getSelectionModel().getSelected(), permissions = record.data.cls, menu = [] @@ -177,19 +177,19 @@ Ext.extend(MODx.grid.UserGroupResourceGroup,MODx.grid.Grid,{ if (this.getSelectionModel().getCount() > 1) { // Currently not allowing bulk actions for this grid } else { - if (permissions.indexOf('pedit') != -1) { + if (permissions.indexOf('pedit') !== -1) { menu.push({ text: _('access_rgroup_update'), handler: this.updateAcl }); } - if (permissions.indexOf('premove') != -1) { + if (permissions.indexOf('premove') !== -1) { if (menu.length > 0) { menu.push('-'); } menu.push({ text: _('access_rgroup_remove'), - handler: this.remove.createDelegate(this,['confirm_remove','Security/Access/UserGroup/ResourceGroup/Remove']) + handler: this.remove.createDelegate(this, ['confirm_remove', 'Security/Access/UserGroup/ResourceGroup/Remove']) }); } } @@ -197,49 +197,55 @@ Ext.extend(MODx.grid.UserGroupResourceGroup,MODx.grid.Grid,{ if (menu.length > 0) { this.addContextMenuItem(menu); } - } + }, - ,createAcl: function(itm,e) { - var r = { + createAcl: function(itm, e) { + const record = { principal: this.config.usergroup }; if (!this.windows.createAcl) { this.windows.createAcl = MODx.load({ - xtype: 'modx-window-user-group-resourcegroup-create' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('createAcl',r); - },scope:this} + xtype: 'modx-window-user-group-resourcegroup-create', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('createAcl', response); + }, + scope: this + } } }); } - this.windows.createAcl.setValues(r); + this.windows.createAcl.setValues(record); this.windows.createAcl.show(e.target); - } + }, - ,updateAcl: function(itm,e) { - var r = this.menu.record; + updateAcl: function(itm, e) { + const { record } = this.menu; if (!this.windows.updateAcl) { this.windows.updateAcl = MODx.load({ - xtype: 'modx-window-user-group-resourcegroup-update' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('updateAcl',r); - },scope:this} + xtype: 'modx-window-user-group-resourcegroup-update', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('updateAcl', response); + }, + scope: this + } } }); } - this.windows.updateAcl.setValues(r); + this.windows.updateAcl.setValues(record); this.windows.updateAcl.show(e.target); } }); -Ext.reg('modx-grid-user-group-resource-group',MODx.grid.UserGroupResourceGroup); +Ext.reg('modx-grid-user-group-resource-group', MODx.grid.UserGroupResourceGroup); /** * @class MODx.window.CreateUGRG @@ -247,129 +253,133 @@ Ext.reg('modx-grid-user-group-resource-group',MODx.grid.UserGroupResourceGroup); * @param {Object} config An object of options. * @xtype modx-window-user-group-resourcegroup-create */ -MODx.window.CreateUGRG = function(config) { - config = config || {}; - this.ident = config.ident || 'crgactx'+Ext.id(); - Ext.applyIf(config,{ - title: _('resource_group_add') - ,url: MODx.config.connector_url - ,action: 'Security/Access/UserGroup/ResourceGroup/Create' - ,fields: [{ - xtype: 'hidden' - ,name: 'id' - },{ - xtype: 'hidden' - ,name: 'principal' - ,hiddenName: 'principal' - },{ - xtype: 'hidden' - ,name: 'principal_class' - ,value: 'MODX\\Revolution\\modUserGroup' - },{ - xtype: 'modx-combo-resourcegroup' - ,fieldLabel: _('resource_group') - ,description: MODx.expandHelp ? '' : _('user_group_resourcegroup_resource_group_desc') - ,id: 'modx-'+this.ident+'-resource-group' - ,name: 'target' - ,hiddenName: 'target' - ,editable: false - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-resource-group' - ,html: _('user_group_resourcegroup_resource_group_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-context' - ,fieldLabel: _('context') - ,description: MODx.expandHelp ? '' : _('user_group_resourcegroup_context_desc') - ,id: 'modx-'+this.ident+'-context' - ,name: 'context_key' - ,hiddenName: 'context_key' - ,editable: false - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-context' - ,html: _('user_group_resourcegroup_context_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-authority' - ,fieldLabel: _('minimum_role') - ,description: MODx.expandHelp ? '' : _('user_group_resourcegroup_authority_desc') - ,id: 'modx-'+this.ident+'-authority' - ,name: 'authority' - ,value: 0 - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-authority' - ,html: _('user_group_resourcegroup_authority_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-policy' - ,fieldLabel: _('policy') - ,description: MODx.expandHelp ? '' : _('user_group_resourcegroup_policy_desc') - ,id: 'modx-'+this.ident+'-policy' - ,name: 'policy' - ,hiddenName: 'policy' - ,baseParams: { - action: 'Security/Access/Policy/GetList' - ,group: 'Resource,Object' - ,combo: true - } - ,anchor: '100%' - ,listeners: { - 'select':{fn:this.onPolicySelect,scope:this} +MODx.window.CreateUGRG = function(config = {}) { + this.ident = config.ident || `crgactx${Ext.id()}`; + Ext.applyIf(config, { + title: _('resource_group_add'), + url: MODx.config.connector_url, + action: 'Security/Access/UserGroup/ResourceGroup/Create', + fields: [{ + xtype: 'hidden', + name: 'id' + }, { + xtype: 'hidden', + name: 'principal', + hiddenName: 'principal' + }, { + xtype: 'hidden', + name: 'principal_class', + value: 'MODX\\Revolution\\modUserGroup' + }, { + xtype: 'modx-combo-resourcegroup', + fieldLabel: _('resource_group'), + description: MODx.expandHelp ? '' : _('user_group_resourcegroup_resource_group_desc'), + id: `modx-${this.ident}-resource-group`, + name: 'target', + hiddenName: 'target', + editable: false, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-resource-group`, + html: _('user_group_resourcegroup_resource_group_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-context', + fieldLabel: _('context'), + description: MODx.expandHelp ? '' : _('user_group_resourcegroup_context_desc'), + id: `modx-${this.ident}-context`, + name: 'context_key', + hiddenName: 'context_key', + editable: false, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-context`, + html: _('user_group_resourcegroup_context_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-authority', + fieldLabel: _('minimum_role'), + description: MODx.expandHelp ? '' : _('user_group_resourcegroup_authority_desc'), + id: `modx-${this.ident}-authority`, + name: 'authority', + value: 0, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-authority`, + html: _('user_group_resourcegroup_authority_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-policy', + fieldLabel: _('policy'), + description: MODx.expandHelp ? '' : _('user_group_resourcegroup_policy_desc'), + id: `modx-${this.ident}-policy`, + name: 'policy', + hiddenName: 'policy', + baseParams: { + action: 'Security/Access/Policy/GetList', + group: 'Resource,Object', + combo: true + }, + anchor: '100%', + listeners: { + select: { fn: this.onPolicySelect, scope: this } } - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-policy' - ,html: _('user_group_resourcegroup_policy_desc') - ,cls: 'desc-under' - },{ - id: 'modx-'+this.ident+'-permissions-list-ct' - ,cls: 'modx-permissions-list' - ,defaults: {border: false} - ,autoHeight: true - ,hidden: true - ,anchor: '100%' - ,items: [{ - html: '

'+_('permissions_in_policy')+'

' - ,id: 'modx-'+this.ident+'-permissions-list-header' - },{ - id: 'modx-'+this.ident+'-permissions-list' - ,cls: 'modx-permissions-list-textarea' - ,xtype: 'textarea' - ,grow: false - ,anchor: '100%' - ,height: 100 - ,width: '97%' - ,readOnly: true + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-policy`, + html: _('user_group_resourcegroup_policy_desc'), + cls: 'desc-under' + }, { + id: `modx-${this.ident}-permissions-list-ct`, + cls: 'modx-permissions-list', + defaults: { border: false }, + autoHeight: true, + hidden: true, + anchor: '100%', + items: [{ + html: `

${_('permissions_in_policy')}

`, + id: `modx-${this.ident}-permissions-list-header` + }, { + id: `modx-${this.ident}-permissions-list`, + cls: 'modx-permissions-list-textarea', + xtype: 'textarea', + grow: false, + anchor: '100%', + height: 100, + width: '97%', + readOnly: true }] }] }); - MODx.window.CreateUGRG.superclass.constructor.call(this,config); + MODx.window.CreateUGRG.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.CreateUGRG,MODx.Window,{ - onPolicySelect: function(cb,rec,idx) { - var s = cb.getStore(); - if (!s) return; - - var r = s.getAt(idx); - var lc = Ext.getCmp('modx-'+this.ident+'-permissions-list-ct'); - if (r && idx>0) { - lc.show(); - var pl = Ext.getCmp('modx-'+this.ident+'-permissions-list'); - var o = rec.data.permissions.join(', '); - pl.setValue(o); +Ext.extend(MODx.window.CreateUGRG, MODx.Window, { + onPolicySelect: function(cb, rec, idx) { + const store = cb.getStore(); + if (!store) { + return; + } + const + record = store.getAt(idx), + listContainer = Ext.getCmp(`modx-${this.ident}-permissions-list-ct`) + ; + if (record && idx > 0) { + listContainer.show(); + const + listCmp = Ext.getCmp(`modx-${this.ident}-permissions-list`), + list = rec.data.permissions.join(', ') + ; + listCmp.setValue(list); } else { - lc.hide(); + listContainer.hide(); } this.doLayout(); } }); -Ext.reg('modx-window-user-group-resourcegroup-create',MODx.window.CreateUGRG); +Ext.reg('modx-window-user-group-resourcegroup-create', MODx.window.CreateUGRG); /** * @class MODx.window.UpdateUGRG @@ -377,14 +387,13 @@ Ext.reg('modx-window-user-group-resourcegroup-create',MODx.window.CreateUGRG); * @param {Object} config An object of options. * @xtype modx-window-user-group-resourcegroup-update */ -MODx.window.UpdateUGRG = function(config) { - config = config || {}; - this.ident = config.ident || 'ugrgactx'+Ext.id(); - Ext.applyIf(config,{ - title: _('access_rgroup_update') - ,action: 'Security/Access/UserGroup/ResourceGroup/Update' +MODx.window.UpdateUGRG = function(config = {}) { + this.ident = config.ident || `ugrgactx${Ext.id()}`; + Ext.applyIf(config, { + title: _('access_rgroup_update'), + action: 'Security/Access/UserGroup/ResourceGroup/Update' }); - MODx.window.UpdateUGRG.superclass.constructor.call(this,config); + MODx.window.UpdateUGRG.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.UpdateUGRG,MODx.window.CreateUGRG); -Ext.reg('modx-window-user-group-resourcegroup-update',MODx.window.UpdateUGRG); +Ext.extend(MODx.window.UpdateUGRG, MODx.window.CreateUGRG); +Ext.reg('modx-window-user-group-resourcegroup-update', MODx.window.UpdateUGRG); diff --git a/manager/assets/modext/widgets/security/modx.grid.user.group.source.js b/manager/assets/modext/widgets/security/modx.grid.user.group.source.js index 7d32f1faf0b..ec3a8da98b0 100644 --- a/manager/assets/modext/widgets/security/modx.grid.user.group.source.js +++ b/manager/assets/modext/widgets/security/modx.grid.user.group.source.js @@ -10,17 +10,17 @@ MODx.grid.UserGroupSource = function(config = {}) { lazyRender: false, enableCaching: false }); - Ext.applyIf(config,{ - id: 'modx-grid-user-group-sources' - ,url: MODx.config.connector_url - ,baseParams: { - action: 'Security/Access/UserGroup/Source/GetList' - ,usergroup: config.usergroup - ,source: MODx.request.source || null - ,policy: this.applyRequestFilter(3) - ,isGroupingGrid: true - } - ,fields: [ + Ext.applyIf(config, { + id: 'modx-grid-user-group-sources', + url: MODx.config.connector_url, + baseParams: { + action: 'Security/Access/UserGroup/Source/GetList', + usergroup: config.usergroup, + source: MODx.request.source || null, + policy: this.applyRequestFilter(3), + isGroupingGrid: true + }, + fields: [ 'id', 'target', 'name', @@ -32,67 +32,67 @@ MODx.grid.UserGroupSource = function(config = {}) { 'context_key', 'permissions', 'cls' - ] - ,grouping: true - ,groupBy: 'role_display' - ,remoteGroup: true - ,sortBy: 'name' - ,remoteSort: true - ,paging: true - ,hideMode: 'offsets' - ,singleText: _('policy') - ,pluralText: _('policies') - ,plugins: [this.exp] - ,columns: [ + ], + grouping: true, + groupBy: 'role_display', + remoteGroup: true, + sortBy: 'name', + remoteSort: true, + paging: true, + hideMode: 'offsets', + singleText: _('policy'), + pluralText: _('policies'), + plugins: [this.exp], + columns: [ this.exp, { - header: _('source') - ,dataIndex: 'name' - ,width: 120 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('source/update', 'name', { + header: _('source'), + dataIndex: 'name', + width: 120, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('source/update', 'name', { linkParams: [{ key: 'id', valueIndex: 'target' }] }) - },{ - header: _('minimum_role') - ,dataIndex: 'role_display' - ,width: 100 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/permission', 'role_display') - },{ - header: _('policy') - ,dataIndex: 'policy_name' - ,width: 200 - ,sortable: true - ,xtype: 'templatecolumn' - ,tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { + }, { + header: _('minimum_role'), + dataIndex: 'role_display', + width: 100, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/permission', 'role_display') + }, { + header: _('policy'), + dataIndex: 'policy_name', + width: 200, + sortable: true, + xtype: 'templatecolumn', + tpl: this.getLinkTemplate('security/access/policy/update', 'policy_name', { linkParams: [{ key: 'id', valueIndex: 'policy' }] }) } - ] - ,tbar: [ + ], + tbar: [ { - text: _('source_add') - ,cls: 'primary-button' - ,scope: this - ,handler: this.createAcl + text: _('source_add'), + cls: 'primary-button', + scope: this, + handler: this.createAcl }, '->', { - xtype: 'modx-combo-source' - ,itemId: 'filter-source' - ,emptyText: _('filter_by_source') - ,width: 200 - ,allowBlank: true - ,value: MODx.request.source || null - ,baseParams: { + xtype: 'modx-combo-source', + itemId: 'filter-source', + emptyText: _('filter_by_source'), + width: 200, + allowBlank: true, + value: MODx.request.source || null, + baseParams: { action: 'Source/GetList', isGridFilter: true, usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-policy-source', 'source', record.data.id); @@ -101,21 +101,21 @@ MODx.grid.UserGroupSource = function(config = {}) { scope: this } } - },{ - xtype: 'modx-combo-policy' - ,itemId: 'filter-policy-source' - ,emptyText: _('filter_by_policy') - ,width: 180 - ,allowBlank: true - ,value: this.applyRequestFilter(3) - ,baseParams: { + }, { + xtype: 'modx-combo-policy', + itemId: 'filter-policy-source', + emptyText: _('filter_by_policy'), + width: 180, + allowBlank: true, + value: this.applyRequestFilter(3), + baseParams: { action: 'Security/Access/Policy/GetList', group: 'MediaSource', isGridFilter: true, targetGrid: 'MODx.grid.UserGroupSource', usergroup: config.usergroup - } - ,listeners: { + }, + listeners: { select: { fn: function(cmp, record, selectedIndex) { this.updateDependentFilter('filter-source', 'policy', record.data.id); @@ -131,9 +131,9 @@ MODx.grid.UserGroupSource = function(config = {}) { ) ] }); - MODx.grid.UserGroupSource.superclass.constructor.call(this,config); + MODx.grid.UserGroupSource.superclass.constructor.call(this, config); - this.addEvents('createAcl','updateAcl'); + this.addEvents('createAcl', 'updateAcl'); const gridFilterData = [ { filterId: 'filter-policy-source', dependentParams: ['source'] }, @@ -142,12 +142,12 @@ MODx.grid.UserGroupSource = function(config = {}) { this.on({ createAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, updateAcl: function() { - if (arguments[0].a.response.status == 200) { + if (arguments[0].a.response.status === 200) { this.refreshFilterOptions(gridFilterData); } }, @@ -156,11 +156,11 @@ MODx.grid.UserGroupSource = function(config = {}) { } }); }; -Ext.extend(MODx.grid.UserGroupSource,MODx.grid.Grid,{ - combos: {} - ,windows: {} +Ext.extend(MODx.grid.UserGroupSource, MODx.grid.Grid, { + combos: {}, + windows: {}, - ,getMenu: function() { + getMenu: function() { const record = this.getSelectionModel().getSelected(), permissions = record.data.cls, menu = [] @@ -169,19 +169,19 @@ Ext.extend(MODx.grid.UserGroupSource,MODx.grid.Grid,{ if (this.getSelectionModel().getCount() > 1) { // Currently not allowing bulk actions for this grid } else { - if (permissions.indexOf('pedit') != -1) { + if (permissions.indexOf('pedit') !== -1) { menu.push({ text: _('access_source_update'), handler: this.updateAcl }); } - if (permissions.indexOf('premove') != -1) { + if (permissions.indexOf('premove') !== -1) { if (menu.length > 0) { menu.push('-'); } menu.push({ text: _('access_source_remove'), - handler: this.remove.createDelegate(this,['confirm_remove','Security/Access/UserGroup/Source/Remove']) + handler: this.remove.createDelegate(this, ['confirm_remove', 'Security/Access/UserGroup/Source/Remove']) }); } } @@ -189,48 +189,54 @@ Ext.extend(MODx.grid.UserGroupSource,MODx.grid.Grid,{ if (menu.length > 0) { this.addContextMenuItem(menu); } - } + }, - ,createAcl: function(itm,e) { - var r = { + createAcl: function(itm, e) { + const record = { principal: this.config.usergroup }; if (!this.windows.createAcl) { this.windows.createAcl = MODx.load({ - xtype: 'modx-window-user-group-source-create' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('createAcl',r); - },scope:this} + xtype: 'modx-window-user-group-source-create', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('createAcl', response); + }, + scope: this + } } }); } - this.windows.createAcl.setValues(r); + this.windows.createAcl.setValues(record); this.windows.createAcl.show(e.target); - } + }, - ,updateAcl: function(itm,e) { - var r = this.menu.record; + updateAcl: function(itm, e) { + const { record } = this.menu; if (!this.windows.updateAcl) { this.windows.updateAcl = MODx.load({ - xtype: 'modx-window-user-group-source-update' - ,record: r - ,listeners: { - 'success': {fn:function(r) { - this.refresh(); - this.fireEvent('updateAcl',r); - },scope:this} + xtype: 'modx-window-user-group-source-update', + record: record, + listeners: { + success: { + fn: function(response) { + this.refresh(); + this.fireEvent('updateAcl', response); + }, + scope: this + } } }); } - this.windows.updateAcl.setValues(r); + this.windows.updateAcl.setValues(record); this.windows.updateAcl.show(e.target); } }); -Ext.reg('modx-grid-user-group-source',MODx.grid.UserGroupSource); +Ext.reg('modx-grid-user-group-source', MODx.grid.UserGroupSource); /** * @class MODx.window.CreateUGSource @@ -238,120 +244,127 @@ Ext.reg('modx-grid-user-group-source',MODx.grid.UserGroupSource); * @param {Object} config An object of options. * @xtype modx-window-user-group-source-create */ -MODx.window.CreateUGSource = function(config) { - config = config || {}; - this.ident = config.ident || 'cugsrc'+Ext.id(); - Ext.applyIf(config,{ - title: _('source_add') - ,url: MODx.config.connector_url - ,action: 'Security/Access/UserGroup/Source/Create' - ,fields: [{ - xtype: 'hidden' - ,name: 'id' - },{ - xtype: 'hidden' - ,name: 'principal' - ,hiddenName: 'principal' - },{ - xtype: 'hidden' - ,name: 'principal_class' - ,value: 'MODX\\Revolution\\modUserGroup' - },{ - xtype: 'hidden' - ,name: 'context_key' - ,hiddenName: 'context_key' - ,value: 'mgr' - },{ - xtype: 'modx-combo-source' - ,fieldLabel: _('source') - ,description: MODx.expandHelp ? '' : _('user_group_source_source_desc') - ,id: 'modx-'+this.ident+'-source' - ,name: 'target' - ,hiddenName: 'target' - ,editable: false - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-source' - ,html: _('user_group_source_source_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-authority' - ,fieldLabel: _('minimum_role') - ,description: MODx.expandHelp ? '' : _('user_group_source_authority_desc') - ,id: 'modx-'+this.ident+'-authority' - ,name: 'authority' - ,value: 0 - ,anchor: '100%' - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-authority' - ,html: _('user_group_source_authority_desc') - ,cls: 'desc-under' - },{ - xtype: 'modx-combo-policy' - ,fieldLabel: _('policy') - ,description: MODx.expandHelp ? '' : _('user_group_source_policy_desc') - ,id: 'modx-'+this.ident+'-policy' - ,name: 'policy' - ,hiddenName: 'policy' - ,baseParams: { - action: 'Security/Access/Policy/GetList' - ,group: 'MediaSource' - } - ,anchor: '100%' - ,listeners: { - 'select':{fn:this.onPolicySelect,scope:this} +MODx.window.CreateUGSource = function(config = {}) { + this.ident = config.ident || `cugsrc${Ext.id()}`; + Ext.applyIf(config, { + title: _('source_add'), + url: MODx.config.connector_url, + action: 'Security/Access/UserGroup/Source/Create', + fields: [{ + xtype: 'hidden', + name: 'id' + }, { + xtype: 'hidden', + name: 'principal', + hiddenName: 'principal' + }, { + xtype: 'hidden', + name: 'principal_class', + value: 'MODX\\Revolution\\modUserGroup' + }, { + xtype: 'hidden', + name: 'context_key', + hiddenName: 'context_key', + value: 'mgr' + }, { + xtype: 'modx-combo-source', + fieldLabel: _('source'), + description: MODx.expandHelp ? '' : _('user_group_source_source_desc'), + id: `modx-${this.ident}-source`, + name: 'target', + hiddenName: 'target', + editable: false, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-source`, + html: _('user_group_source_source_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-authority', + fieldLabel: _('minimum_role'), + description: MODx.expandHelp ? '' : _('user_group_source_authority_desc'), + id: `modx-${this.ident}-authority`, + name: 'authority', + value: 0, + anchor: '100%' + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-authority`, + html: _('user_group_source_authority_desc'), + cls: 'desc-under' + }, { + xtype: 'modx-combo-policy', + fieldLabel: _('policy'), + description: MODx.expandHelp ? '' : _('user_group_source_policy_desc'), + id: `modx-${this.ident}-policy`, + name: 'policy', + hiddenName: 'policy', + baseParams: { + action: 'Security/Access/Policy/GetList', + group: 'MediaSource' + }, + anchor: '100%', + listeners: { + select: { + fn: this.onPolicySelect, + scope: this + } } - },{ - xtype: MODx.expandHelp ? 'label' : 'hidden' - ,forId: 'modx-'+this.ident+'-policy' - ,html: _('user_group_source_policy_desc') - ,cls: 'desc-under' - },{ - id: 'modx-'+this.ident+'-permissions-list-ct' - ,cls: 'modx-permissions-list' - ,defaults: {border: false} - ,autoHeight: true - ,hidden: true - ,anchor: '100%' - ,items: [{ - html: '

'+_('permissions_in_policy')+'

' - ,id: 'modx-'+this.ident+'-permissions-list-header' - },{ - id: 'modx-'+this.ident+'-permissions-list' - ,cls: 'modx-permissions-list-textarea' - ,xtype: 'textarea' - ,name: 'permissions' - ,grow: false - ,anchor: '100%' - ,height: 100 - ,width: '97%' - ,readOnly: true + }, { + xtype: MODx.expandHelp ? 'label' : 'hidden', + forId: `modx-${this.ident}-policy`, + html: _('user_group_source_policy_desc'), + cls: 'desc-under' + }, { + id: `modx-${this.ident}-permissions-list-ct`, + cls: 'modx-permissions-list', + defaults: { border: false }, + autoHeight: true, + hidden: true, + anchor: '100%', + items: [{ + html: `

${_('permissions_in_policy')}

`, + id: `modx-${this.ident}-permissions-list-header` + }, { + id: `modx-${this.ident}-permissions-list`, + cls: 'modx-permissions-list-textarea', + xtype: 'textarea', + name: 'permissions', + grow: false, + anchor: '100%', + height: 100, + width: '97%', + readOnly: true }] }] }); - MODx.window.CreateUGSource.superclass.constructor.call(this,config); + MODx.window.CreateUGSource.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.CreateUGSource,MODx.Window,{ - onPolicySelect: function(cb,rec,idx) { - var s = cb.getStore(); - if (!s) return; - - var r = s.getAt(idx); - var lc = Ext.getCmp('modx-'+this.ident+'-permissions-list-ct'); - if (r && idx>0) { - lc.show(); - var pl = Ext.getCmp('modx-'+this.ident+'-permissions-list'); - var o = rec.data.permissions.join(', '); - pl.setValue(o); +Ext.extend(MODx.window.CreateUGSource, MODx.Window, { + onPolicySelect: function(cb, rec, idx) { + const store = cb.getStore(); + if (!store) { + return; + } + const + record = store.getAt(idx), + listContainer = Ext.getCmp(`modx-${this.ident}-permissions-list-ct`) + ; + if (record && idx > 0) { + listContainer.show(); + const + listCmp = Ext.getCmp(`modx-${this.ident}-permissions-list`), + list = rec.data.permissions.join(', ') + ; + listCmp.setValue(list); } else { - lc.hide(); + listContainer.hide(); } this.doLayout(); } }); -Ext.reg('modx-window-user-group-source-create',MODx.window.CreateUGSource); +Ext.reg('modx-window-user-group-source-create', MODx.window.CreateUGSource); /** * @class MODx.window.UpdateUGSource @@ -359,14 +372,13 @@ Ext.reg('modx-window-user-group-source-create',MODx.window.CreateUGSource); * @param {Object} config An object of options. * @xtype modx-window-user-group-source-update */ -MODx.window.UpdateUGSource = function(config) { - config = config || {}; - this.ident = config.ident || 'updugsrc'+Ext.id(); - Ext.applyIf(config,{ - title: _('access_source_update') - ,action: 'Security/Access/UserGroup/Source/Update' +MODx.window.UpdateUGSource = function(config = {}) { + this.ident = config.ident || `updugsrc${Ext.id()}`; + Ext.applyIf(config, { + title: _('access_source_update'), + action: 'Security/Access/UserGroup/Source/Update' }); - MODx.window.UpdateUGSource.superclass.constructor.call(this,config); + MODx.window.UpdateUGSource.superclass.constructor.call(this, config); }; -Ext.extend(MODx.window.UpdateUGSource,MODx.window.CreateUGSource); -Ext.reg('modx-window-user-group-source-update',MODx.window.UpdateUGSource); +Ext.extend(MODx.window.UpdateUGSource, MODx.window.CreateUGSource); +Ext.reg('modx-window-user-group-source-update', MODx.window.UpdateUGSource);