luci-mod-network: remove related bridge-vlan sections on deleting device
authorJo-Philipp Wich <jo@mein.io>
Fri, 22 Oct 2021 17:17:42 +0000 (19:17 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 22 Oct 2021 18:37:28 +0000 (20:37 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 216767f420a92468b865a5ef301a1e94283dcb0e)

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

index 9a9282c0342507a9979824b475c5e0dc88edbd14..117be2c7c12ed3aae5a092efb5c33bc5a7422ac1 100644 (file)
@@ -1309,6 +1309,20 @@ return view.extend({
                        return form.GridSection.prototype.handleModalCancel.apply(this, arguments);
                };
 
+               s.handleRemove = function(section_id /*, ... */) {
+                       var name = uci.get('network', section_id, 'name'),
+                           type = uci.get('network', section_id, 'type');
+
+                       if (name != null && type == 'bridge') {
+                               uci.sections('network', 'bridge-vlan', function(bvs) {
+                                       if (bvs.device == name)
+                                               uci.remove('network', bvs['.name']);
+                               });
+                       }
+
+                       return form.GridSection.prototype.handleRemove.apply(this, arguments);
+               };
+
                function getDevice(section_id) {
                        var m = section_id.match(/^dev:(.+)$/),
                            name = m ? m[1] : uci.get('network', section_id, 'name');