From 4cb373086b40763b60028590d986ace576f7c999 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Wed, 29 Apr 2020 14:46:20 +0200
Subject: [PATCH] FEAT #13827 TIME 0:20 fix selected indexing model

---
 .../select-indexing-model/select-indexing-model.component.ts  | 4 +++-
 src/frontend/app/process/process.component.html               | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/frontend/app/indexation/select-indexing-model/select-indexing-model.component.ts b/src/frontend/app/indexation/select-indexing-model/select-indexing-model.component.ts
index e1defda58ae..12e35335d21 100644
--- a/src/frontend/app/indexation/select-indexing-model/select-indexing-model.component.ts
+++ b/src/frontend/app/indexation/select-indexing-model/select-indexing-model.component.ts
@@ -23,6 +23,7 @@ export class SelectIndexingModelComponent implements OnInit {
     lang: any = LANG;
     loading: boolean = true;
 
+    @Input() defaultIndexingModelId: number = null;
     @Input() indexingModels: any = [];
     @Input() indexingForm: IndexingFormComponent;
     @Input() adminMode: boolean = false;
@@ -49,7 +50,8 @@ export class SelectIndexingModelComponent implements OnInit {
             tap((data: any) => {
                 this.indexingModels = data.indexingModels;
                 if (this.indexingModels.length > 0) {
-                    this.currentIndexingModel = this.indexingModels.filter((model: any) => model.default === true)[0];
+                    this.currentIndexingModel = this.defaultIndexingModelId === null ? this.indexingModels.filter((model: any) => model.default === true)[0] : this.indexingModels.filter((model: any) => model.id === this.defaultIndexingModelId)[0];
+
                     if (this.currentIndexingModel === undefined) {
                         this.currentIndexingModel = this.indexingModels[0];
                         this.notify.error(this.lang.noDefaultIndexingModel);
diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html
index 58a62840168..e4348249c59 100644
--- a/src/frontend/app/process/process.component.html
+++ b/src/frontend/app/process/process.component.html
@@ -101,7 +101,7 @@
                     [resId]="currentResourceInformations.resId" [autoOpenCreation]="isMailing" [target]="'process'"
                     (reloadBadgeAttachments)="refreshBadge($event,'attachments')">
                 </app-attachments-list>
-                <app-select-indexing-model *ngIf="currentTool === 'info' && !loading" #appSelectIndexingModel [adminMode]="canChangeModel" [indexingForm]="indexingForm" (afterSelectedListModel)="this.currentIndexingModel = $event;indexingForm.loadForm($event.id, false)"></app-select-indexing-model>
+                <app-select-indexing-model *ngIf="currentTool === 'info' && !loading" #appSelectIndexingModel [defaultIndexingModelId]="currentResourceInformations.modelId" [adminMode]="canChangeModel" [indexingForm]="indexingForm" (afterSelectedListModel)="this.currentIndexingModel = $event;indexingForm.loadForm($event.id, false)"></app-select-indexing-model>
                 <app-indexing-form *ngIf="currentTool === 'info' && !loading" #indexingForm [groupId]="currentGroupId"
                     [resId]="currentResourceInformations.resId" [indexingFormId]="currentResourceInformations.modelId"
                     [mode]="'process'" [canEdit]="canEditData" [hideDiffusionList]="true"
@@ -287,7 +287,7 @@
                 <app-attachments-list *ngIf="modal.id === 'attachments'  && !loading" #appAttachmentsList
                     [resId]="currentResourceInformations.resId" [autoOpenCreation]="isMailing" (reloadBadgeAttachments)="refreshBadge($event,'attachments')">
                 </app-attachments-list>
-                <app-select-indexing-model *ngIf="modal.id === 'info' && !loading" #appSelectIndexingModel [adminMode]="canChangeModel" [indexingForm]="indexingForm" (afterSelectedListModel)="this.currentIndexingModel = $event;indexingForm.loadForm($event.id, false)"></app-select-indexing-model>
+                <app-select-indexing-model *ngIf="modal.id === 'info' && !loading" #appSelectIndexingModel [adminMode]="canChangeModel" [indexingForm]="indexingForm" [defaultIndexingModelId]="currentResourceInformations.modelId" (afterSelectedListModel)="this.currentIndexingModel = $event;indexingForm.loadForm($event.id, false)"></app-select-indexing-model>
                 <app-indexing-form *ngIf="modal.id === 'info' && !loading" #indexingForm [groupId]="currentGroupId"
                     [indexingFormId]="currentResourceInformations.modelId" [resId]="currentResourceInformations.resId"
                     [mode]="'process'" [canEdit]="canEditData" [hideDiffusionList]="true"
-- 
GitLab