From 006cede8158bb1b3579805b6492df8b050aa83be Mon Sep 17 00:00:00 2001 From: Ahmedeldeeb50 Date: Mon, 11 Jan 2021 14:10:35 +0200 Subject: Enable user to create new resource dictionary with json Issue-ID: CCSDK-3078 Signed-off-by: Ahmedeldeeb50 Change-Id: I2136eb5b2cec1e9db4c7124af9f09046ff5c15f0 --- .../resource-dictionary/model/metaData.model.ts | 5 +- .../dictionary-creation.service.ts | 5 +- .../dictionary-creation.store.ts | 11 ++- .../dictionary-editor.component.html | 6 +- .../dictionary-editor.component.ts | 10 ++- .../dictionary-metadata.component.ts | 3 +- .../resource-dictionary-creation.component.html | 91 +++++++++++----------- .../resource-dictionary-creation.component.ts | 30 +++++-- 8 files changed, 96 insertions(+), 65 deletions(-) (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary') 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 609b066e2..26420882c 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 @@ -20,13 +20,14 @@ export class MetaData { public name: string; - public tags: string; public dataType: string; public description: string; public entrySchema: string; public updatedBy: string; + public tags: string; + public required: string; + public createdDate: string; public libraryInstance: string; - public required: string; public derivedFrom: string; } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.service.ts b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.service.ts index df90e6cd1..445be2015 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.service.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.service.ts @@ -32,6 +32,9 @@ export class DictionaryCreationService { getSources() { return this.api.get(ResourceDictionaryURLs.getSources); -} + } + save(metadata) { + return this.api.post(ResourceDictionaryURLs.saveResourceDictionary, { ...metadata }); + } } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.store.ts index 20cec7448..5734d4050 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.store.ts @@ -29,11 +29,14 @@ import { SourcesStore } from './sources-template/sources.store'; providedIn: 'root' }) export class DictionaryCreationStore extends Store { - constructor(private dictionaryCreationService: DictionaryCreationService, private sourcesStore: SourcesStore) { + constructor( + private dictionaryCreationService: DictionaryCreationService, + private sourcesStore: SourcesStore + ) { super(new ResourceDictionary()); } - - changeMetaData(metaDataObject: MetaData) { + // changeMetaData(metaDataObject: MetaData) { + changeMetaData(metaDataObject: any) { console.log(metaDataObject); this.setState({ ...this.state, @@ -43,7 +46,7 @@ export class DictionaryCreationStore extends Store { getSources() { this.sourcesStore.state$.subscribe(data => { - console.log(data); + console.log(data); }); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.html index 93d7df7d1..c0cb818eb 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.html @@ -17,6 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */--> - - + + \ No newline at end of file diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.ts index 157a5aa25..63725a228 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.ts @@ -18,6 +18,8 @@ * ============LICENSE_END========================================================= */ import { Component, OnInit } from '@angular/core'; +import { DictionaryCreationService } from '../dictionary-creation.service'; +import { DictionaryCreationStore } from '../dictionary-creation.store'; @Component({ selector: 'app-dictionary-editor', @@ -26,14 +28,18 @@ import { Component, OnInit } from '@angular/core'; }) export class DictionaryEditorComponent implements OnInit { text = ''; - constructor() { + constructor( + private dictionaryStore: DictionaryCreationStore, + private dictionaryService: DictionaryCreationService + ) { } ngOnInit() { } textChanged(event) { - console.log(event); + console.log(JSON.parse(event)); + this.dictionaryStore.changeMetaData(JSON.parse(event)); } } 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 aa975f87a..caeac83f1 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 @@ -73,6 +73,7 @@ export class DictionaryMetadataComponent implements OnInit { } saveMetaDataToStore() { - this.dictionaryCreationStore.changeMetaData(this.metaDataTab); + 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/resource-dictionary-creation.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.html index bf183216d..637c87d7a 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.html @@ -33,12 +33,12 @@
-
-
-
- Dictionary Name -
- +
+
+
+ Dictionary Name +
+ Last modified {{createDate}} by me
@@ -46,7 +46,7 @@
- + Save @@ -69,54 +69,55 @@ -
+
+
-
-
-
-
-
-
\ No newline at end of file +
\ No newline at end of file diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.ts index e32db8a37..c40679718 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.ts @@ -24,6 +24,7 @@ import { DictionaryModel } from '../model/dictionary.model'; import { Definition } from '../model/definition.model'; import { DictionaryMetadataComponent } from './dictionary-metadata/dictionary-metadata.component'; import { SourcesTemplateComponent } from './sources-template/sources-template.component'; +import { DictionaryCreationService } from './dictionary-creation.service'; @Component({ selector: 'app-resource-dictionary-creation', @@ -32,7 +33,11 @@ import { SourcesTemplateComponent } from './sources-template/sources-template.co }) export class ResourceDictionaryCreationComponent implements OnInit { - constructor(private router: Router, private dictionaryCreationStore: DictionaryCreationStore) { + constructor( + private router: Router, + private dictionaryCreationStore: DictionaryCreationStore, + private dictionaryService: DictionaryCreationService + ) { } modes: object[] = [ @@ -59,15 +64,26 @@ export class ResourceDictionaryCreationComponent implements OnInit { } saveDictionaryToStore() { - this.dictionaryCreationStore.getSources(); - this.dictionaryCreationStore.state$.subscribe(dd => { - console.log(dd); - }); + // console.log('00000000000'); + // this.dictionaryCreationStore.getSources(); + // this.dictionaryCreationStore.state$.subscribe(dd => { + // console.log(dd); + // }); } - test() { + createDictionary() { + console.log('-----'); this.metadataTabComponent.saveMetaDataToStore(); - this.sourcesTemplateComponent.saveSorcesDataToStore(); + this.dictionaryCreationStore.state$.subscribe(res => { + console.log('---------------------------------------'); + console.log(res); + this.dictionaryService.save(res.metaData).subscribe(data => { + + }, err => { + + }); + }); + // this.sourcesTemplateComponent.saveSorcesDataToStore(); } goBackToDashBorad() { -- cgit 1.2.3-korg