mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-17 21:48:47 +00:00
network: use std remove button for confirm
alows to make the code simpler too, but we need to instantiate the selection model explicitly, as we use a bit of a weird layout here to be able to show the pending changes at the bottom, if any, so the main gridpanel is not the parent of the toolbar buttons, so the std-remove button does not automatically finds the selection model when searching in the parent Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
99f3e147e4
commit
bb5511d569
@ -110,31 +110,12 @@ Ext.define('Proxmox.node.NetworkView', {
|
|||||||
handler: run_editor,
|
handler: run_editor,
|
||||||
});
|
});
|
||||||
|
|
||||||
let del_btn = new Ext.Button({
|
let sm = Ext.create('Ext.selection.RowModel', {});
|
||||||
text: gettext('Remove'),
|
|
||||||
disabled: true,
|
|
||||||
handler: function() {
|
|
||||||
let grid = me.down('gridpanel');
|
|
||||||
let sm = grid.getSelectionModel();
|
|
||||||
let rec = sm.getSelection()[0];
|
|
||||||
if (!rec) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let iface = rec.data.iface;
|
let del_btn = new Proxmox.button.StdRemoveButton({
|
||||||
|
selModel: sm,
|
||||||
Proxmox.Utils.API2Request({
|
getUrl: ({ data }) => `${baseUrl}/${data.iface}`,
|
||||||
url: baseUrl + '/' + iface,
|
callback: () => reload(),
|
||||||
method: 'DELETE',
|
|
||||||
waitMsgTarget: me,
|
|
||||||
callback: function() {
|
|
||||||
reload();
|
|
||||||
},
|
|
||||||
failure: function(response, opts) {
|
|
||||||
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let apply_btn = Ext.create('Proxmox.button.Button', {
|
let apply_btn = Ext.create('Proxmox.button.Button', {
|
||||||
@ -165,8 +146,6 @@ Ext.define('Proxmox.node.NetworkView', {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let set_button_status = function() {
|
let set_button_status = function() {
|
||||||
let grid = me.down('gridpanel');
|
|
||||||
let sm = grid.getSelectionModel();
|
|
||||||
let rec = sm.getSelection()[0];
|
let rec = sm.getSelection()[0];
|
||||||
|
|
||||||
edit_btn.setDisabled(!rec);
|
edit_btn.setDisabled(!rec);
|
||||||
@ -328,6 +307,7 @@ Ext.define('Proxmox.node.NetworkView', {
|
|||||||
stateful: true,
|
stateful: true,
|
||||||
stateId: 'grid-node-network',
|
stateId: 'grid-node-network',
|
||||||
store: store,
|
store: store,
|
||||||
|
selModel: sm,
|
||||||
region: 'center',
|
region: 'center',
|
||||||
border: false,
|
border: false,
|
||||||
columns: [
|
columns: [
|
||||||
|
Loading…
Reference in New Issue
Block a user