From 18c5bb988ddaa936a8c9a416ae906ea373cb79f6 Mon Sep 17 00:00:00 2001
From: Jean-Laurent <jean-laurent.duzant@xelians.fr>
Date: Tue, 2 Aug 2022 15:51:59 +0200
Subject: [PATCH] FIX #21555 TIME 0:10 launch priority event && send priority
 to API when null

---
 .../indexing-form/indexing-form.component.ts       | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 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 a9b5bfb05fd..a5922f5d480 100755
--- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts
+++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts
@@ -1218,7 +1218,9 @@ export class IndexingFormComponent implements OnInit {
     }
 
     launchEvent(value: any, field: any) {
-        if (field.event !== undefined && value !== null && !this.adminMode) {
+        if (field.event !== undefined && field.identifier === 'priority' && value === null) {
+            this[field.event](field, value);
+        } else if (field.event !== undefined && value !== null && !this.adminMode) {
             this[field.event](field, value);
         }
     }
@@ -1227,9 +1229,9 @@ export class IndexingFormComponent implements OnInit {
         let limitDate: any = null;
         const objToSend: any = {
             doctype: value,
-            priority: this.arrFormControl['priority'].value
+            priority: this.arrFormControl['priority']?.value
         };
-        if (this.functions.empty(this.arrFormControl['priority'].value)) {
+        if (this.functions.empty(this.arrFormControl['priority']?.value)) {
             delete objToSend.priority;
         }
         if (this.arrFormControl['processLimitDate'] !== undefined) {
@@ -1256,10 +1258,12 @@ export class IndexingFormComponent implements OnInit {
         let limitDate: any = null;
         const objToSend: any = {
             priority: value,
-            doctype: this.arrFormControl['doctype'].value
+            doctype: this.arrFormControl['doctype']?.value
         };
-        if (this.functions.empty(this.arrFormControl['doctype'].value)) {
+        if (!this.functions.empty(objToSend.priority) && this.functions.empty(this.arrFormControl['doctype']?.value)) {
             delete objToSend.doctype;
+        } else if (this.functions.empty(objToSend.priority) && !this.functions.empty(this.arrFormControl['doctype']?.value)) {
+            delete objToSend.priority;
         }
         if (this.arrFormControl['processLimitDate'] !== undefined) {
             this.http.get('../rest/indexing/processLimitDate', { params: objToSend }).pipe(
-- 
GitLab