Commit 360018e2 authored by Dietmar Maurer's avatar Dietmar Maurer

improve UserView GUI (sensitive buttons)

parent 04bbdbc2
...@@ -23,36 +23,9 @@ Ext.define('PVE.dc.UserView', { ...@@ -23,36 +23,9 @@ Ext.define('PVE.dc.UserView', {
store.load(); store.load();
}; };
var tbar = [ var remove_btn = new Ext.Button({
{
text: 'Create',
handler: function() {
var win = Ext.create('PVE.dc.UserEdit',{
});
win.on('destroy', reload);
win.show();
}
},
{
text: 'Modify',
handler: function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
var userid = rec.data.userid;
var win = Ext.create('PVE.dc.UserEdit',{
userid: userid
});
win.on('destroy', reload);
win.show();
}
},
{
text: 'Delete', text: 'Delete',
disabled: true,
handler: function() { handler: function() {
var msg; var msg;
var sm = me.getSelectionModel(); var sm = me.getSelectionModel();
...@@ -63,7 +36,6 @@ Ext.define('PVE.dc.UserView', { ...@@ -63,7 +36,6 @@ Ext.define('PVE.dc.UserView', {
var userid = rec.data.userid; var userid = rec.data.userid;
if (userid !== 'root@pam') {
msg = 'Are you sure you want to permanently delete the user: ' + userid; msg = 'Are you sure you want to permanently delete the user: ' + userid;
Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) { Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
if (btn !== 'yes') { if (btn !== 'yes') {
...@@ -82,12 +54,55 @@ Ext.define('PVE.dc.UserView', { ...@@ -82,12 +54,55 @@ Ext.define('PVE.dc.UserView', {
} }
}); });
}); });
} else {
msg = 'You are not permitted to delete the user: root@pam';
Ext.Msg.alert('Error', msg);
} }
});
var run_editor = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
} }
var win = Ext.create('PVE.dc.UserEdit',{
userid: rec.data.userid
});
win.on('destroy', reload);
win.show();
};
var edit_btn = new Ext.Button({
text: 'Modify',
disabled: true,
handler: run_editor
});
var set_button_status = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
remove_btn.disable();
edit_btn.disable();
return;
} }
edit_btn.setDisabled(false);
remove_btn.setDisabled(rec.data.userid === 'root@pam');
};
var tbar = [
{
text: 'Create',
handler: function() {
var win = Ext.create('PVE.dc.UserEdit',{
});
win.on('destroy', reload);
win.show();
}
},
edit_btn, remove_btn
]; ];
var render_expire = function(date) { var render_expire = function(date) {
...@@ -165,7 +180,9 @@ Ext.define('PVE.dc.UserView', { ...@@ -165,7 +180,9 @@ Ext.define('PVE.dc.UserView', {
} }
], ],
listeners: { listeners: {
show: reload show: reload,
itemdblclick: run_editor,
selectionchange: set_button_status
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment