From 97403898893c3940898fdeb370c84caf4c589e8f Mon Sep 17 00:00:00 2001 From: Ahmedeldeeb50 Date: Sun, 27 Sep 2020 17:01:38 +0200 Subject: Mapping Table Editing Issue-ID: CCSDK-2795 Signed-off-by: Ahmedeldeeb50 Change-Id: I66d98801e66b32e335487cc159c623c5d11f1549 --- .../templ-mapp-creation.component.html | 22 +++++--- .../templ-mapp-creation.component.ts | 66 +++++++++++++++++++++- 2 files changed, 78 insertions(+), 10 deletions(-) (limited to 'cds-ui/designer-client/src/app/modules/feature-modules') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html index dfd8c31a8..4566f34d7 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html @@ -9,8 +9,8 @@ class="btn btn-outline-danger" title="Delete Template">Delete - +
@@ -31,8 +31,8 @@
- @@ -59,7 +59,8 @@ Jinja -
Use the editor to add parameters or you can also - Import + Import File.
When you import new file, the new attributes will replace current attributes.
@@ -86,8 +86,9 @@
- @@ -127,6 +128,7 @@ + @@ -139,6 +141,8 @@ +
Required Parameter Name Dictionary Name
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 78449fba9..94fa3db99 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 @@ -54,6 +54,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { edit = false; fileToDelete: any = {}; parserFactory = new ParserFactory(); + selectedProps = new Set(); constructor( private packageCreationStore: PackageCreationStore, @@ -88,7 +89,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { this.resourceDictionaryRes = []; } this.templateFileContent = templateInfo.fileContent; - this.templateExt = this.templateInfo.ext || this.templateExt ; + this.templateExt = this.templateInfo.ext || this.templateExt; this.currentTemplate = Object.assign({}, templateInfo); if (templateInfo.type === 'template' || templateInfo.type.includes('template')) { @@ -101,6 +102,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { }); + this.sharedService.isEdit().subscribe(res => { console.log('------------------------....'); console.log(res); @@ -131,6 +133,68 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { }; } + selectProp(value) { + console.log(value); + if (this.selectedProps.has(value)) { + this.selectedProps.delete(value); + } else { + this.selectedProps.add(value); + } + } + + removeProps() { + console.log(this.selectedProps); + this.selectedProps.forEach(prop => { + this.resourceDictionaryRes.forEach((res, index) => { + if (res.name === prop) { + console.log('delete...'); + this.resourceDictionaryRes.splice(index, 1); + this.selectedProps.delete(prop); + } + }); + }); + } + selectAllProps() { + if (this.resourceDictionaryRes.length === this.selectedProps.size) { + this.selectedProps = new Set(); + } else { + this.resourceDictionaryRes.forEach(prop => { + console.log(prop); + this.selectedProps.add(prop.name); + }); + } + + } + reMap() { + let currentResDictionary = []; + if (this.selectedProps && this.selectedProps.size > 0) { + console.log('base'); + this.packageCreationService.getTemplateAndMapping([...this.selectedProps]).subscribe(res => { + let message = 'Re-Auto mapping'; + this.mappingRes = []; + currentResDictionary = res; + console.log(currentResDictionary); + if (currentResDictionary && currentResDictionary.length <= 0) { + message = 'No values for those attributes'; + } + + // Replcae new values with the old ones + currentResDictionary.forEach(curr => { + for (let i = 0; i < this.resourceDictionaryRes.length; i++) { + if (this.resourceDictionaryRes[i].name === curr.name) { + this.resourceDictionaryRes[i] = curr; + } + } + }); + this.rerender(); + this.toastr.success(message, 'Success'); + }, err => { + this.toastr.error('Error'); + }); + } + + } + getFileExtension() { switch (this.templateExt) { case 'vtl': -- cgit 1.2.3-korg