caeac83f1b6bce6b4a7a0f0fca47aec68f829c89
[ccsdk/cds.git] / cds-ui / designer-client / src / app / modules / feature-modules / resource-dictionary / resource-dictionary-creation / dictionary-metadata / dictionary-metadata.component.ts
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : CDS
4 * ================================================================================
5 * Copyright (C) 2020 TechMahindra
6 *=================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *     http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20 import { Component, OnInit } from '@angular/core';
21 import { ActivatedRoute } from '@angular/router';
22 import { DictionaryModel } from '../../model/dictionary.model';
23 import { DictionaryCreationService } from '../dictionary-creation.service';
24 import { DictionaryCreationStore } from '../dictionary-creation.store';
25 import { MetaData } from '../../model/metaData.model';
26
27 @Component({
28     selector: 'app-dictionary-metadata',
29     templateUrl: './dictionary-metadata.component.html',
30     styleUrls: ['./dictionary-metadata.component.css']
31 })
32 export class DictionaryMetadataComponent implements OnInit {
33     packageNameAndVersionEnables = true;
34     counter = 0;
35     tags = new Set<string>();
36     metaDataTab: MetaData = new MetaData();
37     errorMessage: string;
38
39     constructor(
40         private route: ActivatedRoute,
41         private dictionaryCreationService: DictionaryCreationService,
42         private dictionaryCreationStore: DictionaryCreationStore
43     ) { }
44
45     ngOnInit() {
46         this.dictionaryCreationStore.state$.subscribe(element => {
47             if (element && element.metaData) {
48                 this.metaDataTab.name = element.metaData.name;
49                 this.metaDataTab.description = element.metaData.description;
50                 this.metaDataTab.dataType = element.metaData.dataType;
51                 this.metaDataTab.tags = element.metaData.tags;
52                 this.metaDataTab.entrySchema = element.metaData.entrySchema;
53                 this.metaDataTab.required = element.metaData.required;
54                 this.metaDataTab.libraryInstance = element.metaData.libraryInstance;
55                 this.metaDataTab.derivedFrom = element.metaData.derivedFrom;
56                 console.log(element);
57             }
58         });
59         console.log(this.metaDataTab.name);
60     }
61
62     removeTag(value) {
63         this.tags.delete(value);
64     }
65
66     addTag(event) {
67         const value = event.target.value;
68         console.log(value);
69         if (value && value.trim().length > 0) {
70             event.target.value = '';
71             this.tags.add(value);
72         }
73     }
74
75     saveMetaDataToStore() {
76         console.log(this.metaDataTab);
77      //   this.dictionaryCreationStore.changeMetaData(this.metaDataTab);
78     }
79 }