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', {
store.load();
};
var tbar = [
{
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();
}
},
{
var remove_btn = new Ext.Button({
text: 'Delete',
disabled: true,
handler: function() {
var msg;
var sm = me.getSelectionModel();
......@@ -63,7 +36,6 @@ Ext.define('PVE.dc.UserView', {
var userid = rec.data.userid;
if (userid !== 'root@pam') {
msg = 'Are you sure you want to permanently delete the user: ' + userid;
Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
if (btn !== 'yes') {
......@@ -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) {
......@@ -165,7 +180,9 @@ Ext.define('PVE.dc.UserView', {
}
],
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