summaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/dsl-definitions-tab/dsl-definitions-tab.component.ts
blob: b2f2693b64ea2d0cfb75e4d875a7a7ab87e31375 (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
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {DslDefinition} from '../mapping-models/CBAPacakge.model';
import {PackageCreationStore} from '../package-creation.store';

@Component({
    selector: 'app-dsl-definitions-tab',
    templateUrl: './dsl-definitions-tab.component.html',
    styleUrls: ['./dsl-definitions-tab.component.css']
})
export class DslDefinitionsTabComponent implements OnInit {

    dslDefinition: DslDefinition = new DslDefinition();
    @Output() changeEvent = new EventEmitter<string>();
    lang = 'json';

    constructor(private packageCreationStore: PackageCreationStore) {
    }

    ngOnInit() {
        this.packageCreationStore.state$.subscribe(cbaPackage => {
            if (cbaPackage && cbaPackage.definitions && cbaPackage.definitions.dslDefinition) {
                this.dslDefinition.content = cbaPackage.definitions.dslDefinition.content;
            }
        });

    }

    textChanged(event) {
        this.packageCreationStore.changeDslDefinition(this.dslDefinition);
    }

    callParent(): void {
        this.changeEvent.next('some changes to enable save ');
    }

    onPaste($event: ClipboardEvent) {
        this.callParent();
    }
}