diff --git a/eform-client/src/app/modules/cases/components/case-elements/element-entityselect/element-entityselect.component.html b/eform-client/src/app/modules/cases/components/case-elements/element-entityselect/element-entityselect.component.html index 6553d5ce05..0ab688fe93 100644 --- a/eform-client/src/app/modules/cases/components/case-elements/element-entityselect/element-entityselect.component.html +++ b/eform-client/src/app/modules/cases/components/case-elements/element-entityselect/element-entityselect.component.html @@ -1,4 +1,3 @@ - + diff --git a/eform-client/src/app/modules/cases/components/case-elements/element-entityselect/element-entityselect.component.ts b/eform-client/src/app/modules/cases/components/case-elements/element-entityselect/element-entityselect.component.ts index 03cd99bd04..371c7d91a5 100644 --- a/eform-client/src/app/modules/cases/components/case-elements/element-entityselect/element-entityselect.component.ts +++ b/eform-client/src/app/modules/cases/components/case-elements/element-entityselect/element-entityselect.component.ts @@ -1,13 +1,18 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {CaseFieldValue} from 'app/models'; +import {Component, Input, OnDestroy, OnInit} from '@angular/core'; +import {CaseFieldValue, CommonDictionaryTextModel} from 'app/models'; +import {ISubscription} from 'rxjs/Subscription'; +import {FormControl} from '@angular/forms'; @Component({ selector: 'element-entityselect', templateUrl: './element-entityselect.component.html', styleUrls: ['./element-entityselect.component.css'] }) -export class ElementEntityselectComponent implements OnInit { +export class ElementEntityselectComponent implements OnInit, OnDestroy { + sub: ISubscription; + selectControl = new FormControl(); fieldValueObj: CaseFieldValue = new CaseFieldValue(); + items: Array = []; @Input() get fieldValue() { @@ -22,6 +27,18 @@ export class ElementEntityselectComponent implements OnInit { } ngOnInit() { + this.sub = this.selectControl.valueChanges.subscribe(value => this.onSelectedChanged(value)); + for (const keyValuePair of this.fieldValueObj.keyValuePairList) { + this.items.push({id: keyValuePair.key, text: keyValuePair.value}); + } + } + + ngOnDestroy(): void { + this.sub.unsubscribe(); + } + + onSelectedChanged(value: string) { + this.fieldValue.value = value; } }