luci-mod-network: reset bridge VLANs on cancelling modal dialog
authorJo-Philipp Wich <jo@mein.io>
Sat, 12 Jun 2021 20:54:51 +0000 (22:54 +0200)
committerJo-Philipp Wich <jo@mein.io>
Sat, 12 Jun 2021 20:55:38 +0000 (22:55 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit bb3269945c7f189e1d1de1e7979d79d30a860b03)

modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js
modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

index 67aecf262cad267d399f548efc9f190e393c5a80..8ba259e2c949eb7f8e4a1f134cd19e96796d9933 100644 (file)
@@ -922,6 +922,9 @@ return baseclass.extend({
 
                                s.getOption('vlan_filtering').updateDefaultValue(s.section);
 
+                               s.map.addedVLANs = s.map.addedVLANs || [];
+                               s.map.addedVLANs.push(section_id);
+
                                return this.redraw();
                        }, this));
                };
index 7e9eadf788f77db81afff0f2de8f2d418387cb1d..694d43141fd32aef7a3d4208d11bec50ccdc6059 100644 (file)
@@ -1302,7 +1302,7 @@ return view.extend({
                        nettools.addDeviceOptions(s, dev, isNew);
                };
 
-               s.handleModalCancel = function(/* ... */) {
+               s.handleModalCancel = function(map /*, ... */) {
                        var name = uci.get('network', this.addedSection, 'name')
 
                        uci.sections('network', 'bridge-vlan', function(bvs) {
@@ -1310,6 +1310,10 @@ return view.extend({
                                        uci.remove('network', bvs['.name']);
                        });
 
+                       if (map.addedVLANs)
+                               for (var i = 0; i < map.addedVLANs.length; i++)
+                                       uci.remove('network', map.addedVLANs[i]);
+
                        return form.GridSection.prototype.handleModalCancel.apply(this, arguments);
                };