From 18f5e9210c1c9b0a8894fedc7220e0120b0cb12b Mon Sep 17 00:00:00 2001 From: t8g Date: Wed, 18 Oct 2017 11:05:44 +0200 Subject: [PATCH] fix(front) search in tempForeignKeys always return found fix #482 fix #483 --- client/src/app/isari-data.service.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/client/src/app/isari-data.service.ts b/client/src/app/isari-data.service.ts index d48aabbb..5ad9e845 100644 --- a/client/src/app/isari-data.service.ts +++ b/client/src/app/isari-data.service.ts @@ -586,11 +586,10 @@ export class IsariDataService { } const api = mongoSchema2Api[feature] || feature; - const url = `${this.dataUrl}/${api}/` - + (((this.tempForeignKeys[api] && intersection(this.tempForeignKeys[api], values)) + const ids = (((this.tempForeignKeys[api] && intersection(this.tempForeignKeys[api], values).length) ? this.tempForeignKeys[api] - : (values))).join(',') - + '/string'; + : (values))).join(','); + const url = `${this.dataUrl}/${api}/${ids}/string`; if (!this.labelsCache[url]) { this.labelsCache[url] = this.http.get(url, this.getHttpOptions()) @@ -623,13 +622,17 @@ export class IsariDataService { })); } + resetTemForeignKeys() { + this.tempForeignKeys = {}; + } + buildForm(layout, data, base = false): FormGroup { let form = this.fb.group({}); let fields = layout.reduce((acc, cv) => [...acc, ...cv.fields], []); // reset tempForeignKeys if (base) { - this.tempForeignKeys = {}; + this.resetTemForeignKeys(); } // build form from object after layout manipluation