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 = {},
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, {
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;
+ },
});