9a0cdcdac02652865d5a277c7ffd6fa7bfb45139
[ccsdk/cds.git] /
1 import {Component, EventEmitter, OnInit, Output} from '@angular/core';
2 import {PackageCreationStore} from '../../package-creation.store';
3 import {Template} from '../../mapping-models/CBAPacakge.model';
4 import {TemplateInfo, TemplateStore} from '../../template.store';
5
6 @Component({
7     selector: 'app-templ-mapp-listing',
8     templateUrl: './templ-mapp-listing.component.html',
9     styleUrls: ['./templ-mapp-listing.component.css']
10 })
11 export class TemplMappListingComponent implements OnInit {
12     @Output() showCreationViewParentNotification = new EventEmitter<any>();
13     private templates: Template;
14     private sourceCodeEditorContnet: string;
15
16     constructor(private packageCreationStore: PackageCreationStore, private templateStore: TemplateStore) {
17     }
18
19     ngOnInit() {
20         this.packageCreationStore.state$.subscribe(cba => {
21             if (cba.templates) {
22                 this.templates = cba.templates;
23             }
24         });
25     }
26
27     openCreationView() {
28         this.showCreationViewParentNotification.emit('tell parent to open create views');
29     }
30
31     setSourceCodeEditor(key: string) {
32         this.packageCreationStore.state$.subscribe(cba => {
33             if (cba.templates) {
34                 const fileContent = cba.templates.getValue(key);
35                 const templateInfo = new TemplateInfo();
36                 templateInfo.fileContent = fileContent;
37                 templateInfo.fileName = key;
38                 this.templateStore.changeTemplateInfo(templateInfo);
39             }
40         });
41     }
42 }