ui: traffic-control edit: move on-load set value logic to own method
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
77d8c593b3
commit
5d5a53059f
|
@ -425,16 +425,17 @@ Ext.define('PBS.window.TrafficControlEdit', {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
doSetValues: function(data) {
|
||||||
let me = this;
|
let me = this;
|
||||||
me.callParent();
|
|
||||||
if (!me.isCreate) {
|
// NOTE: it can make sense to have any-ip (::/0 and 0/0) and specific ones in the same set
|
||||||
me.load({
|
// so only check for "is default" when there really just two networks
|
||||||
success: function(response) {
|
if (data.network?.length === 2) {
|
||||||
let data = response.result.data;
|
let nets = [...new Set(data.network)]; // only the set of unique networks
|
||||||
if (data.network?.length === 2 && data.network[0] === '0.0.0.0/0' && data.network[1] === '::/0') {
|
if (nets.find(net => net === '0.0.0.0/0') && nets.find(net => net === '::/0')) {
|
||||||
delete data.network;
|
delete data.network;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Ext.isArray(data.timeframe)) {
|
if (Ext.isArray(data.timeframe)) {
|
||||||
data.timeframe = data.timeframe.join(';');
|
data.timeframe = data.timeframe.join(';');
|
||||||
|
@ -442,6 +443,15 @@ Ext.define('PBS.window.TrafficControlEdit', {
|
||||||
|
|
||||||
me.setValues(data);
|
me.setValues(data);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initComponent: function() {
|
||||||
|
let me = this;
|
||||||
|
|
||||||
|
me.callParent();
|
||||||
|
|
||||||
|
if (!me.isCreate) {
|
||||||
|
me.load({
|
||||||
|
success: ({ result: { data } }) => me.doSetValues(data),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue