summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/components/component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/models/components/component.ts')
-rw-r--r--catalog-ui/src/app/models/components/component.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts
index a0706b4157..1d48151be8 100644
--- a/catalog-ui/src/app/models/components/component.ts
+++ b/catalog-ui/src/app/models/components/component.ts
@@ -35,6 +35,7 @@ import {Requirement} from "../requirement";
import {Relationship} from "../graph/relationship";
import { PolicyInstance } from "app/models/graph/zones/policy-instance";
import { GroupInstance } from "../graph/zones/group-instance";
+import { Metadata } from "app/models/metadata";
// import {}
@@ -142,6 +143,7 @@ export abstract class Component implements IComponent {
public archived:boolean;
public vspArchived: boolean;
public componentMetadata: ComponentMetadata;
+ public categorySpecificMetadata: Metadata = new Metadata();
constructor(componentService:IComponentService, protected $q:ng.IQService, component?:Component) {
if (component) {
@@ -198,12 +200,36 @@ export abstract class Component implements IComponent {
this.policies = component.policies;
this.archived = component.archived;
this.vspArchived = component.vspArchived;
+
+ if (component.categorySpecificMetadata && component.categories && component.categories[0]){
+ this.copyCategoryMetadata(component);
+ this.copySubcategoryMetadata(component);
+ }
}
//custom properties
this.componentService = componentService;
}
+ private copyCategoryMetadata = (component:Component):void => {
+ if (component.categories[0].metadataKeys){
+ for (let key of Object.keys(component.categorySpecificMetadata)) {
+ if (component.categories[0].metadataKeys.some(metadataKey => metadataKey.name == key)) {
+ this.categorySpecificMetadata[key] = component.categorySpecificMetadata[key];
+ }
+ }
+ }
+ }
+ private copySubcategoryMetadata = (component:Component):void => {
+ if (component.categories[0].subcategories && component.categories[0].subcategories[0] && component.categories[0].subcategories[0].metadataKeys){
+ for (let key of Object.keys(component.categorySpecificMetadata)) {
+ if (component.categories[0].subcategories[0].metadataKeys.some(metadataKey => metadataKey.name == key)) {
+ this.categorySpecificMetadata[key] = component.categorySpecificMetadata[key];
+ }
+ }
+ }
+ }
+
public setUniqueId = (uniqueId:string):void => {
this.uniqueId = uniqueId;
};
@@ -543,6 +569,11 @@ export abstract class Component implements IComponent {
this.archived = componentMetadata.archived || false;
this.vspArchived = componentMetadata.vspArchived;
this.componentMetadata = componentMetadata;
+ if (componentMetadata.categorySpecificMetadata){
+ this.categorySpecificMetadata = componentMetadata.categorySpecificMetadata;
+ } else {
+ this.categorySpecificMetadata = new Metadata();
+ }
}
public toJSON = ():any => {