Commit fad2c77d authored by Dietmar Maurer's avatar Dietmar Maurer

cleanup: use PVE.button.Button

parent a8875ec0
...@@ -37,7 +37,7 @@ Ext.define('PVE.dc.GroupView', { ...@@ -37,7 +37,7 @@ Ext.define('PVE.dc.GroupView', {
reload(); reload();
}, },
failure: function (response, opts) { failure: function (response, opts) {
Ext.Msg.alert(gettext('Error'),response.htmlStatus); Ext.Msg.alert(gettext('Error'), response.htmlStatus);
} }
}); });
} }
...@@ -56,9 +56,10 @@ Ext.define('PVE.dc.GroupView', { ...@@ -56,9 +56,10 @@ Ext.define('PVE.dc.GroupView', {
win.show(); win.show();
}; };
var edit_btn = new Ext.Button({ var edit_btn = new PVE.button.Button({
text: gettext('Edit'), text: gettext('Edit'),
disabled: true, disabled: true,
selModel: sm,
handler: run_editor handler: run_editor
}); });
...@@ -66,8 +67,7 @@ Ext.define('PVE.dc.GroupView', { ...@@ -66,8 +67,7 @@ Ext.define('PVE.dc.GroupView', {
{ {
text: gettext('Create'), text: gettext('Create'),
handler: function() { handler: function() {
var win = Ext.create('PVE.dc.GroupEdit', { var win = Ext.create('PVE.dc.GroupEdit', {});
});
win.on('destroy', reload); win.on('destroy', reload);
win.show(); win.show();
} }
......
...@@ -19,42 +19,37 @@ Ext.define('PVE.dc.UserView', { ...@@ -19,42 +19,37 @@ Ext.define('PVE.dc.UserView', {
store.load(); store.load();
}; };
var remove_btn = new Ext.Button({ var sm = Ext.create('Ext.selection.RowModel', {});
var remove_btn = new PVE.button.Button({
text: gettext('Remove'), text: gettext('Remove'),
disabled: true, disabled: true,
handler: function() { selModel: sm,
var msg; enableFn: function(rec) {
var sm = me.getSelectionModel(); return rec.data.userid !== 'root@pam';
var rec = sm.getSelection()[0]; },
if (!rec) { confirmMsg: function (rec) {
return; return Ext.String.format(gettext('Are you sure you want to remove entry {0}'),
} "'" + rec.data.userid + "'");
},
handler: function(btn, event, rec) {
var userid = rec.data.userid; var userid = rec.data.userid;
msg = 'Are you sure you want to permanently delete the user: ' + userid; PVE.Utils.API2Request({
Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) { url: '/access/users/' + userid,
if (btn !== 'yes') { method: 'DELETE',
return; waitMsgTarget: me,
callback: function() {
reload();
},
failure: function (response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
} }
PVE.Utils.API2Request({
url: '/access/users/' + userid,
method: 'DELETE',
waitMsgTarget: me,
callback: function() {
reload();
},
failure: function (response, opts) {
Ext.Msg.alert('Error',response.htmlStatus);
}
});
}); });
} }
}); });
var run_editor = function() { var run_editor = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0]; var rec = sm.getSelection()[0];
if (!rec) { if (!rec) {
return; return;
...@@ -67,27 +62,13 @@ Ext.define('PVE.dc.UserView', { ...@@ -67,27 +62,13 @@ Ext.define('PVE.dc.UserView', {
win.show(); win.show();
}; };
var edit_btn = new Ext.Button({ var edit_btn = new PVE.button.Button({
text: gettext('Edit'), text: gettext('Edit'),
disabled: true, disabled: true,
selModel: sm,
handler: run_editor 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 = [ var tbar = [
{ {
text: gettext('Create'), text: gettext('Create'),
...@@ -125,13 +106,12 @@ Ext.define('PVE.dc.UserView', { ...@@ -125,13 +106,12 @@ Ext.define('PVE.dc.UserView', {
Ext.apply(me, { Ext.apply(me, {
store: store, store: store,
selModel: sm,
stateful: false, stateful: false,
tbar: tbar, tbar: tbar,
viewConfig: { viewConfig: {
trackOver: false trackOver: false
}, },
columns: [ columns: [
{ {
header: gettext('User name'), header: gettext('User name'),
...@@ -177,8 +157,7 @@ Ext.define('PVE.dc.UserView', { ...@@ -177,8 +157,7 @@ Ext.define('PVE.dc.UserView', {
], ],
listeners: { listeners: {
show: reload, show: reload,
itemdblclick: run_editor, 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