From bf566c138c513af95f01657cec75d97bc442777b Mon Sep 17 00:00:00 2001 From: AhmedEldeeb50 Date: Thu, 7 May 2020 16:10:33 +0200 Subject: update template&mapping create view. add alert messages for success and error Issue-ID: CCSDK-2323 Signed-off-by: AhmedEldeeb50 Change-Id: Id05c73abad2342685971e2e57409b4a471f9242f --- .../scripts-tab/scripts-tab.component.html | 3 +- .../templ-mapp-creation.component.css | 5 +++ .../templ-mapp-creation.component.html | 19 ++++++---- .../templ-mapp-creation.component.ts | 40 ++++++++++++++++------ .../templ-mapp-listing.component.html | 7 ++-- .../templ-mapp-listing.component.ts | 14 +++++--- .../template-mapping.component.html | 8 ++--- .../template-mapping/template-mapping.component.ts | 11 ++++-- 8 files changed, 73 insertions(+), 34 deletions(-) (limited to 'cds-ui/designer-client/src/app/modules') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html index 159f7aec4..1ecf2985e 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html @@ -116,8 +116,7 @@ - diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.css b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.css index 7273b9c27..3a0d9461c 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.css +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.css @@ -1,4 +1,9 @@ .accordian-title { color: #a09e9e; font-size: .9em; +} + +.mapping-source-load { + background-color: white; + border: 0 } \ No newline at end of file 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 e6149c883..4f9b2709a 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 @@ -6,7 +6,8 @@
- +
@@ -79,11 +80,13 @@ @@ -253,8 +257,9 @@ - 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 7d4705d69..4601880f8 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 @@ -1,4 +1,4 @@ -import { Component, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; +import { Component, EventEmitter, OnDestroy, OnInit, Output, ViewChild, AfterViewInit, ElementRef } from '@angular/core'; import { FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop'; import { PackageCreationStore } from '../../package-creation.store'; import { TemplateInfo, TemplateStore } from '../../template.store'; @@ -17,14 +17,14 @@ import { ToastrService } from 'ngx-toastr'; }) export class TemplMappCreationComponent implements OnInit, OnDestroy { @Output() showListViewParent = new EventEmitter(); - + @Output() openList = new EventEmitter(); public uploadedFiles: FileSystemFileEntry[] = []; private fileNames: Set = new Set(); private jsonConvert = new JsonConvert(); public files: NgxFileDropEntry[] = []; fileName: any; templateInfo = new TemplateInfo(); - private variables: string[] = []; + variables: string[] = []; dtOptions: DataTables.Settings = {}; // We use this trigger because fetching the list of persons can be quite long, // thus we ensure the data is fetched before rendering @@ -44,8 +44,6 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { currentTemplate: any; currentMapping: any; - - constructor( private packageCreationStore: PackageCreationStore, private templateStore: TemplateStore, @@ -56,6 +54,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { ngOnInit() { this.templateStore.state$.subscribe(templateInfo => { + // init Template&mapping vars console.log('----------'); console.log(templateInfo); this.templateInfo = templateInfo; @@ -63,21 +62,29 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { if (this.fileName) { this.fileName = this.fileName.split('-')[0]; } - if (templateInfo.type === 'mapping') { + if (templateInfo.type === 'mapping' || templateInfo.type.includes('mapping')) { this.mappingRes = templateInfo.mapping; - this.currentMapping = templateInfo; + this.currentMapping = Object.assign({}, templateInfo); this.resourceDictionaryRes = []; this.resTableDtTrigger.next(); } else { + this.mappingRes = []; + this.currentMapping = Any; + } + this.templateFileContent = templateInfo.fileContent; + this.currentTemplate = Object.assign({}, templateInfo); - this.templateFileContent = templateInfo.fileContent; - this.currentTemplate = templateInfo; + if (templateInfo.type === 'template' || templateInfo.type.includes('template')) { + this.currentTemplate.fileName = 'Templates/' + this.fileName + '-template.vtl'; + } else { + this.currentTemplate = Any; } + }); this.dtOptions = { pagingType: 'full_numbers', - pageLength: 10, + pageLength: 25, destroy: true, retrieve: true, }; @@ -211,7 +218,12 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { this.showListViewParent.emit('tell parent to open create views'); } + closeCreationForm() { + this.openList.emit('close create form and open list'); + } + getMappingTableFromTemplate(e) { + console.log('-' + this.templateFileContent + '-'); this.resourceDictionaryRes = []; if (e) { e.preventDefault(); @@ -219,10 +231,17 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { if (this.variables && this.variables.length > 0) { console.log('base'); this.packageCreationStore.getTemplateAndMapping(this.variables).subscribe(res => { + let message = 'Attributes are Fetched'; this.mappingRes = []; this.resourceDictionaryRes = res; console.log(this.resourceDictionaryRes); this.rerender(); + if (this.resourceDictionaryRes && this.resourceDictionaryRes.length <= 0) { + message = 'No values for those attributes'; + } + this.toastr.success(message, 'Success'); + }, err => { + this.toastr.error('Error'); }); } } @@ -261,6 +280,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { } this.fileName = ''; this.toastr.success('File is created', 'success'); + this.closeCreationForm(); } else { console.log('this file already exist'); this.toastr.error('File name already exist', 'Error'); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.html index a47963a72..8c92f0dc2 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.html @@ -1,9 +1,9 @@ - + Create -
+
@@ -21,7 +21,8 @@
- {{file}} + {{file}} Mapping Template 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 448899019..ed9f3eeb3 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 @@ -13,6 +13,7 @@ import { ActivatedRoute } from '@angular/router'; }) export class TemplMappListingComponent implements OnInit { @Output() showCreationViewParentNotification = new EventEmitter(); + @Output() showFullView = new EventEmitter(); private templateAndMappingMap = new Map(); private templates: Template; private mapping: Mapping; @@ -71,6 +72,9 @@ export class TemplMappListingComponent implements OnInit { openCreationView() { this.showCreationViewParentNotification.emit('tell parent to open create views'); } + FullView() { + this.showFullView.emit('show full view'); + } setSourceCodeEditor(key: string) { this.currentFile = key; @@ -80,23 +84,23 @@ export class TemplMappListingComponent implements OnInit { 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); - const templateInfo = new TemplateInfo(); templateInfo.fileContent = fileContent; templateInfo.fileName = templateKey; - this.templateStore.changeTemplateInfo(templateInfo); + templateInfo.type = 'template'; } const mappingKey = 'Templates/' + key + '-mapping.json'; if (cba.mapping && cba.mapping.files.has(mappingKey)) { const obj = JSON.parse(cba.mapping.getValue(mappingKey)); - const templateInfo = new TemplateInfo(); templateInfo.mapping = obj; templateInfo.fileName = mappingKey; - templateInfo.type = 'mapping'; - this.templateStore.changeTemplateInfo(templateInfo); + templateInfo.type += 'mapping'; } + this.templateStore.changeTemplateInfo(templateInfo); + this.FullView(); }); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.html index f8cfe7a6a..8fd97d71d 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.html @@ -1,9 +1,9 @@
- +
- -
+ + +
\ No newline at end of file diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.ts index 106765834..d2e25ef6f 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.ts @@ -8,8 +8,8 @@ import { PackageCreationStore } from '../package-creation.store'; styleUrls: ['./template-mapping.component.css'] }) export class TemplateMappingComponent implements OnInit { - creationView = true; - listView = false; + creationView = false; + listView = true; constructor(private route: ActivatedRoute, private pakcageStore: PackageCreationStore) { } @@ -17,7 +17,7 @@ export class TemplateMappingComponent implements OnInit { ngOnInit() { if (this.route.snapshot.paramMap.has('id')) { console.log('Edit mode'); - this.creationView = false; + this.creationView = true; this.listView = false; } else { console.log('Create mode'); @@ -34,4 +34,9 @@ export class TemplateMappingComponent implements OnInit { this.creationView = false; } + closeCreationView() { + this.creationView = true; + this.listView = false; + } + } -- cgit 1.2.3-korg