Enable user to create new resource dictionary with json 21/116721/1
authorAhmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Mon, 11 Jan 2021 12:10:35 +0000 (14:10 +0200)
committerAhmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Mon, 11 Jan 2021 12:10:35 +0000 (14:10 +0200)
Issue-ID: CCSDK-3078

Signed-off-by: Ahmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Change-Id: I2136eb5b2cec1e9db4c7124af9f09046ff5c15f0

cds-ui/designer-client/src/app/modules/feature-modules/packages/packages.module.ts
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/model/metaData.model.ts
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.service.ts
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.store.ts
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.html
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-editor/dictionary-editor.component.ts
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-metadata/dictionary-metadata.component.ts
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.html
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.ts
cds-ui/designer-client/src/styles.css

index 0a43364..47ed050 100644 (file)
@@ -96,7 +96,7 @@ import { CollapseModule } from 'ngx-bootstrap/collapse';
             masterLoaderId: 'master',
             overlayBorderRadius: '0',
             overlayColor: 'rgba(40, 40, 40, 0.8)',
-            pbColor: 'red',
+            pbColor: '#63bdba',
             pbDirection: 'ltr',
             pbThickness: 3,
             hasProgressBar: true,
index 609b066..2642088 100644 (file)
 
 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;
 }
index 20cec74..5734d40 100644 (file)
@@ -29,11 +29,14 @@ import { SourcesStore } from './sources-template/sources.store';
     providedIn: 'root'
 })
 export class DictionaryCreationStore extends Store<ResourceDictionary> {
-    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<ResourceDictionary> {
 
     getSources() {
         this.sourcesStore.state$.subscribe(data => {
-        console.log(data);
+            console.log(data);
         });
     }
 
index 93d7df7..c0cb818 100644 (file)
@@ -17,6 +17,6 @@
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */-->
-<ace-editor [(text)]="text" [mode]="'javascript'" [autoUpdateContent]="true"
-[durationBeforeCallback]="1000" (textChanged)="textChanged($event)" [theme]="'tomorrow_night_bright'" #editor style="height:500px;">
-</ace-editor>
+<ace-editor [(text)]="text" [mode]="'json'" [autoUpdateContent]="true" [durationBeforeCallback]="1000"
+    (textChanged)="textChanged($event)" [theme]="'tomorrow_night_bright'" #editor style="height:500px;">
+</ace-editor>
\ No newline at end of file
index 157a5aa..63725a2 100644 (file)
@@ -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));
   }
 }
 
index bf18321..637c87d 100644 (file)
             </div>
         </header>
         <div class="container-fluid body-container">
-                <div class="container card creat-card col-11">
-                    <div class="single-line-model customKeyTitle">
-                        <h5 class="label-name w-100 ">
-                            Dictionary Name
-                        </h5>
-                        <!-- <label class="label-name"></label> -->
+            <div class="container card creat-card col-11">
+                <div class="single-line-model customKeyTitle">
+                    <h5 class="label-name w-100 ">
+                        Dictionary Name
+                    </h5>
+                    <!-- <label class="label-name"></label> -->
                     <span>Last modified {{createDate}} by me</span>
                 </div>
             </div>
@@ -46,7 +46,7 @@
         <div class="container-fluid body-container">
             <div class="container">
                 <div class="creat-action-container">
-                    <a class="action-button" (click)="saveDictionaryToStore()">
+                    <a class="action-button" (click)="createDictionary()">
                         <i class="icon-save-sm" aria-hidden="true"></i>
                         <span>Save</span>
                     </a>
                         <div class="nav nav-tabs ed" id="nav-tab" role="tablist">
                             <a class="nav-item nav-link active" id="nav-metadata-tab" data-toggle="tab"
                                 href="#nav-metadata" role="tab" aria-controls="nav-metadata" aria-selected="false"
-                                autofocus #nameit (focusout)="test()">METADATA</a>
-                            <a class="edit-button" id="nav-editor-tab" data-toggle="tab" href="#nav-editor"
-                            role="tab" aria-controls="nav-editor" aria-selected="false">EDITOR MODE</a>
+                                autofocus #nameit (focusout)="saveDictionaryToStore()">METADATA</a>
+                            <a class="edit-button" id="nav-editor-tab" data-toggle="tab" href="#nav-editor" role="tab"
+                                aria-controls="nav-editor" aria-selected="false">EDITOR MODE</a>
 
-                           </div>
-                    </div> 
+                        </div>
+                    </div>
                 </nav>
-               <div>
-                <div class="row mt-4">
-                    <div class="col">
-                        <div class="tab-content" id="nav-tabContent">
-                            <div class="tab-pane fade show active" id="nav-metadata" role="tabpanel"
-                                aria-labelledby="nav-metadata-tab">
-                                <app-dictionary-metadata></app-dictionary-metadata>
-                                <nav class="row">
-                                    <!--Nav Tabs-->
-                                    <div class="col">
-                                        <div class="nav nav-tabs " id="nav-tab" role="tablist">
-                                            <a class="nav-item nav-link active" id="nav-source-tab" data-toggle="tab"
-                                                href="#nav-source" role="tab" aria-controls="nav-source" aria-selected="false"
-                                                >SOURCES</a>
+                <div>
+                    <div class="row mt-4">
+                        <div class="col">
+                            <div class="tab-content" id="nav-tabContent">
+                                <div class="tab-pane fade show active" id="nav-metadata" role="tabpanel"
+                                    aria-labelledby="nav-metadata-tab">
+                                    <app-dictionary-metadata></app-dictionary-metadata>
+                                    <nav class="row">
+                                        <!--Nav Tabs-->
+                                        <div class="col">
+                                            <div class="nav nav-tabs " id="nav-tab" role="tablist">
+                                                <a class="nav-item nav-link active" id="nav-source-tab"
+                                                    data-toggle="tab" href="#nav-source" role="tab"
+                                                    aria-controls="nav-source" aria-selected="false">SOURCES</a>
+                                            </div>
                                         </div>
-                                    </div>
-                                </nav>
-                                <div class="row mt-4">
-                                    <div class="col">
-                                        <div class="tab-content" id="nav-tabContent">
-                                            <div class="tab-pane fade show active" id="nav-source" role="tabpanel"
-                                                aria-labelledby="nav-source-tab">
-                                                <app-sources-template></app-sources-template>
+                                    </nav>
+                                    <div class="row mt-4">
+                                        <div class="col">
+                                            <div class="tab-content" id="nav-tabContent">
+                                                <div class="tab-pane fade show active" id="nav-source" role="tabpanel"
+                                                    aria-labelledby="nav-source-tab">
+                                                    <app-sources-template></app-sources-template>
+                                                </div>
                                             </div>
                                         </div>
                                     </div>
                                 </div>
-                            </div>
-                            <div class="tab-pane fade col-11" id="nav-editor" role="tabpanel"
-                                aria-labelledby="nav-editor-tab">
-                                <div class="card creat-card">
-                                    <div class="editor-container">
-                                <app-dictionary-editor></app-dictionary-editor>
-                                </div></div>
+                                <div class="tab-pane fade col-11" id="nav-editor" role="tabpanel"
+                                    aria-labelledby="nav-editor-tab">
+                                    <div class="card creat-card">
+                                        <div class="editor-container">
+                                            <app-dictionary-editor></app-dictionary-editor>
+                                        </div>
+                                    </div>
+                                </div>
                             </div>
                         </div>
                     </div>
-                </div>
 
-                
+
+                </div>
             </div>
         </div>
-    </div>
-</div>
\ No newline at end of file
+    </div>
\ No newline at end of file
index e32db8a..c406797 100644 (file)
@@ -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() {
index 5d79720..88c6159 100644 (file)
@@ -3014,7 +3014,7 @@ animation: glowing 1500ms infinite;
 /* -------- ace editor style -------- */
 .editor-container{
   height: 55vh !important;
-  overflow: scroll;
+  /* overflow: scroll; */
 }
 .ace_print-margin{
   left: 100% !important;