From 4de8a4723e2fc8071595863253faed736be8c9b6 Mon Sep 17 00:00:00 2001 From: Ahmedeldeeb50 Date: Sun, 11 Oct 2020 15:24:39 +0200 Subject: adding template selection from function attribute Issue-ID: CCSDK-2900 Signed-off-by: Ahmedeldeeb50 Change-Id: I19fb4a86857c2f02603a93e4e47bc792e6aadf09 --- .../packages/designer/designer.component.css | 8 + .../functions-attribute.component.html | 183 ++++++++++++--------- .../functions-attribute.component.ts | 76 +++++++-- 3 files changed, 177 insertions(+), 90 deletions(-) (limited to 'cds-ui/designer-client') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.css b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.css index 43f3818a0..f514831ca 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.css +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.css @@ -87,6 +87,14 @@ header{ color: #1B3E6F; font-size: 10px; } +.template-list.active { + display: inline; + padding: 4px 10px; + background: #F4F9FE; + border-radius: 10px; + color: #1B3E6F; + font-size: 10px; +} .designer-breadcrumb .fa-angle-right::before { color: #fff; line-height: 38px; diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.html index c89a96de0..23633017d 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.html @@ -19,106 +19,86 @@
-
-
+
+ aria-labelledby="pills-home-tab">
-
-
- -
@@ -136,43 +116,86 @@
+ + + + + + \ No newline at end of file diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts index 88bd76eb6..0c47b3bbc 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts @@ -1,9 +1,10 @@ -import {Component, OnDestroy, OnInit} from '@angular/core'; -import {DesignerStore} from '../designer.store'; -import {PackageCreationStore} from '../../package-creation/package-creation.store'; -import {Subject} from 'rxjs'; -import {distinctUntilChanged, takeUntil} from 'rxjs/operators'; -import {CBAPackage} from '../../package-creation/mapping-models/CBAPacakge.model'; +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { DesignerStore } from '../designer.store'; +import { PackageCreationStore } from '../../package-creation/package-creation.store'; +import { Subject } from 'rxjs'; +import { distinctUntilChanged, takeUntil } from 'rxjs/operators'; +import { CBAPackage } from '../../package-creation/mapping-models/CBAPacakge.model'; +import { TemplateAndMapping } from '../../package-creation/template-mapping/TemplateAndMapping'; @Component({ selector: 'app-functions-attribute', @@ -13,11 +14,16 @@ import {CBAPackage} from '../../package-creation/mapping-models/CBAPacakge.model export class FunctionsAttributeComponent implements OnInit, OnDestroy { ngUnsubscribe = new Subject(); - private designerDashboardState: DecodeSuccessCallback; - private cbaPackage: CBAPackage; + designerDashboardState: DecodeSuccessCallback; + cbaPackage: CBAPackage; + templateAndMappingMap = new Map(); + selectedTemplates = new Map(); + fileToDelete: string; - constructor(private designerStore: DesignerStore, - private packageCreationStore: PackageCreationStore) { + constructor( + private designerStore: DesignerStore, + private packageCreationStore: PackageCreationStore + ) { } ngOnInit() { @@ -35,6 +41,22 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { takeUntil(this.ngUnsubscribe)) .subscribe(cbaPackage => { this.cbaPackage = cbaPackage; + console.log('File name =>================== '); + console.log(this.cbaPackage.templates.files); + this.cbaPackage.templates.files.forEach((value, key) => { + console.log('File name => ' + key); + const templateAndMapping = new TemplateAndMapping(); + templateAndMapping.isTemplate = true; + const isFromTemplate = true; + this.setIsMappingOrTemplate(key, templateAndMapping, isFromTemplate); + }); + + this.cbaPackage.mapping.files.forEach((value, key) => { + const templateAndMapping = new TemplateAndMapping(); + templateAndMapping.isMapping = true; + const isFromTemplate = false; + this.setIsMappingOrTemplate(key, templateAndMapping, isFromTemplate); + }); }); } @@ -43,4 +65,38 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { this.ngUnsubscribe.next(); this.ngUnsubscribe.complete(); } + // Template logic + + private setIsMappingOrTemplate(key: string, templateAndMapping: TemplateAndMapping, isFromTemplate: boolean) { + 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); + !isFromTemplate ? templateAndMappingExisted.isMapping = true : templateAndMappingExisted.isTemplate = true; + this.templateAndMappingMap.set(nameOfFile, templateAndMappingExisted); + } else { + this.templateAndMappingMap.set(nameOfFile, templateAndMapping); + } + + } + + addTemplates() { } + + setTemplate(file: string) { + if (this.selectedTemplates.has(file)) { + this.selectedTemplates.delete(file); + } else { + this.selectedTemplates.set(file, this.templateAndMappingMap.get(file)); + } + console.log(this.selectedTemplates); + } + + getKeys(templateAndMappingMap: Map) { + return Array.from(templateAndMappingMap.keys()); + } + getValue(file: string) { + return this.templateAndMappingMap.get(file); + } } -- cgit 1.2.3-korg