summaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts')
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts73
1 files changed, 54 insertions, 19 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts
index 70e35939b..3a05bcfc5 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts
@@ -1,4 +1,4 @@
-import { Component, EventEmitter, OnInit, Output } from '@angular/core';
+import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
import { PackageCreationStore } from '../../package-creation.store';
import { Mapping, Template } from '../../mapping-models/CBAPacakge.model';
import { TemplateInfo, TemplateStore } from '../../template.store';
@@ -6,6 +6,7 @@ import { TemplateAndMapping } from '../TemplateAndMapping';
import { ActivatedRoute } from '@angular/router';
import { SharedService } from '../shared-service';
import { TourService } from 'ngx-tour-md-menu';
+import { TemplateType } from '../utils/TemplateType';
@Component({
@@ -13,7 +14,7 @@ import { TourService } from 'ngx-tour-md-menu';
templateUrl: './templ-mapp-listing.component.html',
styleUrls: ['./templ-mapp-listing.component.css']
})
-export class TemplMappListingComponent implements OnInit {
+export class TemplMappListingComponent implements OnInit, OnDestroy {
@Output() showCreationView = new EventEmitter<any>();
@Output() showListView = new EventEmitter<any>();
templateAndMappingMap = new Map<string, TemplateAndMapping>();
@@ -22,7 +23,7 @@ export class TemplMappListingComponent implements OnInit {
isCreate = true;
currentFile: string;
edit = false;
- fileToDelete: any = {};
+ fileToDelete = '';
constructor(
private packageCreationStore: PackageCreationStore,
@@ -30,11 +31,17 @@ export class TemplMappListingComponent implements OnInit {
private route: ActivatedRoute,
private sharedService: SharedService,
private tourService: TourService,
-
) {
}
+ ngOnDestroy(): void {
+ // this.templateStore.unsubscribe();
+ // this.packageCreationStore.unsubscribe();
+ }
+
ngOnInit() {
+ this.templateAndMappingMap = new Map<string, TemplateAndMapping>();
+ this.edit = false;
if (this.route.snapshot.paramMap.has('id')) {
this.isCreate = false;
this.sharedService.isEdit().subscribe(res => {
@@ -73,7 +80,9 @@ export class TemplMappListingComponent implements OnInit {
}
private setIsMappingOrTemplate(key: string, templateAndMapping: TemplateAndMapping, isFromTemplate: boolean) {
- const nameOfFile = key.split('/')[1].split('.')[0].split('-')[0];
+ const nameOfFile = isFromTemplate ?
+ key.split('/')[1].split('.')[0].split('-template')[0]
+ : key.split('/')[1].split('.')[0].split('-mapping')[0];
// const fullName = nameOfFile + ',' + key.split('.');
if (this.templateAndMappingMap.has(nameOfFile)) {
const templateAndMappingExisted = this.templateAndMappingMap.get(nameOfFile);
@@ -102,12 +111,16 @@ export class TemplMappListingComponent implements OnInit {
createNewTemplate() {
this.openCreationView();
this.sharedService.disableEdit();
- this.tourService.goto('tm-templateName');
+ if (localStorage.getItem('tour-guide') !== 'end' && localStorage.getItem('tour-guide') !== 'false') {
+ this.tourService.goto('tm-templateName');
+ }
}
+
openCreationView() {
this.showCreationView.emit('tell parent to open create views');
console.log('disable edit mode');
}
+
openListView() {
console.log('open list view');
this.showListView.emit('show full view');
@@ -115,19 +128,25 @@ export class TemplMappListingComponent implements OnInit {
setSourceCodeEditor(key: string) {
this.currentFile = key;
- const templateKey = 'Templates/' + key + '-template.vtl';
+ const templateKey = 'Templates/' + key + '-template';
this.packageCreationStore.state$.subscribe(cba => {
console.log('cba ------');
console.log(cba);
console.log(key);
console.log(this.templateAndMappingMap);
const templateInfo = new TemplateInfo();
- if (cba.templates && cba.templates.files.has(templateKey)) {
- const fileContent = cba.templates.getValue(templateKey.trim());
- console.log(fileContent);
- templateInfo.fileContent = fileContent;
- templateInfo.fileName = templateKey;
- templateInfo.type = 'template';
+ // tslint:disable-next-line: forin
+ for (const templateType in TemplateType) {
+ const fileName = templateKey + '.' + TemplateType[templateType];
+ if (cba.templates && cba.templates.files.has(fileName)) {
+ const fileContent = cba.templates.getValue(fileName.trim());
+ console.log(templateType + '......ccccccc.... ' + fileName);
+ templateInfo.fileContent = fileContent;
+ templateInfo.fileName = fileName;
+ templateInfo.ext = TemplateType[templateType];
+ templateInfo.type = 'template';
+ break;
+ }
}
const mappingKey = 'Templates/' + key + '-mapping.json';
if (cba.mapping && cba.mapping.files.has(mappingKey)) {
@@ -138,7 +157,9 @@ export class TemplMappListingComponent implements OnInit {
}
this.templateStore.changeTemplateInfo(templateInfo);
this.openCreationView();
- this.sharedService.enableEdit();
+ if (templateInfo.fileName && templateInfo.fileName.length > 0) {
+ this.sharedService.enableEdit();
+ }
});
}
@@ -149,20 +170,34 @@ export class TemplMappListingComponent implements OnInit {
getValue(file: string) {
return this.templateAndMappingMap.get(file);
}
+
initDelete(file) {
console.log(file);
- this.fileToDelete = file;
+ const templateKey = 'Templates/' + file + '-template';
+ // tslint:disable-next-line: forin
+ for (const templateType in TemplateType) {
+ const fileName = templateKey + '.' + TemplateType[templateType];
+ if (this.packageCreationStore.state.templates.files.has(fileName)) {
+ this.fileToDelete = fileName;
+ break;
+ }
+ }
+
}
+
condifrmDelete() {
- console.log(this.templateAndMappingMap);
- this.templateAndMappingMap.delete(this.fileToDelete);
+ const fullName = this.fileToDelete.split('/')[1];
+ const file = fullName.substr(0, fullName.lastIndexOf('-'));
+ const ext = fullName.substr(fullName.lastIndexOf('.') + 1);
+ this.templateAndMappingMap.delete(file);
if (this.templateAndMappingMap.size <= 0) {
this.openCreationView();
}
// Delete from templates
- this.packageCreationStore.state.templates.files.delete('Templates/' + this.fileToDelete + '-template.vtl');
+ this.packageCreationStore.state.templates.files.delete('Templates/' + file + '-template.' + ext);
// Delete from Mapping
- this.packageCreationStore.state.mapping.files.delete('Templates/' + this.fileToDelete + '-mapping.json');
+ this.packageCreationStore.state.mapping.files.delete('Templates/' + file + '-mapping.json');
+ console.log(this.templateAndMappingMap);
}