From 581fa4aecf0fde50290852a1c820a85ff8840257 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Mon, 31 Mar 2025 21:41:11 +0200 Subject: [PATCH] luci-app-firewall: repair handleAdd for rules.js 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 (cherry picked from commit d356e30ac13cc1648045d8a0bcb5dd92630778f4) --- .../luci-static/resources/view/firewall/rules.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js index b727f4e798..ea40ed6831 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js @@ -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')); -- 2.30.2