summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-firewall/htdocs/luci-static/resources
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-07-21 11:12:13 +0200
committerJo-Philipp Wich <jo@mein.io>2019-07-21 22:35:24 +0200
commit0be4ad51a0bea3e1e3e6cd7d646e11ec6c722540 (patch)
tree70b5fcaab0ae1b2a2651e420dfd2cd424ad4d05c /applications/luci-app-firewall/htdocs/luci-static/resources
parentca94c7805c2edd4ac29f27b16d8bee6ae09eb1d0 (diff)
luci-app-firewall: fix cbi form for rules
- Set src/dest defaults only in initial section create state, otherwise it is impossible to specify output rules - Get rid of dest_remote/dest_local widget switching and implement change logic directly in tools.widgets.CBIZoneSelect - Remove leftover debug code Ref: https://github.com/openwrt/luci/issues/2889 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-firewall/htdocs/luci-static/resources')
-rw-r--r--applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js40
1 files changed, 23 insertions, 17 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 e67397268..4252cf369 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
@@ -144,6 +144,27 @@ return L.view.extend({
return uci.get('firewall', section_id, 'name') || _('Unnamed rule');
};
+ 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.default = 'wan';
+ opt2.default = 'lan';
+
+ this.addedSection = section_id;
+ this.renderMoreOptionsModal(section_id);
+
+ delete opt1.default;
+ delete opt2.default;
+ };
+
o = s.taboption('general', form.Value, 'name', _('Name'));
o.placeholder = _('Unnamed rule');
o.modalonly = true;
@@ -243,7 +264,6 @@ return L.view.extend({
o.nocreate = true;
o.allowany = true;
o.allowlocal = 'src';
- o.default = 'wan';
o = s.taboption('advanced', form.Value, 'src_mac', _('Source MAC address'));
o.modalonly = true;
@@ -276,22 +296,11 @@ return L.view.extend({
o.depends('proto', 'tcp udp');
o.depends('proto', 'tcpudp');
- o = s.taboption('general', widgets.ZoneSelect, 'dest_local', _('Output zone'));
- o.modalonly = true;
- o.nocreate = true;
- o.allowany = true;
- o.alias = 'dest';
- o.default = 'wan';
- o.depends('src', '');
-
- o = s.taboption('general', widgets.ZoneSelect, 'dest_remote', _('Destination zone'));
+ o = s.taboption('general', widgets.ZoneSelect, 'dest', _('Destination zone'));
o.modalonly = true;
o.nocreate = true;
o.allowany = true;
o.allowlocal = true;
- o.alias = 'dest';
- o.default = 'lan';
- o.depends({'src': '', '!reverse': true});
o = s.taboption('general', form.Value, 'dest_ip', _('Destination address'));
o.modalonly = true;
@@ -366,9 +375,6 @@ return L.view.extend({
o.modalonly = true;
o.default = o.disabled;
- return m.render().catch(function(e) {
- console.debug('render fail')
- });
-
+ return m.render();
}
});