]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - src/window/SafeDestroy.js
1 /* Popup a message window
2 * where the user has to manually enter the resource ID
3 * to enable the destroy button
5 Ext
.define('Proxmox.window.SafeDestroy', {
6 extend
: 'Ext.window.Window',
7 alias
: 'widget.proxmoxSafeDestroy',
9 title
: gettext('Confirm'),
11 buttonAlign
: 'center',
14 layout
: { type
: 'hbox' },
15 defaultFocus
: 'confirmField',
20 // gets called if we have a progress bar or taskview and it detected that
21 // the task finished. function(success)
22 taskDone
: Ext
.emptyFn
,
24 // gets called when the api call is finished, right at the beginning
25 // function(success, response, options)
26 apiCallDone
: Ext
.emptyFn
,
38 getParams: function() {
41 if (Ext
.Object
.isEmpty(me
.params
)) {
44 return '?' + Ext
.Object
.toQueryString(me
.params
);
49 xclass
: 'Ext.app.ViewController',
52 'field[name=confirm]': {
53 change: function(f
, value
) {
54 const view
= this.getView();
55 const removeButton
= this.lookupReference('removeButton');
56 if (value
=== view
.getItem().id
.toString()) {
57 removeButton
.enable();
59 removeButton
.disable();
62 specialkey: function(field
, event
) {
63 const removeButton
= this.lookupReference('removeButton');
64 if (!removeButton
.isDisabled() && event
.getKey() === event
.ENTER
) {
65 removeButton
.fireEvent('click', removeButton
, event
);
69 'button[reference=removeButton]': {
71 const view
= this.getView();
72 Proxmox
.Utils
.API2Request({
73 url
: view
.getUrl() + view
.getParams(),
76 failure: function(response
, opts
) {
77 view
.apiCallDone(false, response
, opts
);
79 Ext
.Msg
.alert('Error', response
.htmlStatus
);
81 success: function(response
, options
) {
82 const hasProgressBar
= !!(view
.showProgress
&&
83 response
.result
.data
);
85 view
.apiCallDone(true, response
, options
);
88 // stay around so we can trigger our close events
89 // when background action is completed
92 const upid
= response
.result
.data
;
93 const win
= Ext
.create('Proxmox.window.TaskProgress', {
95 taskDone
: view
.taskDone
,
115 reference
: 'removeButton',
116 text
: gettext('Remove'),
121 initComponent: function() {
127 cls
: [Ext
.baseCSSPrefix
+ 'message-box-icon',
128 Ext
.baseCSSPrefix
+ 'message-box-warning',
129 Ext
.baseCSSPrefix
+ 'dlg-icon'],
141 reference
: 'messageCmp',
144 itemId
: 'confirmField',
145 reference
: 'confirmField',
153 .concat(me
.additionalItems
)
157 reference
: 'noteContainer',
168 reference
: 'noteCmp',
170 style
: 'font-size: smaller; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;',
180 const itemId
= me
.getItem().id
;
181 if (!Ext
.isDefined(itemId
)) {
182 throw "no ID specified";
185 if (Ext
.isDefined(me
.getNote())) {
186 me
.lookupReference('noteCmp').setHtml(`<span title="${me.getNote()}">${me.getNote()}</span>`);
187 const noteContainer
= me
.lookupReference('noteContainer');
188 noteContainer
.setHidden(false);
189 noteContainer
.setDisabled(false);
192 let taskName
= me
.getTaskName();
193 if (Ext
.isDefined(taskName
)) {
194 me
.lookupReference('messageCmp').setHtml(
195 Proxmox
.Utils
.format_task_description(taskName
, itemId
),
198 throw "no task name specified";
201 me
.lookupReference('confirmField')
202 .setFieldLabel(`${gettext('Please enter the ID to confirm')} (${itemId})`);