pve-manager/www/manager6/dc/RoleView.js
Fabian Ebner 392e3cf11d sorters: use correct property 'direction' and keep default 'ASC'
Ext.util.Sorter does not have an 'order' property, so 'order: DESC'
didn't have an effect. The default is 'ASC' and it is arguably the
preferred direction for all affected sorters anyways.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-12-16 10:11:48 +01:00

118 lines
2.2 KiB
JavaScript

Ext.define('PVE.dc.RoleView', {
extend: 'Ext.grid.GridPanel',
alias: ['widget.pveRoleView'],
onlineHelp: 'pveum_roles',
stateful: true,
stateId: 'grid-roles',
initComponent: function() {
let me = this;
let store = new Ext.data.Store({
model: 'pmx-roles',
sorters: {
property: 'roleid',
direction: 'ASC',
},
});
Proxmox.Utils.monStoreErrors(me, store);
let sm = Ext.create('Ext.selection.RowModel', {});
let run_editor = function() {
let rec = sm.getSelection()[0];
if (!rec) {
return;
}
if (rec.data.special) {
return;
}
Ext.create('PVE.dc.RoleEdit', {
roleid: rec.data.roleid,
privs: rec.data.privs,
listeners: {
destroy: () => store.load(),
},
autoShow: true,
});
};
Ext.apply(me, {
store: store,
selModel: sm,
viewConfig: {
trackOver: false,
},
columns: [
{
header: gettext('Built-In'),
width: 65,
sortable: true,
dataIndex: 'special',
renderer: Proxmox.Utils.format_boolean,
},
{
header: gettext('Name'),
width: 150,
sortable: true,
dataIndex: 'roleid',
},
{
itemid: 'privs',
header: gettext('Privileges'),
sortable: false,
renderer: (value, metaData) => {
if (!value) {
return '-';
}
metaData.style = 'white-space:normal;'; // allow word wrap
return value.replace(/,/g, ' ');
},
variableRowHeight: true,
dataIndex: 'privs',
flex: 1,
},
],
listeners: {
activate: function() {
store.load();
},
itemdblclick: run_editor,
},
tbar: [
{
text: gettext('Create'),
handler: function() {
Ext.create('PVE.dc.RoleEdit', {
listeners: {
destroy: () => store.load(),
},
autoShow: true,
});
},
},
{
xtype: 'proxmoxButton',
text: gettext('Edit'),
disabled: true,
selModel: sm,
handler: run_editor,
enableFn: (rec) => !rec.data.special,
},
{
xtype: 'proxmoxStdRemoveButton',
selModel: sm,
callback: () => store.load(),
baseurl: '/access/roles/',
enableFn: (rec) => !rec.data.special,
},
],
});
me.callParent();
},
});