Skip to content

Commit b1518a5

Browse files
authored
Merge pull request #84 from Gid733/master
Fixes for entity-select
2 parents 4d52c33 + 0df331c commit b1518a5

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

eFormAPI/eFormAPI/Infrastructure/Helpers/CaseUpdateHelper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
107107
list.Add(val);
108108
}
109109
break;
110+
case "EntitySelect":
111+
var entitySelect = editRequestField?.FieldValues?.First();
112+
if (entitySelect?.Value != null && entitySelect?.FieldId != null)
113+
{
114+
string val = $"{entitySelect.FieldId}|{entitySelect.Value.ToString()}";
115+
list.Add(val);
116+
}
117+
break;
110118
case "MultiSelect":
111119
var multiFirst = editRequestField?.FieldValues?.First();
112120
if (multiFirst?.Value != null && multiFirst?.FieldId != null)

eform-client/src/app/modules/cases/components/case-edit-switch/case-edit-switch.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<element-entitysearch [(fieldValue)]="dataItem.fieldValues[0]" [entityGroupUid]="dataItem.entityGroupId"></element-entitysearch>
5555
</div>
5656
<div *ngSwitchCase="'EntitySelect'">
57-
<element-entityselect [(fieldValue)]="dataItem.fieldValues[0]"></element-entityselect>
57+
<element-entitysearch [(fieldValue)]="dataItem.fieldValues[0]" [entityGroupUid]="dataItem.entityGroupId"></element-entitysearch>
5858
</div>
5959
<div *ngSwitchDefault></div>
6060
</div>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<ngx-select [items]="items"
2+
(typed)="onSelectInputChanged($event)"
23
[formControl]="selectControl"
34
[placeholder]="fieldValueObj.valueReadable">
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
22
import {CaseFieldValue, CommonDictionaryTextModel} from 'app/models';
3-
import {ISubscription} from 'rxjs/Subscription';
3+
import {EntitySearchService} from 'app/services';
44
import {FormControl} from '@angular/forms';
5+
import {ISubscription} from 'rxjs/Subscription';
56

67
@Component({
78
selector: 'element-entityselect',
@@ -11,9 +12,11 @@ import {FormControl} from '@angular/forms';
1112
export class ElementEntityselectComponent implements OnInit, OnDestroy {
1213
sub: ISubscription;
1314
selectControl = new FormControl();
14-
fieldValueObj: CaseFieldValue = new CaseFieldValue();
1515
items: Array<CommonDictionaryTextModel> = [];
1616

17+
fieldValueObj: CaseFieldValue = new CaseFieldValue();
18+
@Input() entityGroupUid: string;
19+
1720
@Input()
1821
get fieldValue() {
1922
return this.fieldValueObj;
@@ -23,22 +26,28 @@ export class ElementEntityselectComponent implements OnInit, OnDestroy {
2326
this.fieldValueObj = val;
2427
}
2528

26-
constructor() {
29+
constructor(private entitySearchService: EntitySearchService) {
2730
}
2831

2932
ngOnInit() {
3033
this.sub = this.selectControl.valueChanges.subscribe(value => this.onSelectedChanged(value));
31-
for (const keyValuePair of this.fieldValueObj.keyValuePairList) {
32-
this.items.push({id: keyValuePair.key, text: keyValuePair.value});
33-
}
3434
}
3535

3636
ngOnDestroy(): void {
3737
this.sub.unsubscribe();
3838
}
3939

40+
onSelectInputChanged(searchString: string) {
41+
if (searchString.length > 2) {
42+
this.entitySearchService.getEntitySearchableGroupDictionary(this.entityGroupUid, searchString).subscribe((operation => {
43+
if (operation && operation.success) {
44+
this.items = operation.model;
45+
}
46+
}));
47+
}
48+
}
49+
4050
onSelectedChanged(value: string) {
4151
this.fieldValue.value = value;
4252
}
43-
4453
}

0 commit comments

Comments
 (0)