From 59d5373c43954ed4201e221be02cba6465e2087a Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Mon, 30 Sep 2019 17:45:51 +0200
Subject: [PATCH] FIX #11271 TIME 0:10 fix default launch + fix if no default
 model

---
 src/frontend/app/indexation/indexation.component.ts      | 5 ++++-
 .../indexation/indexing-form/indexing-form.component.ts  | 9 +++++++--
 src/frontend/lang/lang-en.ts                             | 1 +
 src/frontend/lang/lang-fr.ts                             | 1 +
 src/frontend/lang/lang-nl.ts                             | 1 +
 5 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/frontend/app/indexation/indexation.component.ts b/src/frontend/app/indexation/indexation.component.ts
index 5e3e56bc20a..def6c7916d7 100644
--- a/src/frontend/app/indexation/indexation.component.ts
+++ b/src/frontend/app/indexation/indexation.component.ts
@@ -64,7 +64,10 @@ export class IndexationComponent implements OnInit {
                 tap((data: any) => {
                     this.indexingModels = data.indexingModels;
                     this.currentIndexingModel = this.indexingModels.filter(model => model.default === true)[0];
-
+                    if (this.currentIndexingModel === undefined) {
+                        this.currentIndexingModel = this.indexingModels[0];
+                        this.notify.error(this.lang.noDefaultIndexingModel);
+                    }
                     if (this.appService.getViewMode()) {
                         setTimeout(() => {
                             this.sidenavLeft.open();
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 ae8b5aaee26..251c6506314 100644
--- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts
+++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts
@@ -373,7 +373,9 @@ export class IndexingFormComponent implements OnInit {
                         } else if (elem.identifier === 'priority') {
                             elem.values = data.priorities;
                             elem.event = 'setPriorityColor';
-                            this.setPriorityColor(elem, elem.default_value);
+                            if (elem.default_value !== '') {
+                                this.setPriorityColor(elem, elem.default_value);
+                            }
                         } else if (elem.identifier === 'doctype') {
                             let title = '';
                             let arrValues: any[] = [];
@@ -410,7 +412,10 @@ export class IndexingFormComponent implements OnInit {
                             });
                             elem.values = arrValues;
                             elem.event = 'calcLimitDate';
-                            this.calcLimitDate(elem, elem.default_value);
+                            if (elem.default_value !== '') {
+                                this.calcLimitDate(elem, elem.default_value);
+                            }
+                            
                         }
                     });
                 });
diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts
index 08754f8a5a0..fa5bafcee76 100755
--- a/src/frontend/lang/lang-en.ts
+++ b/src/frontend/lang/lang-en.ts
@@ -1132,4 +1132,5 @@ export const LANG_EN = {
     "noAvaiblableAction" : "<b>No available action</b>, please set an action in <b>Administration > Users groups > Mail indexing</b>.",
     "eraseValue" : "Erase value",
     "todayDate" : "Today date",
+    "noDefaultIndexingModel" : "No default indexing model found, the first model of the list have been loaded.",
 };
diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts
index 21e4c4b2b21..dfce1c2c9d6 100755
--- a/src/frontend/lang/lang-fr.ts
+++ b/src/frontend/lang/lang-fr.ts
@@ -1169,4 +1169,5 @@ export const LANG_FR = {
     "noAvaiblableAction" : "<b>Aucune action disponible</b>, veuillez paramétrer une action dans <b>Administration > Groupes d'utilisateurs > Enregistrement de courrier</b>.",
     "eraseValue" : "Effacer la valeur",
     "todayDate" : "Date du jour",
+    "noDefaultIndexingModel" : "Aucun modèle par défaut trouvé, chargement du premier de la liste.",
 };
diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts
index b19e508a050..792d7e0579b 100755
--- a/src/frontend/lang/lang-nl.ts
+++ b/src/frontend/lang/lang-nl.ts
@@ -1158,4 +1158,5 @@ export const LANG_NL = {
     "noAvaiblableAction" : "<b>No available action</b>, please set an action in <b>Administration > User groups > Mail indexing</b>.", //_TO_TRANSLATE
     "eraseValue" : "Erase value", //_TO_TRANSLATE
     "todayDate" : "Today date", //_TO_TRANSLATE
+    "noDefaultIndexingModel" : "No default indexing model found, the first model of the list have been loaded.", //_TO_TRANSLATE
 };
-- 
GitLab