luci-app-firewall: simplify some form actions 4307/head
authorJo-Philipp Wich <jo@mein.io>
Thu, 6 Aug 2020 19:22:18 +0000 (21:22 +0200)
committerJo-Philipp Wich <jo@mein.io>
Mon, 15 Mar 2021 10:41:50 +0000 (11:41 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js
applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js

index 7c09eeadf6e41a725a7f7dd240749dd30d59bdce..df49dcf80c71ea8af135015aa800846f68bd7ceb 100644 (file)
@@ -193,13 +193,8 @@ return view.extend({
                s.handleAdd = function(ev) {
                        var config_name = this.uciconfig || this.map.config,
                            section_id = uci.add(config_name, this.sectiontype),
-                           opt1, opt2;
-
-                       for (var i = 0; i < this.children.length; i++)
-                               if (this.children[i].option == 'src')
-                                       opt1 = this.children[i];
-                               else if (this.children[i].option == 'dest')
-                                       opt2 = this.children[i];
+                           opt1 = this.getOption('src'),
+                           opt2 = this.getOption('dest');
 
                        opt1.default = 'wan';
                        opt2.default = 'lan';
index 1d6e01c1a8385946913994d2699eb7599188ffa5..ce65fc78392d6419f744a8df757382b45667cf7b 100644 (file)
@@ -217,9 +217,8 @@ return view.extend({
                o.placeholder = null;
                o.depends('target', 'SNAT');
                o.validate = function(section_id, value) {
-                       var port = this.map.lookupOption('snat_port', section_id),
-                           a = this.formvalue(section_id),
-                           p = port ? port[0].formvalue(section_id) : null;
+                       var a = this.formvalue(section_id),
+                           p = this.section.formvalue(section_id, 'snat_port');
 
                        if ((a == null || a == '') && (p == null || p == '') && value == '')
                                return _('A rewrite IP must be specified!');