From fc5fa67b192b25a6507212cf1b3082134c6cb2a6 Mon Sep 17 00:00:00 2001 From: Ahmedeldeeb50 Date: Mon, 18 Jan 2021 14:26:22 +0200 Subject: create dictionary resource from metadata tab enable the user to add source from the UI Issue-ID: CCSDK-3083 Signed-off-by: Ahmedeldeeb50 Change-Id: I1f656fe303863373723a1285d5e1a473a9a47dec --- .../resource-dictionary/model/metaData.model.ts | 2 + .../dictionary-metadata.component.html | 2 +- .../dictionary-metadata.component.ts | 18 ++-- .../sources-template.component.html | 101 ++++++++++----------- .../sources-template/sources-template.component.ts | 90 +++++++++++++----- 5 files changed, 128 insertions(+), 85 deletions(-) (limited to 'cds-ui/designer-client/src/app/modules') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/model/metaData.model.ts b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/model/metaData.model.ts index 92e6bce43..89a83a1ea 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/model/metaData.model.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/model/metaData.model.ts @@ -27,12 +27,14 @@ export class MetaData { @JsonProperty('updated-by') public updatedBy: string; public property: Property; + public sources: any; constructor() { this.name = ''; this.tags = ''; this.updatedBy = ''; this.property = new Property(); + this.sources = {}; } } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.html index add21e9e1..8e355449b 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.html @@ -78,7 +78,7 @@
-
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.ts index 631a0fffd..01df118d2 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.ts @@ -37,8 +37,6 @@ export class DictionaryMetadataComponent implements OnInit { errorMessage: string; constructor( - private route: ActivatedRoute, - private dictionaryCreationService: DictionaryCreationService, private dictionaryCreationStore: DictionaryCreationStore ) { } @@ -67,6 +65,7 @@ export class DictionaryMetadataComponent implements OnInit { removeTag(value) { this.tags.delete(value); + this.mergeTags(); } @@ -74,15 +73,22 @@ export class DictionaryMetadataComponent implements OnInit { const value = event.target.value; console.log(value); if (value && value.trim().length > 0) { - let tag = ''; event.target.value = ''; this.tags.add(value); - this.tags.forEach(val => { - tag += val + ', '; - }); + // merge + this.mergeTags(); } } + mergeTags() { + let tag = ''; + this.tags.forEach((val, index) => { + tag += val + ', '; + }); + this.metaDataTab.tags = tag.trim(); + this.saveMetaDataToStore(); + } + saveMetaDataToStore() { console.log(this.metaDataTab); this.dictionaryCreationStore.changeMetaData(this.metaDataTab); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.html index b274ce95d..f6150c95b 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.html @@ -18,68 +18,59 @@ * ============LICENSE_END========================================================= */-->
-
-
-
Sources Options
- - -
-
+
+
+
Sources Options
+ + +
+
- + {{item.name}}
- +
- +
-
- -
-
Sources List
-
-
- -
- - - - - {{item.name}} - - -
- - -
-
- -
- -
-
- Delete +
+ +
+
Sources List
+
+
+ +
+ + + + + {{item.name}} + + +
+ + +
-
-
-
+
+ +
+
+ Delete +
+
+
+
\ No newline at end of file diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.ts index bec8c4bf3..1a950163e 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.ts @@ -21,6 +21,8 @@ import { Component, OnInit } from '@angular/core'; import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop'; import { SourcesStore } from './sources.store'; import { DictionaryCreationService } from '../dictionary-creation.service'; +import { DictionaryCreationStore } from '../dictionary-creation.store'; +import { MetaData } from '../../model/metaData.model'; @Component({ selector: 'app-sources-template', @@ -40,9 +42,12 @@ export class SourcesTemplateComponent implements OnInit { searchText = ''; text = ''; selectedArray = []; + metaDataTab: MetaData = new MetaData(); + constructor( private sourcesStore: SourcesStore, - private dictionaryCreationService: DictionaryCreationService + private dictionaryCreationService: DictionaryCreationService, + private dictionaryCreationStore: DictionaryCreationStore ) { } @@ -66,16 +71,44 @@ export class SourcesTemplateComponent implements OnInit { } }); + + this.dictionaryCreationStore.state$.subscribe(element => { + console.log('################'); + console.log(this.metaDataTab); + if (element && element.metaData) { + this.metaDataTab = element.metaData; + this.addSourcesInUI(); + } + }); + } + + addSourcesInUI() { + // add sources from json to UI + const originalSources = this.sourcesOptions; + // for (const key of this.sourcesOptions) { + // this.sourcesOptions; + for (const source in this.metaDataTab.sources) { + if (source) { + console.log(source); + } + } } saveSorcesDataToStore() { - this.sourcesStore.saveSources(this.ddSource); + console.log(this.ddSource); + this.metaDataTab.sources = {}; + for (const obj of this.ddSource) { + this.metaDataTab.sources = { ...this.metaDataTab.sources, ...obj }; + } + // this.metaDataTab.sources = { ...this.ddSource } + console.log(this.metaDataTab.sources); + this.dictionaryCreationStore.changeMetaData(this.metaDataTab); } drop(event: CdkDragDrop) { console.log('-------------'); - console.log(event); - this.ddSource = []; + // console.log(event); + if (event.previousContainer === event.container) { moveItemInArray(event.container.data, event.previousIndex, event.currentIndex); } else { @@ -85,18 +118,24 @@ export class SourcesTemplateComponent implements OnInit { event.currentIndex); } - for (const key2 in this.sources) { - if (key2) { - const originalSources = this.sourcesOptions; - for (const key of originalSources) { - /* tslint:disable:no-string-literal */ - if (key.name === key2['name']) { - const obj = `{${key.name}: ${key.value}}`; - this.ddSource.push(obj); - } + console.log(this.sourcesOptions); + console.log(this.sources); + + this.ddSource = []; + + const originalSources = this.sourcesOptions; + for (const key of originalSources) { + /* tslint:disable:no-string-literal */ + this.ddSource.push({ + [key.name]: { + type: key.value, + properties: {} } - } + }); + } + + this.saveSorcesDataToStore(); } searchDictionary(event: any) { @@ -113,15 +152,20 @@ export class SourcesTemplateComponent implements OnInit { } textChanged(event, item) { - const editedData = JSON.parse(event); - const originalSources = this.sources; - for (const key in originalSources) { - if (key === item.name) { - this.sources[key] = editedData; - } - } - this.option = []; - this.sourcesStore.changeSources(this.sources); + // const editedData = JSON.parse(event); + // const originalSources = this.sources; + // for (const key in originalSources) { + // if (key === item.name) { + // this.sources[key] = editedData; + // } + // } + // this.option = []; + // this.sourcesStore.changeSources(this.sources); + + console.log(item); + console.log(event); + + // this.metaDataTab.sources[item.name].properties = editedData; } } -- cgit 1.2.3-korg