From fa19dddd833a15109b5be939d45716d6707da3c8 Mon Sep 17 00:00:00 2001 From: AhmedEldeeb50 Date: Mon, 11 May 2020 16:19:00 +0200 Subject: Disable Filename in edit enable editing an existing file Issue-ID: CCSDK-2368 Issue-ID: CCSDK-2369 Signed-off-by: AhmedEldeeb50 Change-Id: I214e9b9e1a7ee12edf1318610a4594e36ddbb393 --- .../templ-mapp-creation.component.ts | 39 +++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts index 4601880f8..5129b38d9 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts @@ -9,6 +9,8 @@ import { Mapping, MappingAdapter } from '../../mapping-models/mappingAdapter.mod import { PackageCreationUtils } from '../../package-creation.utils'; import { JsonConvert, Any } from 'json2typescript'; import { ToastrService } from 'ngx-toastr'; +import { Router, ActivatedRoute } from '@angular/router'; +import { SharedService } from '../shared-service'; @Component({ selector: 'app-templ-mapp-creation', @@ -43,19 +45,27 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { mappingRes = []; currentTemplate: any; currentMapping: any; + edit = false; constructor( private packageCreationStore: PackageCreationStore, private templateStore: TemplateStore, private packageCreationUtils: PackageCreationUtils, - private toastr: ToastrService + private toastr: ToastrService, + private router: ActivatedRoute, + private sharedService: SharedService ) { } ngOnInit() { + if (this.router.snapshot.paramMap.has('id')) { + console.log('URL contains Id'); + this.sharedService.enableEdit(); + } + this.templateStore.state$.subscribe(templateInfo => { // init Template&mapping vars - console.log('----------'); + console.log('Oninit'); console.log(templateInfo); this.templateInfo = templateInfo; this.fileName = templateInfo.fileName.split('/')[1]; @@ -82,6 +92,22 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { }); + this.sharedService.isEdit().subscribe(res => { + console.log('------------------------'); + console.log(res); + this.edit = res; + + if (!this.edit) { + console.log('remove ----'); + this.currentMapping = {}; + this.currentTemplate = {}; + this.fileName = ''; + this.templateFileContent = ''; + this.resourceDictionaryRes = []; + this.mappingRes = []; + } + }); + this.dtOptions = { pagingType: 'full_numbers', pageLength: 25, @@ -259,12 +285,17 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { this.mappingRes = []; this.currentMapping = {}; this.currentTemplate = {}; + this.closeCreationForm(); } saveToStore() { if (this.fileName) { // check file duplication - if (!(this.packageCreationStore.fileExist('Templates/' + this.fileName + '-mapping.json') - || this.packageCreationStore.fileExist('Templates/' + this.fileName + '-template' + this.getFileExtension()))) { + console.log('----------- mode ' + this.edit); + if ( + (!(this.packageCreationStore.fileExist('Templates/' + this.fileName + '-mapping.json') + || this.packageCreationStore.fileExist('Templates/' + this.fileName + '-template' + this.getFileExtension()))) + || this.edit + ) { // Save Mapping to Store if (this.resourceDictionaryRes && this.resourceDictionaryRes.length > 0) { const mapArray = this.convertDictionaryToMap(this.resourceDictionaryRes); -- cgit 1.2.3-korg