X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2Fwindow%2FEdit.js;h=573c24c3e629fac4fd52d97b206728348161c0da;hb=3637defc27995da4ba329669769830ca698198aa;hp=e952362ae9b2a84466d82529ec2fb99bc3648fc6;hpb=8969bdadf6b397b6d255626178615d47aa039b21;p=proxmox-widget-toolkit.git diff --git a/src/window/Edit.js b/src/window/Edit.js index e952362..573c24c 100644 --- a/src/window/Edit.js +++ b/src/window/Edit.js @@ -13,7 +13,7 @@ Ext.define('Proxmox.window.Edit', { resizable: false, - // use this to atimatically generate a title like `Create: ` + // use this to automatically generate a title like `Create: ` subject: undefined, // set isCreate to true if you want a Create button (instead OK and RESET) @@ -22,9 +22,12 @@ Ext.define('Proxmox.window.Edit', { // set to true if you want an Add button (instead of Create) isAdd: false, - // set to true if you want an Remove button (instead of Create) + // set to true if you want a Remove button (instead of Create) isRemove: false, + // set to false, if you don't want the reset button present + showReset: true, + // custom submitText submitText: undefined, @@ -219,16 +222,14 @@ Ext.define('Proxmox.window.Edit', { method: 'GET', success: function(response, opts) { form.clearInvalid(); - me.digest = response.result.digest || response.result.data.digest; + me.digest = response.result?.digest || response.result?.data?.digest; if (successFn) { successFn(response, opts); } else { me.setValues(response.result.data); } // hack: fix ExtJS bug - Ext.Array.each(me.query('radiofield'), function(f) { - f.resetOriginalValue(); - }); + Ext.Array.each(me.query('radiofield'), f => f.resetOriginalValue()); }, failure: function(response, opts) { Ext.Msg.alert(gettext('Error'), response.htmlStatus, function() { @@ -253,8 +254,9 @@ Ext.define('Proxmox.window.Edit', { ) { throw "neither 'url' nor both, submitUrl and loadUrl specified"; } - - if (me.create) {throw "deprecated parameter, use isCreate";} + if (me.create) { + throw "deprecated parameter, use isCreate"; + } let items = Ext.isArray(me.items) ? me.items : [me.items]; @@ -319,8 +321,7 @@ Ext.define('Proxmox.window.Edit', { resetBtn.setDisabled(!dirty); if (inputPanel && inputPanel.hasAdvanced) { - // we want to show the advanced options - // as soon as some of it is not valid + // we want to show the advanced options as soon as some of it is not valid let advancedItems = me.down('#advancedContainer').query('field'); let allAdvancedValid = true; advancedItems.forEach(function(field) { @@ -331,7 +332,6 @@ Ext.define('Proxmox.window.Edit', { if (!allAdvancedValid) { inputPanel.setAdvancedVisible(true); - me.down('#advancedcb').setValue(true); } } }; @@ -350,7 +350,7 @@ Ext.define('Proxmox.window.Edit', { me.title = Proxmox.Utils.dialog_title(me.subject, me.isCreate, me.isAdd); } - if (me.isCreate) { + if (me.isCreate || !me.showReset) { me.buttons = [submitBtn]; } else { me.buttons = [submitBtn, resetBtn]; @@ -360,22 +360,20 @@ Ext.define('Proxmox.window.Edit', { let sp = Ext.state.Manager.getProvider(); let advchecked = sp.get('proxmox-advanced-cb'); inputPanel.setAdvancedVisible(advchecked); - me.buttons.unshift( - { - xtype: 'proxmoxcheckbox', - itemId: 'advancedcb', - boxLabelAlign: 'before', - boxLabel: gettext('Advanced'), - stateId: 'proxmox-advanced-cb', - value: advchecked, - listeners: { - change: function(cb, val) { - inputPanel.setAdvancedVisible(val); - sp.set('proxmox-advanced-cb', val); - }, - }, - }, - ); + me.buttons.unshift({ + xtype: 'proxmoxcheckbox', + itemId: 'advancedcb', + boxLabelAlign: 'before', + boxLabel: gettext('Advanced'), + stateId: 'proxmox-advanced-cb', + value: advchecked, + listeners: { + change: function(cb, val) { + inputPanel.setAdvancedVisible(val); + sp.set('proxmox-advanced-cb', val); + }, + }, + }); } let onlineHelp = me.onlineHelp;