summaryrefslogtreecommitdiffstats
path: root/cds-ui/client
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2019-07-25 21:57:31 +0530
committerArundathi Patil <arundpil@in.ibm.com>2019-07-25 21:57:44 +0530
commit3f87894a91a64d53c1509bb5f48c91cdb6e9fc2c (patch)
treeeaa9b751aaad87f3881e0a2da2b483ff50cc1c77 /cds-ui/client
parent961f4b1e3b91ffa3821d02ac4a57cd207e8081bb (diff)
Source option- avoiding duplicates
Implemented code to prevent adding duplicate resources in source list Issue-ID: CCSDK-707 Change-Id: I56caa3a248a2e2a611dceec0982820ea13c438a6 Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
Diffstat (limited to 'cds-ui/client')
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html2
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts66
2 files changed, 54 insertions, 14 deletions
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html
index b179f011d..a5f367de0 100644
--- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html
+++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html
@@ -27,7 +27,7 @@
class="sources-list"
(cdkDropListDropped)="drop($event)">
<div class="sources-box" *ngFor="let item of sourcesOptions;let i = index" cdkDrag>
- <mat-expansion-panel class="expansion-panel" (opened)="selected(item)">
+ <mat-expansion-panel class="expansion-panel">
<mat-expansion-panel-header>
<mat-panel-title>
{{item.name}}
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts
index 42f990a24..3c76b8506 100644
--- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts
+++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts
@@ -48,7 +48,8 @@ export class SourcesTemplateComponent implements OnInit {
sources:ISourcesData;
sourcesOptions = [];
sourcesData = {};
- @Output() resourcesData = new EventEmitter();
+ @Output() resourcesData = new EventEmitter();
+ tempOption = [];
constructor(private store: Store<IAppState>, private apiService: ResourceEditService) {
this.rdState = this.store.select('resources');
@@ -62,12 +63,10 @@ export class SourcesTemplateComponent implements OnInit {
resourcesdata => {
var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
this.resources=resourcesState.resources;
- // this.sources = resourcesState.resources.sources;
if(resourcesState.resources.definition && resourcesState.resources.definition.sources) {
this.sources = resourcesState.resources.definition.sources;
}
for (let key in this.sources) {
- // this.sourcesOptions.push(key);
let source = {
name : key,
data: this.sources[key]
@@ -136,14 +135,45 @@ export class SourcesTemplateComponent implements OnInit {
}
drop(event: CdkDragDrop<string[]>) {
- if (event.previousContainer === event.container) {
- moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
- } else {
- transferArrayItem(event.previousContainer.data,
- event.container.data,
- event.previousIndex,
- event.currentIndex);
- }
+ if (!this.checkIfSourceExists(event.item.element.nativeElement.innerText)) {
+ if (event.previousContainer === event.container) {
+ moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
+ } else {
+ transferArrayItem(event.previousContainer.data,
+ event.container.data,
+ event.previousIndex,
+ event.currentIndex);
+ }
+ this.tempOption.forEach((item) => {
+ if (item.name == event.item.element.nativeElement.innerText) {
+ this.apiService.getModelType(item.value)
+ .subscribe(data => {
+ console.log(data);
+ data.forEach(dataitem => {
+ if (typeof (dataitem) == "object") {
+ for (let key1 in dataitem) {
+ if (key1 == 'properties') {
+ let newPropOnj = {}
+ for (let key2 in dataitem[key1]) {
+ console.log(dataitem[key1][key2]);
+ let varType = dataitem[key1][key2].type
+ // let property : varType =
+ newPropOnj[key2] = dataitem[key1][key2];
+ }
+ }
+ }
+ }
+ });
+ this.sourcesData = data;
+ this.sourcesOptions.forEach(sourcesOptionsitem => {
+ if (sourcesOptionsitem.name == item.name) {
+ sourcesOptionsitem.data = data;
+ }
+ })
+ })
+ }
+ });
+ }
}
getResources() {
@@ -152,11 +182,21 @@ export class SourcesTemplateComponent implements OnInit {
console.log(data);
for (let key in data[0]) {
let sourceObj = { name: key, value: data[0][key] }
- this.option.push(sourceObj);
+ this.option.push(sourceObj);
+ this.tempOption.push(sourceObj);
}
- // this.sourcesOptions = data;
}, error=>{
console.log(error);
})
}
+
+ checkIfSourceExists(sourceName) {
+ let sourceExists: boolean = false;
+ this.sourcesOptions.forEach(item => {
+ if (item.name == sourceName) {
+ sourceExists = true;
+ }
+ });
+ return sourceExists;
+}
}