- 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';
- 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';
- import { of } from 'rxjs';
+ 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';
+ 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({
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 => {
}
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);
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');
}
this.templateStore.changeTemplateInfo(templateInfo);
this.openCreationView();
- this.sharedService.enableEdit();
+ if (templateInfo.fileName && templateInfo.fileName.length > 0) {
+ this.sharedService.enableEdit();
+ }
});
}
getValue(file: string) {
return this.templateAndMappingMap.get(file);
}
+
initDelete(file) {
console.log(file);
const templateKey = 'Templates/' + file + '-template';
}
}
+
condifrmDelete() {
const file = this.fileToDelete.split('/')[1].split('-')[0];
const ext = this.fileToDelete.split('/')[1].split('.')[1];