]>
Commit | Line | Data |
---|---|---|
591efb67 TL |
1 | Ext.define('PVE.button.PendingRevert', { |
2 | extend: 'Proxmox.button.Button', | |
3 | alias: 'widget.pvePendingRevertButton', | |
4 | ||
5 | text: gettext('Revert'), | |
6 | disabled: true, | |
7 | config: { | |
8 | pendingGrid: null, | |
3ee15859 | 9 | apiurl: undefined, |
591efb67 TL |
10 | }, |
11 | ||
12 | handler: function() { | |
417f904f TL |
13 | if (!this.pendingGrid) { |
14 | this.pendingGrid = this.up('proxmoxPendingObjectGrid'); | |
15 | if (!this.pendingGrid) throw "revert button requires a pendingGrid"; | |
16 | } | |
591efb67 TL |
17 | let view = this.pendingGrid; |
18 | ||
19 | let rec = view.getSelectionModel().getSelection()[0]; | |
20 | if (!rec) return; | |
21 | ||
22 | let rowdef = view.rows[rec.data.key] || {}; | |
23 | let keys = rowdef.multiKey || [ rec.data.key ]; | |
24 | ||
25 | Proxmox.Utils.API2Request({ | |
3ee15859 | 26 | url: this.apiurl || view.editorConfig.url, |
591efb67 TL |
27 | waitMsgTarget: view, |
28 | selModel: view.getSelectionModel(), | |
29 | method: 'PUT', | |
30 | params: { | |
f6710aac | 31 | 'revert': keys.join(','), |
591efb67 TL |
32 | }, |
33 | callback: () => view.reload(), | |
34 | failure: (response) => Ext.Msg.alert('Error', response.htmlStatus), | |
35 | }); | |
36 | }, | |
591efb67 | 37 | }); |