diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-03-01 08:54:26 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-03-01 08:54:58 +0100 |
commit | 5d528da29f3b03deba0144c85d862e1e4468ff25 (patch) | |
tree | 150066fe55e01a51cd3b57c54079431ec1b791f3 /applications/luci-app-firewall/htdocs/luci-static/resources | |
parent | 49ecaf60902be2e43ccec3c61bc6b7d0b41da251 (diff) |
luci-app-firewall: fix creating multiple networks from zone network selector
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-firewall/htdocs/luci-static/resources')
-rw-r--r-- | applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js index 53612e0572..835d9eb759 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js @@ -178,19 +178,24 @@ return view.extend({ }; o.write = function(section_id, formvalue) { var name = uci.get('firewall', section_id, 'name'), - cfgvalue = this.cfgvalue(section_id); + cfgvalue = this.cfgvalue(section_id), + oldNetworks = L.toArray(cfgvalue), + newNetworks = L.toArray(formvalue); - if (typeof(cfgvalue) == 'string' && Array.isArray(formvalue) && (cfgvalue == formvalue.join(' '))) + oldNetworks.sort(); + newNetworks.sort(); + + if (oldNetworks.join(' ') == newNetworks.join(' ')) return; var tasks = [ firewall.getZone(name) ]; if (Array.isArray(formvalue)) - for (var i = 0; i < formvalue.length; i++) { - var netname = formvalue[i]; - tasks.push(network.getNetwork(netname).then(function(net) { + for (var i = 0; i < newNetworks.length; i++) { + var netname = newNetworks[i]; + tasks.push(network.getNetwork(netname).then(L.bind(function(netname, net) { return net || network.addNetwork(netname, { 'proto': 'none' }); - })); + }, this, netname))); } return Promise.all(tasks).then(function(zone_networks) { |