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:44:05 +0000 (21:44 +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]>
(cherry picked from commit d356e30ac13cc1648045d8a0bcb5dd92630778f4)

applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js

index b727f4e79826c78fa8059de1575de43337cc29f5..ea40ed68317ced8df889c948dfd36ea95087dd4c 100644 (file)
@@ -191,19 +191,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'));