diff options
author | 2021-03-15 08:37:18 +0000 | |
---|---|---|
committer | 2021-03-17 12:07:40 +0000 | |
commit | a820979640eb7fa4346e0340ce4dd4a5f9e5feeb (patch) | |
tree | 91e3e7544a0c2b73bf4f59d1751f5b8cd634b643 /catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts | |
parent | fd07dec6fc32c6d20a5f6ca23587ec57fa2346aa (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/src/app/view-models/workspace/tabs/general/general-view-model.ts')
-rw-r--r-- | catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts | 14 |
1 files changed, 11 insertions, 3 deletions
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 => { |