aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts
blob: 9a0cdcdac02652865d5a277c7ffd6fa7bfb45139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {PackageCreationStore} from '../../package-creation.store';
import {Template} from '../../mapping-models/CBAPacakge.model';
import {TemplateInfo, TemplateStore} from '../../template.store';

@Component({
    selector: 'app-templ-mapp-listing',
    templateUrl: './templ-mapp-listing.component.html',
    styleUrls: ['./templ-mapp-listing.component.css']
})
export class TemplMappListingComponent implements OnInit {
    @Output() showCreationViewParentNotification = new EventEmitter<any>();
    private templates: Template;
    private sourceCodeEditorContnet: string;

    constructor(private packageCreationStore: PackageCreationStore, private templateStore: TemplateStore) {
    }

    ngOnInit() {
        this.packageCreationStore.state$.subscribe(cba => {
            if (cba.templates) {
                this.templates = cba.templates;
            }
        });
    }

    openCreationView() {
        this.showCreationViewParentNotification.emit('tell parent to open create views');
    }

    setSourceCodeEditor(key: string) {
        this.packageCreationStore.state$.subscribe(cba => {
            if (cba.templates) {
                const fileContent = cba.templates.getValue(key);
                const templateInfo = new TemplateInfo();
                templateInfo.fileContent = fileContent;
                templateInfo.fileName = key;
                this.templateStore.changeTemplateInfo(templateInfo);
            }
        });
    }
}