summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-07-07 19:08:03 +0200
committerJo-Philipp Wich <jo@mein.io>2019-07-07 19:12:59 +0200
commitf8e6caf5525b802dfbaf150ca3d64f92620b2d50 (patch)
tree86ef1524b302c40f2962fb8eebd6b5806ece6dbd /modules/luci-base/htdocs/luci-static/resources
parent1fad6c0eed398b1dd594dcf43cbc4013be7c396e (diff)
luci-base: widgets.js: add textvalude representation for network select
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/tools/widgets.js60
1 files changed, 44 insertions, 16 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js b/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js
index b1917eb356..669689449f 100644
--- a/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js
+++ b/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js
@@ -241,6 +241,25 @@ var CBINetworkSelect = form.ListValue.extend({
return true;
},
+ renderIfaceBadge: function(network) {
+ var span = E('span', { 'class': 'ifacebadge' }, network.getName() + ': '),
+ devices = network.isBridge() ? network.getDevices() : toArray(network.getDevice());
+
+ for (var j = 0; j < devices.length && devices[j]; j++) {
+ span.appendChild(E('img', {
+ 'title': devices[j].getI18n(),
+ 'src': L.resource('icons/%s%s.png'.format(devices[j].getType(), devices[j].isUp() ? '' : '_disabled'))
+ }));
+ }
+
+ if (!devices.length) {
+ span.appendChild(E('em', { 'class': 'hide-close' }, _('(no interfaces attached)')));
+ span.appendChild(E('em', { 'class': 'hide-open' }, '-'));
+ }
+
+ return span;
+ },
+
renderWidget: function(section_id, option_index, cfgvalue) {
var values = toArray((cfgvalue != null) ? cfgvalue : this.default),
choices = {},
@@ -264,25 +283,10 @@ var CBINetworkSelect = form.ListValue.extend({
if (this.novirtual && network.isVirtual())
continue;
- var span = E('span', { 'class': 'ifacebadge' }, network.getName() + ': '),
- devices = network.isBridge() ? network.getDevices() : toArray(network.getDevice());
-
- for (var j = 0; j < devices.length && devices[j]; j++) {
- span.appendChild(E('img', {
- 'title': devices[j].getI18n(),
- 'src': L.resource('icons/%s%s.png'.format(devices[j].getType(), devices[j].isUp() ? '' : '_disabled'))
- }));
- }
-
- if (!devices.length) {
- span.appendChild(E('em', { 'class': 'hide-close' }, _('(no interfaces attached)')));
- span.appendChild(E('em', { 'class': 'hide-open' }, '-'));
- }
-
if (checked[name])
values.push(name);
- choices[name] = span;
+ choices[name] = this.renderIfaceBadge(network);
}
var widget = new ui.Dropdown(this.multiple ? values : values[0], choices, {
@@ -305,6 +309,30 @@ var CBINetworkSelect = form.ListValue.extend({
return widget.render();
},
+
+ textvalue: function(section_id) {
+ var cfgvalue = this.cfgvalue(section_id),
+ values = toArray((cfgvalue != null) ? cfgvalue : this.default),
+ rv = E([]);
+
+ for (var i = 0; i < (this.networks || []).length; i++) {
+ var network = this.networks[i],
+ name = network.getName();
+
+ if (values.indexOf(name) == -1)
+ continue;
+
+ if (rv.length)
+ L.dom.append(rv, ' ');
+
+ L.dom.append(rv, this.renderIfaceBadge(network));
+ }
+
+ if (!rv.firstChild)
+ rv.appendChild(E('em', _('unspecified')));
+
+ return rv;
+ },
});