Skip to content

Commit

Permalink
FC Profiles & Sets finalization
Browse files Browse the repository at this point in the history
Tweaks and optimizations; fix issue with fields and tvs grids not showing inactive rows properly
  • Loading branch information
smg6511 committed Dec 11, 2024
1 parent 757b2e0 commit 2b88f50
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 42 deletions.
15 changes: 12 additions & 3 deletions manager/assets/modext/widgets/core/modx.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ MODx.grid.GridBase = function GridBase(config = {}) {
};

Ext.applyIf(config.groupingConfig, groupingConfig);
if (Object.hasOwn(config, 'viewConfig') && Object.hasOwn(config.viewConfig, 'getRowClass')) {
Ext.applyIf(config.groupingConfig, {
getRowClass: config.viewConfig.getRowClass
});
}
Ext.applyIf(config, {
view: new Ext.grid.GroupingView(config.groupingConfig)
});
Expand Down Expand Up @@ -1147,9 +1152,13 @@ Ext.extend(MODx.grid.GridBase, Ext.grid.EditorGridPanel, {
if (this.cm && Object.hasOwn(this.cm.config[0], 'expandRow')) {
rowClasses.push('x-grid3-row-collapsed');
}
// Objects whose records can be activated/deactivated do not depend upon permission to delete
if (markActiveRows && Object.hasOwn(record.data, 'active')) {
const activeClass = record.data.active ? 'grid-row-active' : 'grid-row-inactive';
/*
Objects whose records can be activated/deactivated do not depend upon
permission to delete; 'visible' prop is used in Form Customization grids,
'active' in others
*/
if (markActiveRows && (Object.hasOwn(record.data, 'active') || Object.hasOwn(record.data, 'visible'))) {
const activeClass = record.data.active || record.data.visible ? 'grid-row-active' : 'grid-row-inactive';
rowClasses.push(activeClass);
}
// Early return if no deletion restrictions are in effect
Expand Down
17 changes: 12 additions & 5 deletions manager/assets/modext/widgets/fc/modx.panel.fcprofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,25 @@ Ext.reg('modx-panel-fc-profile', MODx.panel.FCProfile);
MODx.grid.FCProfileUserGroups = function(config = {}) {
Ext.applyIf(config, {
id: 'modx-grid-fc-profile-usergroups',
fields: ['id', 'name'],
fields: [
'id',
'name'
],
autoHeight: true,
stateful: false,
columns: [{
header: _('name'),
dataIndex: 'name',
renderer: {
fn: function(value, metaData, record) {
return this.renderLink(value, {
href: `?a=security/usergroup/update&id=${record.data.id}`,
target: '_blank'
});
const canEditGroups = MODx.perm.usergroup_edit && MODx.perm.usergroup_save;
return canEditGroups
? this.renderLink(value, {
href: `?a=security/usergroup/update&id=${record.data.id}`,
target: '_blank'
})
: value
;
},
scope: this
}
Expand Down
45 changes: 11 additions & 34 deletions manager/assets/modext/widgets/fc/modx.panel.fcset.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,7 @@ MODx.grid.FCSetFields = function(config = {}) {
return Ext.util.Format.htmlEncode(v);
}
}],
viewConfig: {
forceFit: true,
enableRowBody: true,
scrollOffset: 0,
autoFill: true,
showPreview: true,
getRowClass: function(record, rowIndex, rowParams, store) {
return record.data.visible ? 'grid-row-active' : 'grid-row-inactive';
}
}
viewConfig: this.getViewConfig(false, false, true)
});
MODx.grid.FCSetFields.superclass.constructor.call(this, config);
this.propRecord = Ext.data.Record.create(config.fields);
Expand Down Expand Up @@ -370,16 +361,7 @@ MODx.grid.FCSetTabs = function(config = {}) {
dataIndex: 'label',
editor: { xtype: 'textfield' }
}],
viewConfig: {
forceFit: true,
enableRowBody: true,
scrollOffset: 0,
autoFill: true,
showPreview: true,
getRowClass: function(record, rowIndex, rowParams, store) {
return record.data.visible ? 'grid-row-active' : 'grid-row-inactive';
}
},
viewConfig: this.getViewConfig(false, false, true),
tbar: [{
text: _('create'),
cls: 'primary-button',
Expand Down Expand Up @@ -481,10 +463,14 @@ MODx.grid.FCSetTVs = function(config = {}) {
width: 200,
renderer: {
fn: function(value, metaData, record) {
return this.renderLink(value, {
href: `?a=element/tv/update&id=${record.data.id}`,
target: '_blank'
});
const canEditTvs = MODx.perm.edit_tv && MODx.perm.save_tv;
return canEditTvs
? this.renderLink(value, {
href: `?a=element/tv/update&id=${record.data.id}`,
target: '_blank'
})
: value
;
},
scope: this
}
Expand Down Expand Up @@ -512,16 +498,7 @@ MODx.grid.FCSetTVs = function(config = {}) {
width: 70,
editor: { xtype: 'textfield' }
}],
viewConfig: {
forceFit: true,
enableRowBody: true,
scrollOffset: 0,
autoFill: true,
showPreview: true,
getRowClass: function(record, rowIndex, rowParams, store) {
return record.data.visible ? 'grid-row-active' : 'grid-row-inactive';
}
}
viewConfig: this.getViewConfig(false, false, true)
});
MODx.grid.FCSetTVs.superclass.constructor.call(this, config);
this.propRecord = Ext.data.Record.create(config.fields);
Expand Down

0 comments on commit 2b88f50

Please sign in to comment.