From bb5511d569fa4bd2fd792d4677d3bf8ca4e762e3 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 6 Jul 2021 20:55:52 +0200 Subject: [PATCH] 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 --- src/node/NetworkView.js | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/node/NetworkView.js b/src/node/NetworkView.js index da47fba..34b0da8 100644 --- a/src/node/NetworkView.js +++ b/src/node/NetworkView.js @@ -110,31 +110,12 @@ Ext.define('Proxmox.node.NetworkView', { handler: run_editor, }); - let del_btn = new Ext.Button({ - 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 sm = Ext.create('Ext.selection.RowModel', {}); - let iface = rec.data.iface; - - Proxmox.Utils.API2Request({ - url: baseUrl + '/' + iface, - method: 'DELETE', - waitMsgTarget: me, - callback: function() { - reload(); - }, - failure: function(response, opts) { - Ext.Msg.alert(gettext('Error'), response.htmlStatus); - }, - }); - }, + let del_btn = new Proxmox.button.StdRemoveButton({ + selModel: sm, + getUrl: ({ data }) => `${baseUrl}/${data.iface}`, + callback: () => reload(), }); let apply_btn = Ext.create('Proxmox.button.Button', { @@ -165,8 +146,6 @@ Ext.define('Proxmox.node.NetworkView', { }); let set_button_status = function() { - let grid = me.down('gridpanel'); - let sm = grid.getSelectionModel(); let rec = sm.getSelection()[0]; edit_btn.setDisabled(!rec); @@ -328,6 +307,7 @@ Ext.define('Proxmox.node.NetworkView', { stateful: true, stateId: 'grid-node-network', store: store, + selModel: sm, region: 'center', border: false, columns: [