af6ced092572836d5f6207779e0814defe0a895a
[ccsdk/cds.git] /
1 import { Component, OnInit } from '@angular/core';
2 import { ActivatedRoute } from '@angular/router';
3 import { PackageCreationStore } from '../package-creation.store';
4 import { SharedService } from './shared-service';
5
6 @Component({
7     selector: 'app-template-mapping',
8     templateUrl: './template-mapping.component.html',
9     styleUrls: ['./template-mapping.component.css']
10 })
11 export class TemplateMappingComponent implements OnInit {
12     creationView = false;
13     listView = true;
14
15     constructor(
16         private route: ActivatedRoute,
17         private pakcageStore: PackageCreationStore,
18         private sharedService: SharedService
19     ) {
20     }
21
22     ngOnInit() {
23
24         if (this.route.snapshot.paramMap.has('id')) {
25             console.log('Edit mode');
26             this.creationView = true;
27             this.listView = false;
28             console.log('URL contains Id');
29             this.sharedService.enableEdit();
30             if (this.pakcageStore.state.mapping.files.size > 0 || this.pakcageStore.state.templates.files.size > 0) {
31                 this.openListView();
32             }
33         } else {
34             console.log('Create mode');
35             this.pakcageStore.clear();
36             this.sharedService.disableEdit();
37         }
38     }
39     openCreationView() {
40         this.creationView = false;
41         this.listView = true;
42     }
43
44     openListView() {
45         this.listView = false;
46         this.creationView = false;
47     }
48
49     closeCreationView() {
50         this.creationView = true;
51         this.listView = false;
52     }
53
54 }