From 1dd93fdfe23c005be258aa30ad75a40204190994 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Thu, 5 Dec 2019 16:44:13 +0100
Subject: [PATCH] FIX #12331 TIME 0:20 set custom field resource

---
 .../indexing-form/indexing-form.component.ts       | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts
index 026665e40f3..c8ced3dc78e 100644
--- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts
+++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts
@@ -542,10 +542,17 @@ export class IndexingFormComponent implements OnInit {
             tap((data: any) => {
                 this.fieldCategories.forEach(element => {
                     this['indexingModels_' + element].forEach((elem: any) => {
-
-                        if (Object.keys(data).indexOf(elem.identifier) > -1) {
-                            let fieldValue = data[elem.identifier];
+                        const customId: any = Object.keys(data.customFields).filter(index => index === elem.identifier.split('indexingCustomField_')[1])[0];
+                        
+                        if (Object.keys(data).indexOf(elem.identifier) > -1 || customId !== undefined) {
+                            let fieldValue: any = '';
                             
+                            if (customId !== undefined) {
+                                fieldValue = data.customFields[customId]; 
+                            } else {
+                                fieldValue = data[elem.identifier];  
+                            }
+                                                       
                             if (elem.type === 'date') {
                                 fieldValue = new Date(fieldValue);
                             }
@@ -560,6 +567,7 @@ export class IndexingFormComponent implements OnInit {
                                 }
                                 this.arrFormControl['diffusionList'].disable();
                             }
+                            
                             this.arrFormControl[elem.identifier].setValue(fieldValue);
                         }
                         if (!this.canEdit) {
-- 
GitLab