resizable: false,
- // use this to atimatically generate a title like `Create: <subject>`
+ // use this to automatically generate a title like `Create: <subject>`
subject: undefined,
// set isCreate to true if you want a Create button (instead OK and RESET)
// 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,
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() {
initComponent: function() {
let me = this;
- if (!me.url) {
- throw "no url specified";
+ if (!me.url && (
+ !me.submitUrl || !me.loadUrl || me.submitUrl === Ext.identityFn ||
+ me.loadUrl === Ext.identityFn
+ )
+ ) {
+ 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];
me.items = undefined;
me.formPanel = Ext.create('Ext.form.Panel', {
- url: me.url,
+ url: me.url, // FIXME: not in 'form' class, safe to remove??
method: me.method || 'PUT',
trackResetOnLoad: true,
bodyPadding: me.bodyPadding !== undefined ? me.bodyPadding : 10,
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) {
if (!allAdvancedValid) {
inputPanel.setAdvancedVisible(true);
- me.down('#advancedcb').setValue(true);
}
}
};
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];
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;