summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatiana Ovchinnikova <t.v.ovtchinnikova@gmail.com>2021-09-30 16:20:44 -0500
committerGaƫl THEROND <gael.therond@bitswalk.com>2022-07-26 07:54:10 +0000
commitd329996a929b6a03d7429a0ea7f2b05041f1714a (patch)
tree1a31d9b1bcbfb7b265ba1507fda0284204a73a8d
parentc9ebeb1fa3de5ead102fef2027c8e5320c3038e1 (diff)
downloadhorizon-d329996a929b6a03d7429a0ea7f2b05041f1714a.tar.gz
Make existing empty metadata properties optional
Editing of snapshot image or updating its metadata from Horizon is not allowed until existing properties with empty values are set or removed from metadata tree. They are allowed to be None, therefore Horizon should consider them optional too. Closes-Bug: #1945706 Change-Id: Idfec71d209430c7d069133a40ca1a7d340163783 (cherry picked from commit 4e0f5a5a85467ca83743e6e8126cd570f329afb9)
-rw-r--r--horizon/static/framework/widgets/metadata/tree/metadata-tree-item.html2
-rw-r--r--horizon/static/framework/widgets/metadata/tree/tree.service.js6
2 files changed, 7 insertions, 1 deletions
diff --git a/horizon/static/framework/widgets/metadata/tree/metadata-tree-item.html b/horizon/static/framework/widgets/metadata/tree/metadata-tree-item.html
index 6a30a2125..9f278aa39 100644
--- a/horizon/static/framework/widgets/metadata/tree/metadata-tree-item.html
+++ b/horizon/static/framework/widgets/metadata/tree/metadata-tree-item.html
@@ -13,7 +13,7 @@
type="text"
class="form-control"
ng-pattern="ctrl.item.leaf.pattern"
- required
+ ng-required="ctrl.item.leaf.required"
ng-model="ctrl.item.leaf.value"
ng-minlength="{$ ::ctrl.item.leaf.minLength $}"
ng-maxlength="{$ ::ctrl.item.leaf.maxLength $}"
diff --git a/horizon/static/framework/widgets/metadata/tree/tree.service.js b/horizon/static/framework/widgets/metadata/tree/tree.service.js
index c4d86d87e..1256985f5 100644
--- a/horizon/static/framework/widgets/metadata/tree/tree.service.js
+++ b/horizon/static/framework/widgets/metadata/tree/tree.service.js
@@ -56,6 +56,7 @@
this.default = null;
this.type = 'string';
this.readonly = false;
+ this.required = true;
this.operators = ['<in>'];
angular.extend(this, json);
this.operator = this.operators[0];
@@ -73,6 +74,11 @@
return;
}
+ // if the existing property has empty string value, make the field not required
+ if (value === '') {
+ this.required = false;
+ }
+
switch (this.type) {
case 'integer':
this.value = parseInt(value, 10);