diff options
author | 2020-05-11 16:19:00 +0200 | |
---|---|---|
committer | 2020-05-11 16:19:00 +0200 | |
commit | fa19dddd833a15109b5be939d45716d6707da3c8 (patch) | |
tree | 30e45aaf75caadf40c93fc51d31bc8027ed28030 /cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts | |
parent | 16ced660a671dea28fa56ffa860651d78ebb4501 (diff) |
Disable Filename in edit
enable editing an existing file
Issue-ID: CCSDK-2368
Issue-ID: CCSDK-2369
Signed-off-by: AhmedEldeeb50 <ahmed.eldeeb.ext@orange.com>
Change-Id: I214e9b9e1a7ee12edf1318610a4594e36ddbb393
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts | 39 |
1 files changed, 35 insertions, 4 deletions
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); |