From e178834244609b4d96411b2107714d1d935c4ef4 Mon Sep 17 00:00:00 2001 From: Peter Piela Date: Mon, 31 Jul 2017 09:03:02 -0400 Subject: [PATCH] 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 --- .../ironic/base-port/base-port.controller.js | 5 ++-- .../base-portgroup.controller.js | 29 ++++++++++++------- .../create-port/create-port.controller.js | 4 +-- .../ironic/edit-port/edit-port.controller.js | 4 +-- .../edit-portgroup.controller.js | 4 +-- .../dashboard/admin/ironic/form-field.html | 2 +- .../admin/ironic/form-field.service.js | 27 +++++++++-------- 7 files changed, 43 insertions(+), 32 deletions(-) diff --git a/ironic_ui/static/dashboard/admin/ironic/base-port/base-port.controller.js b/ironic_ui/static/dashboard/admin/ironic/base-port/base-port.controller.js index 6944332c..4b0b0ced 100644 --- a/ironic_ui/static/dashboard/admin/ironic/base-port/base-port.controller.js +++ b/ironic_ui/static/dashboard/admin/ironic/base-port/base-port.controller.js @@ -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", diff --git a/ironic_ui/static/dashboard/admin/ironic/base-portgroup/base-portgroup.controller.js b/ironic_ui/static/dashboard/admin/ironic/base-portgroup/base-portgroup.controller.js index c0f0e293..ac5f16e8 100644 --- a/ironic_ui/static/dashboard/admin/ironic/base-portgroup/base-portgroup.controller.js +++ b/ironic_ui/static/dashboard/admin/ironic/base-portgroup/base-portgroup.controller.js @@ -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({ diff --git a/ironic_ui/static/dashboard/admin/ironic/create-port/create-port.controller.js b/ironic_ui/static/dashboard/admin/ironic/create-port/create-port.controller.js index 475c68d5..e1d35d52 100644 --- a/ironic_ui/static/dashboard/admin/ironic/create-port/create-port.controller.js +++ b/ironic_ui/static/dashboard/admin/ironic/create-port/create-port.controller.js @@ -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; diff --git a/ironic_ui/static/dashboard/admin/ironic/edit-port/edit-port.controller.js b/ironic_ui/static/dashboard/admin/ironic/edit-port/edit-port.controller.js index 487e60fe..6cafc0fd 100644 --- a/ironic_ui/static/dashboard/admin/ironic/edit-port/edit-port.controller.js +++ b/ironic_ui/static/dashboard/admin/ironic/edit-port/edit-port.controller.js @@ -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"); patcher.buildPatch(port.local_link_connection, ctrl.localLinkConnection.toPortAttr(), diff --git a/ironic_ui/static/dashboard/admin/ironic/edit-portgroup/edit-portgroup.controller.js b/ironic_ui/static/dashboard/admin/ironic/edit-portgroup/edit-portgroup.controller.js index 7b79f1b8..42c63689 100644 --- a/ironic_ui/static/dashboard/admin/ironic/edit-portgroup/edit-portgroup.controller.js +++ b/ironic_ui/static/dashboard/admin/ironic/edit-portgroup/edit-portgroup.controller.js @@ -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, diff --git a/ironic_ui/static/dashboard/admin/ironic/form-field.html b/ironic_ui/static/dashboard/admin/ironic/form-field.html index 0b49c90d..003fc4da 100644 --- a/ironic_ui/static/dashboard/admin/ironic/form-field.html +++ b/ironic_ui/static/dashboard/admin/ironic/form-field.html @@ -42,7 +42,7 @@ ng-model="field.value" ng-repeat="opt in field.options" ng-disabled="field.disabled" - uib-btn-radio="opt">{$ opt $} + uib-btn-radio="opt.value">{$ opt.label $}