mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-07-16 19:23:47 +00:00
ui: bandwidth limit selector: make it possible to allow zero
The initial value is '' and in getSubmitValue(), previously the branch if (v == 0 || v == 0.0) return null; was taken, because of the lax '==' comparision. Make sure we still return null for '' by explicitly checking for it. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
f8d1d5ad9a
commit
dcbc3b3ee9
@ -36,12 +36,16 @@ Ext.define('PVE.form.BandwidthField', {
|
|||||||
// for KiB set it to 'KiB'
|
// for KiB set it to 'KiB'
|
||||||
backendUnit: undefined,
|
backendUnit: undefined,
|
||||||
|
|
||||||
|
// allow setting 0 and using it as a submit value
|
||||||
|
allowZero: false,
|
||||||
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
xtype: 'numberfield',
|
xtype: 'numberfield',
|
||||||
cbind: {
|
cbind: {
|
||||||
name: '{name}',
|
name: '{name}',
|
||||||
emptyText: '{emptyText}',
|
emptyText: '{emptyText}',
|
||||||
|
allowZero: '{allowZero}',
|
||||||
},
|
},
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
step: 1,
|
step: 1,
|
||||||
@ -61,7 +65,9 @@ Ext.define('PVE.form.BandwidthField', {
|
|||||||
this._transformed = true;
|
this._transformed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v == 0) v = undefined;
|
if (Number(v) === 0 && !this.allowZero) {
|
||||||
|
v = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
return Ext.form.field.Text.prototype.setValue.call(this, v);
|
return Ext.form.field.Text.prototype.setValue.call(this, v);
|
||||||
},
|
},
|
||||||
@ -69,9 +75,13 @@ Ext.define('PVE.form.BandwidthField', {
|
|||||||
let v = this.processRawValue(this.getRawValue());
|
let v = this.processRawValue(this.getRawValue());
|
||||||
v = v.replace(this.decimalSeparator, '.');
|
v = v.replace(this.decimalSeparator, '.');
|
||||||
|
|
||||||
if (v === undefined) return null;
|
if (v === undefined || v === '') {
|
||||||
// FIXME: make it configurable, as this only works if 0 === default
|
return null;
|
||||||
if (v == 0 || v == 0.0) return null;
|
}
|
||||||
|
|
||||||
|
if (Number(v) === 0) {
|
||||||
|
return this.allowZero ? 0 : null;
|
||||||
|
}
|
||||||
|
|
||||||
let fieldct = this.up('pveBandwidthField');
|
let fieldct = this.up('pveBandwidthField');
|
||||||
let vm = fieldct.getViewModel();
|
let vm = fieldct.getViewModel();
|
||||||
|
Loading…
Reference in New Issue
Block a user