From a1d5d0649e150c581759892c2a196d67287a5c8e Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 20 Mar 2017 07:23:16 +0100 Subject: [PATCH] new widget: proxmoxStdRemoveButton --- button/Button.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/button/Button.js b/button/Button.js index 15619a3..5a03be7 100644 --- a/button/Button.js +++ b/button/Button.js @@ -74,3 +74,42 @@ Ext.define('Proxmox.button.Button', { } } }); + + +Ext.define('Proxmox.button.StdRemoveButton', { + extend: 'Proxmox.button.Button', + alias: 'widget.proxmoxStdRemoveButton', + + text: gettext('Remove'), + + disabled: true, + + baseurl: undefined, + + callback: function(options, success, response) {}, + + getRecordName: function(rec) { return rec.getId() }, + + confirmMsg: function (rec) { + var me = this; + + var name = me.getRecordName(rec); + return Ext.String.format( + gettext('Are you sure you want to remove entry {0}'), + "'" + name + "'"); + }, + + handler: function(btn, event, rec) { + var me = this; + + Proxmox.Utils.API2Request({ + url: me.baseurl + '/' + rec.getId(), + method: 'DELETE', + waitMsgTarget: me.waitMsgTarget, + callback: me.callback, + failure: function (response, opts) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + } + }); + } +});