From a30ca193aeb59db058c42faff3f422428a982635 Mon Sep 17 00:00:00 2001 From: Peter Piela Date: Wed, 17 May 2017 11:35:07 -0400 Subject: [PATCH] Fixed node form submission issue A node definition is not considered valid for submission if it contains a user added property that does not have a value. The code that monitors this condition had gotten out of sync with other recent updates in this area. Change-Id: Iec6afa68977b52c1742b3c1bbc29be0123caff5f --- .../ironic/base-node/base-node.controller.js | 41 ++++++++++++++++++- .../admin/ironic/base-node/base-node.html | 9 ++-- .../ironic/edit-node/edit-node.controller.js | 8 ++-- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.controller.js b/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.controller.js index 28a02317..f5e4d269 100644 --- a/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.controller.js +++ b/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.controller.js @@ -57,14 +57,26 @@ - adding new properties - displaying the list of properties in the set - changing the value of properties + + Collection attributes: + id: Name of the property inside the node object that is used + to store the collection. + formId: Name of the controller variable that can be used to + access the property collection form. + prompt: Label used to prompt the user to add properties + to the collection. + placeholder: Label used to guide the user in providiing property + values. */ ctrl.propertyCollections = [ {id: "properties", + formId: "properties_form", title: gettext("Properties"), addPrompt: gettext("Add Property"), placeholder: gettext("Property Name") }, {id: "extra", + formId: "extra_form", title: gettext("Extras"), addPrompt: gettext("Add Extra"), placeholder: gettext("Extra Property Name") @@ -75,11 +87,13 @@ name: null, driver: null, driver_info: {}, - properties: {}, - extra: {}, network_interface: null }; + angular.forEach(ctrl.propertyCollections, function(collection) { + ctrl.node[collection.id] = {}; + }); + /** * @description Get the list of currently active Ironic drivers * @@ -297,5 +311,28 @@ ctrl.isDriverPropertyActive = function(property) { return property.isActive(); }; + + /** + * @description Check whether the node definition form is ready for + * to be submitted. + * + * @return {boolean} True if the form is ready to be submitted, + * otherwise false. + */ + ctrl.readyToSubmit = function() { + var ready = true; + if (ctrl.driverProperties) { + for (var i = 0; i < ctrl.propertyCollections.length; i++) { + var collection = ctrl.propertyCollections[i]; + if (ctrl[collection.formId].$invalid) { + ready = false; + break; + } + } + } else { + ready = false; + } + return ready; + }; } })(); diff --git a/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.html b/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.html index a5b04f08..34daabd0 100644 --- a/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.html +++ b/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.html @@ -125,8 +125,8 @@ -
+
@@ -253,10 +253,7 @@