diff options
author | 2021-01-18 14:26:22 +0200 | |
---|---|---|
committer | 2021-01-18 14:26:22 +0200 | |
commit | fc5fa67b192b25a6507212cf1b3082134c6cb2a6 (patch) | |
tree | 91fd15255b69c64082959c7373b9f157f45bccd1 /cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.ts | |
parent | 424fcd63ca57bd8cfa8b46001021c29e020a8a6d (diff) |
create dictionary resource from metadata tab
enable the user to add source from the UI
Issue-ID: CCSDK-3083
Signed-off-by: Ahmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Change-Id: I1f656fe303863373723a1285d5e1a473a9a47dec
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/sources-template/sources-template.component.ts | 90 |
1 files changed, 67 insertions, 23 deletions
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<string[]>) { 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; } } |