Merge "Enhanced form-field radio functionality"

This commit is contained in:
Jenkins 2017-09-19 16:44:42 +00:00 committed by Gerrit Code Review
commit 024307a563
7 changed files with 43 additions and 32 deletions

View File

@ -160,8 +160,9 @@
title: gettext("PXE enabled"),
desc: gettext(
"Indicates whether this port should be used when PXE booting this node"),
options: ['True', 'False'],
value: 'True'});
options: [{label: 'True', value: true},
{label: 'False', value: false}],
value: true});
ctrl.portgroup_uuid = new formFieldService.FormField({
type: "select",

View File

@ -59,22 +59,31 @@
id: "standalonePorts",
title: gettext("Standalone Ports Supported"),
desc: gettext(
"Specifies whether ports in this portgroup can be used as standalone ports."),
options: ['True', 'False'],
value: 'True'});
"Specifies whether ports in this portgroup can be used as standalone ports."), // eslint-disable-line max-len
options: [{label: 'True', value: true},
{label: 'False', value: false}],
value: true});
var modeOptions = function(modes) {
var options = [];
angular.forEach(modes, function(mode) {
options.push({label:mode, value: mode});
});
return options;
};
ctrl.mode = new formFieldService.FormField({
type: "radio",
id: "mode",
title: gettext("Mode"),
desc: gettext("Linux portgroup mode. For possible values refer to https://www.kernel.org/doc/Documentation/networking/bonding.txt"), // eslint-disable-line max-len
options: ['balance-rr',
'active-backup',
'balance-xor',
'broadcast',
'802.3ad',
'balance-tlb',
'balance-alb'],
options: modeOptions(['balance-rr',
'active-backup',
'balance-xor',
'broadcast',
'802.3ad',
'balance-tlb',
'balance-alb']),
value: 'active-backup'});
ctrl.properties = new propertyCollectionService.PropertyCollection({

View File

@ -65,9 +65,7 @@
port.local_link_connection = attr;
}
if (ctrl.pxeEnabled.value !== 'True') {
port.pxe_enabled = ctrl.pxeEnabled.value;
}
port.pxe_enabled = ctrl.pxeEnabled.value;
if (ctrl.portgroup_uuid.value !== null) {
port.portgroup_uuid = ctrl.portgroup_uuid.value;

View File

@ -71,7 +71,7 @@
ctrl.address.disable();
}
ctrl.pxeEnabled.value = port.pxe_enabled ? 'True' : 'False';
ctrl.pxeEnabled.value = port.pxe_enabled;
ctrl.portgroup_uuid.value = port.portgroup_uuid;
@ -105,7 +105,7 @@
patcher.buildPatch(port.address, ctrl.address.value, "/address");
patcher.buildPatch(port.pxe_enabled,
ctrl.pxeEnabled.value === 'True',
ctrl.pxeEnabled.value,
"/pxe_enabled");
var attr = ctrl.localLinkConnection.toPortAttr();
if (attr) {

View File

@ -54,7 +54,7 @@
ctrl.name.value = portgroup.name;
ctrl.standalone_ports_supported.value =
portgroup.standalone_ports_supported ? 'True' : 'False';
portgroup.standalone_ports_supported;
ctrl.mode.value = portgroup.mode;
@ -75,7 +75,7 @@
patcher.buildPatch(portgroup.address, ctrl.address.value, "/address");
patcher.buildPatch(portgroup.name, ctrl.name.value, "/name");
patcher.buildPatch(portgroup.standalone_ports_supported,
ctrl.standalone_ports_supported.value === 'True',
ctrl.standalone_ports_supported.value,
"/standalone_ports_supported");
patcher.buildPatch(portgroup.mode,
ctrl.mode.value,

View File

@ -42,7 +42,7 @@
ng-model="field.value"
ng-repeat="opt in field.options"
ng-disabled="field.disabled"
uib-btn-radio="opt">{$ opt $}</label>
uib-btn-radio="opt.value">{$ opt.label $}</label>
</div>
<div ng-switch-when="select">
<select id="field.id"

View File

@ -30,27 +30,30 @@
* @description Utility class for managing form fields.
* Used is association with the form-field directive.
*
* @param {object} args - Base properties are:
* @param {object} args - Base properties are:
* type [string] - Field type. One of: 'input', 'radio', 'select'
* id [string] - id/name of the DOM value element
* title [string] - Label used to identify the field to the user
* options - type == radio [array]:
* List of options for a radio field
* options - type == radio [array of object]:
* List of option objects for a radio field.
* Each object has 'label' and 'value'
* properties.
* type == select [string]:
* String expression that is passed to ng-options
* String expression that is passed to ng-options
* value - Initial value of the field
* required [boolean] - Does the field require a value
* desc [string] - Field description
* pattern [RegExp] - Regular expression pattern used to match
* valid input values
* valid input values
* disabled [boolean] - Is the field disabled
* info [string] - Additional information about the current state of
* the field. It will be displayed in a tooltip
* associated with the field.
* autoFocus [boolean] - True if the focus should be set to this field. Only
* applies to fields of type input.
* change [string] - Expression to be evaluated when the value of this
* field changes. Only applies to fields of type input.
* info [string] - Additional information about the current state
* of the field. It will be displayed in a tooltip
* associated with the field.
* autoFocus [boolean] - True if the focus should be set to this field.
* Only applies to fields of type input.
* change [string] - Expression to be evaluated when the value of
* this field changes. Only applies to fields of
* type input.
*
* @return {void}
*/