]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
new widget: proxmoxStdRemoveButton
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 20 Mar 2017 06:23:16 +0000 (07:23 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 20 Mar 2017 06:23:16 +0000 (07:23 +0100)
button/Button.js

index 15619a325309a3a0c56ee65c0de677c5dcca6a14..5a03be7a7391e1affed1cdba1707e12ecc4fd170 100644 (file)
@@ -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);
+           }
+       });
+    }
+});