aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui
diff options
context:
space:
mode:
authordavsad <david.sadlier@est.tech>2021-03-15 08:37:18 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-17 12:07:40 +0000
commita820979640eb7fa4346e0340ce4dd4a5f9e5feeb (patch)
tree91e3e7544a0c2b73bf4f59d1751f5b8cd634b643 /catalog-ui
parentfd07dec6fc32c6d20a5f6ca23587ec57fa2346aa (diff)
Support default value for category specific metadata
Issue-ID: SDC-3513 Signed-off-by: davsad <david.sadlier@est.tech> Change-Id: I4697b66c6d59c1464cf81f9c68fe76b6ca24472c
Diffstat (limited to 'catalog-ui')
-rw-r--r--catalog-ui/src/app/models/category.ts3
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts14
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html24
3 files changed, 28 insertions, 13 deletions
diff --git a/catalog-ui/src/app/models/category.ts b/catalog-ui/src/app/models/category.ts
index 64588d0c44..2c1bc217e5 100644
--- a/catalog-ui/src/app/models/category.ts
+++ b/catalog-ui/src/app/models/category.ts
@@ -50,6 +50,7 @@ export interface IGroup extends ICategoryBase {
export interface IMetadataKey {
name:string;
- mandatory:boolean
+ mandatory:boolean;
validValues: string[];
+ defaultValue: string;
}
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
index 54caa42317..1065404eef 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
@@ -634,14 +634,14 @@ export class GeneralViewModel {
if (this.$scope.component.categories[0].metadataKeys) {
for (let metadataKey of this.$scope.component.categories[0].metadataKeys) {
if (!this.$scope.component.categorySpecificMetadata[metadataKey.name]) {
- this.$scope.component.categorySpecificMetadata[metadataKey.name] = "";
+ this.$scope.component.categorySpecificMetadata[metadataKey.name] = metadataKey.defaultValue ? metadataKey.defaultValue : "";
}
}
}
if (this.$scope.component.categories[0].subcategories && this.$scope.component.categories[0].subcategories[0].metadataKeys) {
for (let metadataKey of this.$scope.component.categories[0].subcategories[0].metadataKeys) {
if (!this.$scope.component.categorySpecificMetadata[metadataKey.name]) {
- this.$scope.component.categorySpecificMetadata[metadataKey.name] = "";
+ this.$scope.component.categorySpecificMetadata[metadataKey.name] = metadataKey.defaultValue ? metadataKey.defaultValue : "";
}
}
}
@@ -678,9 +678,17 @@ export class GeneralViewModel {
return this.getMetadataKey(this.$scope.component.categories, key) != null;
}
- this.$scope.isCategoryServiceMetadataKey = (key: string): boolean => {
+ this.$scope.isCategoryServiceMetadataKey = (key: string): boolean => {
return this.isServiceMetadataKey(key);
}
+
+ this.$scope.isMetadataKeyForComponentCategoryService = (key: string, attribute: string): boolean => {
+ let metadatakey = this.getMetadataKey(this.$scope.component.categories, key);
+ if (metadatakey && (!this.$scope.component[attribute] || !metadatakey.validValues.find(v => v === this.$scope.component[attribute]))) {
+ this.$scope.component[attribute] = metadatakey.defaultValue;
+ }
+ return metadatakey != null;
+ }
}
private setUnsavedChanges = (hasChanges: boolean): void => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
index cb661f73fc..40300c8021 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
@@ -375,12 +375,12 @@
<!--------------------- NAMING POLICY -------------------->
<div ng-if="component.isService()" class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.namingPolicy)}">
- <div ng-if="component.selectedCategory && isMetadataKeyForComponentCategory('Naming Policy')">
+ <div ng-if="component.selectedCategory && isMetadataKeyForComponentCategoryService('Naming Policy', 'namingPolicy')">
<div ng-if="isMetadataKeyMandatory('Naming Policy')">
<label class="i-sdc-form-label required">Naming Policy</label>
</div>
<div ng-if="!isMetadataKeyMandatory('Naming Policy')">
- <label class="i-sdc-form-label" translate="GENERAL_TAB_LABEL_NAMING_POLICY"></label>
+ <label class="i-sdc-form-label">Naming Policy</label>
</div>
<select class="i-sdc-form-input" type="text"
ng-required="isMetadataKeyMandatory('Naming Policy')"
@@ -420,7 +420,7 @@
<div ng-if="component.isService()"
class="i-sdc-form-item"
data-ng-class="{'error': validateField(editForm.serviceFunctionType)}">
- <div ng-if="component.selectedCategory && isMetadataKeyForComponentCategory('Service Type')">
+ <div ng-if="component.selectedCategory && isMetadataKeyForComponentCategoryService('Service Type', 'serviceType')">
<div ng-if="isMetadataKeyMandatory('Service Type')">
<label class="i-sdc-form-label required" translate="GENERAL_TAB_LABEL_SERVICE_TYPE"></label>
</div>
@@ -462,7 +462,7 @@
<div ng-if="component.isService()"
class="i-sdc-form-item"
data-ng-class="{'error': validateField(editForm.serviceRole)}">
- <div ng-if="component.selectedCategory && isMetadataKeyForComponentCategory('Service Role')">
+ <div ng-if="component.selectedCategory && isMetadataKeyForComponentCategoryService('Service Role', 'serviceRole')">
<div ng-if="isMetadataKeyMandatory('Service Role')">
<label class="i-sdc-form-label required" translate="GENERAL_TAB_LABEL_SERVICE_ROLE"></label>
</div>
@@ -502,10 +502,15 @@
<div ng-if="component.isService()"
class="i-sdc-form-item"
data-ng-class="{'error': validateField(editForm.serviceFunction)}">
- <label class="i-sdc-form-label required" translate="GENERAL_TAB_LABEL_SERVICE_FUNCTION"></label>
- <div ng-if="component.selectedCategory && isMetadataKeyForComponentCategory('Service Function')">
+ <div ng-if="component.selectedCategory && isMetadataKeyForComponentCategoryService('Service Function', 'serviceFunction')">
+ <div ng-if="isMetadataKeyMandatory('Service Function')">
+ <label class="i-sdc-form-label required" translate="GENERAL_TAB_LABEL_SERVICE_FUNCTION"></label>
+ </div>
+ <div ng-if="!isMetadataKeyMandatory('Service Function')">
+ <label class="i-sdc-form-label" translate="GENERAL_TAB_LABEL_SERVICE_FUNCTION"></label>
+ </div>
<select class="i-sdc-form-input" type="text"
- data-required
+ ng-required="isMetadataKeyMandatory('Service Function')"
data-ng-class="{'view-mode': isViewMode()}"
data-ng-model="component.serviceFunction"
data-ng-model-options="{ debounce: 500 }"
@@ -517,13 +522,14 @@
</select>
</div>
<div ng-if="!component.selectedCategory || !isMetadataKeyForComponentCategory('Service Function')">
+ <label class="i-sdc-form-label" translate="GENERAL_TAB_LABEL_SERVICE_FUNCTION"></label>
<input class="i-sdc-form-input" type="text"
data-ng-class="{'view-mode': isViewMode()}"
data-ng-model="component.serviceFunction"
name="serviceFunction"
data-tests-id="serviceFunction"
- data-ng-maxlength="256"
- data-ng-pattern="validation.ServiceTypeAndRoleValidationPattern"
+ data-ng-maxlength="256"
+ data-ng-pattern="validation.ServiceTypeAndRoleValidationPattern"
/>
</div>
<div class="input-error" data-ng-show="validateField(editForm.serviceFunction)">