luci-app-firewall: repair handleAdd for rules.js
authorPaul Donald <[email protected]>
Mon, 31 Mar 2025 19:41:11 +0000 (21:41 +0200)
committerPaul Donald <[email protected]>
Mon, 31 Mar 2025 19:41:11 +0000 (21:41 +0200)
handleAdd did not work correctly for a while: the defaults were not
propagated, and some state was not cleaned up (try:
firewall rules -> add -> no changes -> click dismiss -> press save).

The state is now properly removed when pressing dismiss, by stashing
addedSection correctly under the map m and not in this.

Signed-off-by: Paul Donald <[email protected]>
applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js

index c4383f268f3e5668f7cbed1dd49911359501761e..95b91b54459a870c9d0b21f668f3c3be0e1ae665 100644 (file)
@@ -192,19 +192,14 @@ return view.extend({
                };
 
                s.handleAdd = function(ev) {
-                       var config_name = this.uciconfig || this.map.config,
-                           section_id = uci.add(config_name, this.sectiontype),
-                           opt1 = this.getOption('src'),
-                           opt2 = this.getOption('dest');
+                       const config_name = this.uciconfig || this.map.config;
+                       const section_id = uci.add(config_name, this.sectiontype);
 
-                       opt1.default = 'wan';
-                       opt2.default = 'lan';
+                       uci.set(config_name, section_id, 'src', 'wan');
+                       uci.set(config_name, section_id, 'dest', 'lan');
 
-                       this.addedSection = section_id;
+                       m.addedSection = section_id;
                        this.renderMoreOptionsModal(section_id);
-
-                       delete opt1.default;
-                       delete opt2.default;
                };
 
                o = s.taboption('general', form.Value, 'name', _('Name'));