From df2101778a0297ff7c390713a007da13f24d747c Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Wed, 28 Oct 2020 11:50:12 +0100
Subject: [PATCH] FEAT #15301 TIME 0:10 fix get custom fields

---
 .../service/indexing-fields.service.ts        | 60 +++++++++----------
 1 file changed, 28 insertions(+), 32 deletions(-)

diff --git a/src/frontend/service/indexing-fields.service.ts b/src/frontend/service/indexing-fields.service.ts
index 3c83485e635..f26353fceac 100644
--- a/src/frontend/service/indexing-fields.service.ts
+++ b/src/frontend/service/indexing-fields.service.ts
@@ -416,38 +416,34 @@ export class IndexingFieldsService {
 
     getCustomFields() {
         return new Promise((resolve, reject) => {
-            if (this.customFields.length > 0) {
-                resolve(this.customFields);
-            } else {
-                this.http.get('../rest/customFields').pipe(
-                    tap((data: any) => {
-                        this.customFields = data.customFields.map((info: any) => {
-                            info.identifier = 'indexingCustomField_' + info.id;
-                            info.icon = 'fa-hashtag';
-                            info.system = false;
-                            info.enabled = true;
-                            info.SQLMode = info.SQLMode;
-                            if (['integer', 'string', 'date'].indexOf(info.type) > -1 && !this.functions.empty(info.values)) {
-                                info.default_value = info.values[0].key;
-                            } else {
-                                info.default_value = info.type === 'banAutocomplete' ? [] : null;
-                            }
-                            info.values = info.values.length > 0 ? info.values.map((custVal: any) => {
-                                return {
-                                    id: custVal.key,
-                                    label: custVal.label
-                                };
-                            }) : info.values;
-                            return info;
-                        });
-                    }),
-                    finalize(() => resolve(this.customFields)),
-                    catchError((err: any) => {
-                        this.notify.handleSoftErrors(err);
-                        return of(false);
-                    })
-                ).subscribe();
-            }
+            this.http.get('../rest/customFields').pipe(
+                tap((data: any) => {
+                    this.customFields = data.customFields.map((info: any) => {
+                        info.identifier = 'indexingCustomField_' + info.id;
+                        info.icon = 'fa-hashtag';
+                        info.system = false;
+                        info.enabled = true;
+                        info.SQLMode = info.SQLMode;
+                        if (['integer', 'string', 'date'].indexOf(info.type) > -1 && !this.functions.empty(info.values)) {
+                            info.default_value = info.values[0].key;
+                        } else {
+                            info.default_value = info.type === 'banAutocomplete' ? [] : null;
+                        }
+                        info.values = info.values.length > 0 ? info.values.map((custVal: any) => {
+                            return {
+                                id: custVal.key,
+                                label: custVal.label
+                            };
+                        }) : info.values;
+                        return info;
+                    });
+                }),
+                finalize(() => resolve(this.customFields)),
+                catchError((err: any) => {
+                    this.notify.handleSoftErrors(err);
+                    return of(false);
+                })
+            ).subscribe();
         });
     }
 
-- 
GitLab