]>
Commit | Line | Data |
---|---|---|
32f469f3 EK |
1 | /* Popup a message window |
2 | * where the user has to manually enter the ressource ID | |
3 | * to enable the destroy button | |
4 | */ | |
5 | Ext.define('PVE.window.SafeDestroy', { | |
6 | extend: 'Ext.window.Window', | |
7 | alias: 'widget.pveSafeDestroy', | |
bcecf280 | 8 | |
16152937 | 9 | title: gettext('Confirm'), |
32f469f3 EK |
10 | modal: true, |
11 | buttonAlign: 'center', | |
bcecf280 DM |
12 | bodyPadding: 10, |
13 | width: 450, | |
14 | layout: 'hbox', | |
15 | ||
16 | viewModel: { type: 'default' }, | |
17 | ||
18 | config: { | |
19 | item: { | |
20 | id: undefined, | |
21 | type: undefined | |
22 | }, | |
23 | url: undefined | |
24 | }, | |
25 | ||
26 | applyItem: function(item) { | |
27 | var me = this; | |
28 | ||
29 | if (!Ext.isDefined(item.id)) { | |
30 | throw "no ID specified"; | |
31 | } | |
32 | ||
33 | if (!Ext.isDefined(item.type)) { | |
34 | throw "no VM type specified"; | |
35 | } | |
36 | ||
37 | me.getViewModel().set('item', item); | |
38 | ||
39 | return item; | |
40 | }, | |
41 | ||
42 | controller: { | |
43 | ||
44 | xclass: 'Ext.app.ViewController', | |
45 | ||
46 | control: { | |
47 | 'field[name=confirm]': { | |
48 | change: function(f, value) { | |
49 | var view = this.getView(); | |
50 | var removeButton = this.lookupReference('removeButton'); | |
51 | if (value === view.getItem().id) { | |
52 | removeButton.enable(); | |
53 | } else { | |
54 | removeButton.disable(); | |
55 | } | |
56 | } | |
57 | }, | |
7667066d | 58 | 'button[reference=removeButton]': { |
bcecf280 DM |
59 | click: function() { |
60 | var view = this.getView(); | |
61 | PVE.Utils.API2Request({ | |
62 | url: view.getUrl(), | |
63 | method: 'DELETE', | |
64 | waitMsgTarget: view, | |
65 | failure: function(response, opts) { | |
66 | Ext.Msg.alert('Error', response.htmlStatus); | |
67 | }, | |
68 | callback: function() { | |
69 | view.close(); | |
70 | } | |
71 | }); | |
72 | } | |
73 | } | |
74 | } | |
75 | }, | |
32f469f3 EK |
76 | |
77 | items: [ | |
fd8a2eea | 78 | { |
bcecf280 DM |
79 | xtype: 'component', |
80 | cls: [ Ext.baseCSSPrefix + 'message-box-icon', | |
81 | Ext.baseCSSPrefix + 'message-box-warning', | |
82 | Ext.baseCSSPrefix + 'dlg-icon'], | |
83 | }, | |
84 | { | |
fd8a2eea | 85 | xtype: 'container', |
bcecf280 | 86 | flex: 1, |
fd8a2eea DM |
87 | layout: { |
88 | type: 'vbox', | |
89 | align: 'stretch' | |
90 | }, | |
91 | items: [ | |
92 | { | |
bcecf280 | 93 | xtype: 'component', |
16152937 DM |
94 | bind: gettext('Are you sure you want to remove {item.type} {item.id}?') + ' ' + |
95 | gettext('This will permanently erase all data.') | |
fd8a2eea | 96 | }, |
32f469f3 | 97 | { |
bcecf280 | 98 | reference: 'confirmField', |
fd8a2eea | 99 | xtype: 'numberfield', |
bcecf280 DM |
100 | name: 'confirm', |
101 | labelWidth: 300, | |
102 | bind: { | |
103 | fieldLabel: gettext('Please enter the {item.type} ID to confirm'), | |
104 | }, | |
105 | hideTrigger: true, | |
106 | allowBlank: false | |
32f469f3 | 107 | } |
bcecf280 | 108 | ], |
fd8a2eea DM |
109 | } |
110 | ], | |
32f469f3 EK |
111 | buttons: [ |
112 | { | |
bcecf280 | 113 | reference: 'removeButton', |
32f469f3 | 114 | text: gettext('Remove'), |
bcecf280 | 115 | disabled: true |
32f469f3 | 116 | } |
bcecf280 | 117 | ] |
fd8a2eea | 118 | }); |