Enhanced form-field radio functionality
The form-field radio button functionality has been extended to support separate specification of button label and value. Previously, a single value was used for both items. Change-Id: Id050c47f5fff9e10f4191e03b43ad4fb414ddf2f
This commit is contained in:
parent
d56e262bff
commit
e178834244
@ -160,8 +160,9 @@
|
|||||||
title: gettext("PXE enabled"),
|
title: gettext("PXE enabled"),
|
||||||
desc: gettext(
|
desc: gettext(
|
||||||
"Indicates whether this port should be used when PXE booting this node"),
|
"Indicates whether this port should be used when PXE booting this node"),
|
||||||
options: ['True', 'False'],
|
options: [{label: 'True', value: true},
|
||||||
value: 'True'});
|
{label: 'False', value: false}],
|
||||||
|
value: true});
|
||||||
|
|
||||||
ctrl.portgroup_uuid = new formFieldService.FormField({
|
ctrl.portgroup_uuid = new formFieldService.FormField({
|
||||||
type: "select",
|
type: "select",
|
||||||
|
@ -59,22 +59,31 @@
|
|||||||
id: "standalonePorts",
|
id: "standalonePorts",
|
||||||
title: gettext("Standalone Ports Supported"),
|
title: gettext("Standalone Ports Supported"),
|
||||||
desc: gettext(
|
desc: gettext(
|
||||||
"Specifies whether ports in this portgroup can be used as standalone ports."),
|
"Specifies whether ports in this portgroup can be used as standalone ports."), // eslint-disable-line max-len
|
||||||
options: ['True', 'False'],
|
options: [{label: 'True', value: 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({
|
ctrl.mode = new formFieldService.FormField({
|
||||||
type: "radio",
|
type: "radio",
|
||||||
id: "mode",
|
id: "mode",
|
||||||
title: gettext("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
|
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',
|
options: modeOptions(['balance-rr',
|
||||||
'active-backup',
|
'active-backup',
|
||||||
'balance-xor',
|
'balance-xor',
|
||||||
'broadcast',
|
'broadcast',
|
||||||
'802.3ad',
|
'802.3ad',
|
||||||
'balance-tlb',
|
'balance-tlb',
|
||||||
'balance-alb'],
|
'balance-alb']),
|
||||||
value: 'active-backup'});
|
value: 'active-backup'});
|
||||||
|
|
||||||
ctrl.properties = new propertyCollectionService.PropertyCollection({
|
ctrl.properties = new propertyCollectionService.PropertyCollection({
|
||||||
|
@ -65,9 +65,7 @@
|
|||||||
port.local_link_connection = attr;
|
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) {
|
if (ctrl.portgroup_uuid.value !== null) {
|
||||||
port.portgroup_uuid = ctrl.portgroup_uuid.value;
|
port.portgroup_uuid = ctrl.portgroup_uuid.value;
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
ctrl.address.disable();
|
ctrl.address.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrl.pxeEnabled.value = port.pxe_enabled ? 'True' : 'False';
|
ctrl.pxeEnabled.value = port.pxe_enabled;
|
||||||
|
|
||||||
ctrl.portgroup_uuid.value = port.portgroup_uuid;
|
ctrl.portgroup_uuid.value = port.portgroup_uuid;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@
|
|||||||
|
|
||||||
patcher.buildPatch(port.address, ctrl.address.value, "/address");
|
patcher.buildPatch(port.address, ctrl.address.value, "/address");
|
||||||
patcher.buildPatch(port.pxe_enabled,
|
patcher.buildPatch(port.pxe_enabled,
|
||||||
ctrl.pxeEnabled.value === 'True',
|
ctrl.pxeEnabled.value,
|
||||||
"/pxe_enabled");
|
"/pxe_enabled");
|
||||||
patcher.buildPatch(port.local_link_connection,
|
patcher.buildPatch(port.local_link_connection,
|
||||||
ctrl.localLinkConnection.toPortAttr(),
|
ctrl.localLinkConnection.toPortAttr(),
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
ctrl.name.value = portgroup.name;
|
ctrl.name.value = portgroup.name;
|
||||||
|
|
||||||
ctrl.standalone_ports_supported.value =
|
ctrl.standalone_ports_supported.value =
|
||||||
portgroup.standalone_ports_supported ? 'True' : 'False';
|
portgroup.standalone_ports_supported;
|
||||||
|
|
||||||
ctrl.mode.value = portgroup.mode;
|
ctrl.mode.value = portgroup.mode;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@
|
|||||||
patcher.buildPatch(portgroup.address, ctrl.address.value, "/address");
|
patcher.buildPatch(portgroup.address, ctrl.address.value, "/address");
|
||||||
patcher.buildPatch(portgroup.name, ctrl.name.value, "/name");
|
patcher.buildPatch(portgroup.name, ctrl.name.value, "/name");
|
||||||
patcher.buildPatch(portgroup.standalone_ports_supported,
|
patcher.buildPatch(portgroup.standalone_ports_supported,
|
||||||
ctrl.standalone_ports_supported.value === 'True',
|
ctrl.standalone_ports_supported.value,
|
||||||
"/standalone_ports_supported");
|
"/standalone_ports_supported");
|
||||||
patcher.buildPatch(portgroup.mode,
|
patcher.buildPatch(portgroup.mode,
|
||||||
ctrl.mode.value,
|
ctrl.mode.value,
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
ng-model="field.value"
|
ng-model="field.value"
|
||||||
ng-repeat="opt in field.options"
|
ng-repeat="opt in field.options"
|
||||||
ng-disabled="field.disabled"
|
ng-disabled="field.disabled"
|
||||||
uib-btn-radio="opt">{$ opt $}</label>
|
uib-btn-radio="opt.value">{$ opt.label $}</label>
|
||||||
</div>
|
</div>
|
||||||
<div ng-switch-when="select">
|
<div ng-switch-when="select">
|
||||||
<select id="field.id"
|
<select id="field.id"
|
||||||
|
@ -30,27 +30,30 @@
|
|||||||
* @description Utility class for managing form fields.
|
* @description Utility class for managing form fields.
|
||||||
* Used is association with the form-field directive.
|
* 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'
|
* type [string] - Field type. One of: 'input', 'radio', 'select'
|
||||||
* id [string] - id/name of the DOM value element
|
* id [string] - id/name of the DOM value element
|
||||||
* title [string] - Label used to identify the field to the user
|
* title [string] - Label used to identify the field to the user
|
||||||
* options - type == radio [array]:
|
* options - type == radio [array of object]:
|
||||||
* List of options for a radio field
|
* List of option objects for a radio field.
|
||||||
|
* Each object has 'label' and 'value'
|
||||||
|
* properties.
|
||||||
* type == select [string]:
|
* 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
|
* value - Initial value of the field
|
||||||
* required [boolean] - Does the field require a value
|
* required [boolean] - Does the field require a value
|
||||||
* desc [string] - Field description
|
* desc [string] - Field description
|
||||||
* pattern [RegExp] - Regular expression pattern used to match
|
* pattern [RegExp] - Regular expression pattern used to match
|
||||||
* valid input values
|
* valid input values
|
||||||
* disabled [boolean] - Is the field disabled
|
* disabled [boolean] - Is the field disabled
|
||||||
* info [string] - Additional information about the current state of
|
* info [string] - Additional information about the current state
|
||||||
* the field. It will be displayed in a tooltip
|
* of the field. It will be displayed in a tooltip
|
||||||
* associated with the field.
|
* associated with the field.
|
||||||
* autoFocus [boolean] - True if the focus should be set to this field. Only
|
* autoFocus [boolean] - True if the focus should be set to this field.
|
||||||
* applies to fields of type input.
|
* Only applies to fields of type input.
|
||||||
* change [string] - Expression to be evaluated when the value of this
|
* change [string] - Expression to be evaluated when the value of
|
||||||
* field changes. Only applies to fields of type input.
|
* this field changes. Only applies to fields of
|
||||||
|
* type input.
|
||||||
*
|
*
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user