diff options
author | Swapnali Shadanan Pode <sp00501638@techmahindra.com> | 2019-03-29 16:02:20 +0530 |
---|---|---|
committer | Swapnali Pode <sp00501638@techmahindra.com> | 2019-03-29 19:19:11 +0000 |
commit | 8c409761dbb9e12c8784b9ff8347d6bd8f20c33c (patch) | |
tree | 2587ca39ae978dcabe79891d98da603deb41eb6b /cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts | |
parent | a35be26c8d9bc2e884dc65da48238d7a33f69496 (diff) |
Resource edit changes
Change-Id: Id588f474468655cb995ed44cd8178ef2dc1e44ed
Issue-ID: CCSDK-804
Signed-off-by: sp00501638 <sp00501638@techmahindra.com>
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts')
-rw-r--r-- | cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts index 5b567034a..55b80628d 100644 --- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts +++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts @@ -18,7 +18,15 @@ * ============LICENSE_END========================================================= */ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; +import { IResources } from 'src/app/common/core/store/models/resources.model'; +import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model'; +import { LoadResourcesSuccess,UpdateResources,SetResourcesState } from 'src/app/common/core/store/actions/resources.action'; +import { Store } from '@ngrx/store'; +import { IAppState } from '../../../common/core/store/state/app.state'; +import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor'; +import { Observable } from 'rxjs'; +import { A11yModule } from '@angular/cdk/a11y'; @Component({ selector: 'app-resource-edit', @@ -27,9 +35,62 @@ import { Component, OnInit } from '@angular/core'; }) export class ResourceEditComponent implements OnInit { - constructor() { } + resources:IResources; + data:IResources; + rdState: Observable<IResourcesState>; + designerMode: boolean = true; + editorMode: boolean = false; + viewText: string = "Open in Editor Mode"; + @ViewChild(JsonEditorComponent) editor: JsonEditorComponent; + options = new JsonEditorOptions(); + + constructor(private store: Store<IAppState>) { + this.rdState = this.store.select('resources'); + this.options.mode = 'text'; + this.options.modes = [ 'text', 'tree', 'view']; + this.options.statusBar = false; + } ngOnInit() { + this.rdState.subscribe( + resourcesdata => { + var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess }; + this.resources=resourcesState.resources; + }) } + metaDataDetail(data: IResources) { + this.data=data; + } + + sourcesDetails(data: IResources) { + this.data=data; + } + + onChange($event) { + this.data=JSON.parse($event.srcElement.value); + }; + + updateResourcesState(){ + console.log(this.data); + let resourcesState = { + resources: this.data, + isLoadSuccess: true, + isUpdateSuccess:true, + isSaveSuccess:true + } + this.store.dispatch(new SetResourcesState(resourcesState)); + } + + changeView() { + if(this.viewText == 'Open in Editor Mode') { + this.editorMode = true; + this.designerMode = false; + this.viewText = 'Open in Form Mode' + } else { + this.editorMode = false; + this.designerMode = true; + this.viewText = 'Open in Editor Mode' + } + } } |