From f150d4d2a14d8f8bd1dc5b88f50a5e01360e547c Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Thu, 26 Sep 2019 10:57:06 +0200
Subject: [PATCH] FIX #11271 TIME 0:15 add empty model msg warn in indexation

---
 .../app/indexation/indexation.component.html  | 76 +++++++++++--------
 .../app/indexation/indexation.component.scss  | 14 ++++
 .../app/indexation/indexation.component.ts    |  1 +
 3 files changed, 60 insertions(+), 31 deletions(-)

diff --git a/src/frontend/app/indexation/indexation.component.html b/src/frontend/app/indexation/indexation.component.html
index 8ab476c27dd..170f7aecd58 100644
--- a/src/frontend/app/indexation/indexation.component.html
+++ b/src/frontend/app/indexation/indexation.component.html
@@ -3,36 +3,48 @@
         [fixedInViewport]="appService.getViewMode()" [opened]="appService.getViewMode() ? false : true"
         autoFocus="false" style="overflow-x:hidden;" [ngStyle]="{'width': appService.getViewMode() ? '95%' : '600px'}">
         <header-panel [snavLeft]="snav"></header-panel>
-        <div style="background: #F9F9F9;display: flex;padding: 10px;padding-left: 40px;padding-right: 40px;">
-            <button mat-button class="button-form-primary" [matMenuTriggerFor]="IndexingModelsMenu" style="flex:1;margin-right:20px;">
-                <span class="menu-label">
-                    {{currentIndexingModel.label}} {{currentIndexingModel.default ? '(par défaut)': ''}}
-                </span>
-                <i class="fa fa-chevron-down menu-icon"></i></button>
-            <mat-menu #IndexingModelsMenu="matMenu" [class]="'menuForm'">
-                <ng-container *ngFor="let indexingModel of indexingModels">
-                        <button *ngIf="indexingModel.id !== currentIndexingModel.id" mat-menu-item (click)="loadIndexingModel(indexingModel)">{{indexingModel.label}} {{indexingModel.default ? '(par défaut)': ''}}</button>
-                </ng-container>
-            </mat-menu>
-            <button mat-button class="button-form-primary"
-                style="flex:1;align-items: center;justify-content: center;text-align: center;display: flex;">Enregistrer
-                comme modèle</button>
-        </div>
-        <div class="indexing-form-container">
-            <app-indexing-form *ngIf="currentIndexingModel.id !== undefined" #indexingForm [groupId]="currentGroupId" [indexingFormId]="currentIndexingModel.id"></app-indexing-form>
-        </div>
-        <div class="actions-indexing-form">
-            <button mat-button class="button-form-primary" [matMenuTriggerFor]="menu" style="flex:1;margin-right:20px;">
-                <span class="menu-label">
-                    Enregistrer (par défaut)
-                </span>
-                <i class="fa fa-chevron-down menu-icon"></i></button>
-            <mat-menu #menu="matMenu" [class]="'menuForm'">
-                <button mat-menu-item>Item 1</button>
-                <button mat-menu-item>Item 2</button>
-            </mat-menu>
-            <button mat-button class="button-form-primary"
-                style="width: 150px;align-items: center;justify-content: center;text-align: center;display: flex;" (click)="onSubmit()">Valider</button>
+        <ng-container *ngIf="indexingModels.length > 0">
+            <div style="background: #F9F9F9;display: flex;padding: 10px;padding-left: 40px;padding-right: 40px;">
+                <button mat-button class="button-form-primary" [matMenuTriggerFor]="IndexingModelsMenu"
+                    style="flex:1;margin-right:20px;">
+                    <span class="menu-label">
+                        {{currentIndexingModel.label}} {{currentIndexingModel.default ? '(par défaut)': ''}}
+                    </span>
+                    <i class="fa fa-chevron-down menu-icon"></i></button>
+                <mat-menu #IndexingModelsMenu="matMenu" [class]="'menuForm'">
+                    <ng-container *ngFor="let indexingModel of indexingModels">
+                        <button *ngIf="indexingModel.id !== currentIndexingModel.id" mat-menu-item
+                            (click)="loadIndexingModel(indexingModel)">{{indexingModel.label}}
+                            {{indexingModel.default ? '(par défaut)': ''}}</button>
+                    </ng-container>
+                </mat-menu>
+                <button mat-button class="button-form-primary"
+                    style="flex:1;align-items: center;justify-content: center;text-align: center;display: flex;">Enregistrer
+                    comme modèle</button>
+            </div>
+            <div class="indexing-form-container">
+                <app-indexing-form *ngIf="currentIndexingModel.id !== undefined" #indexingForm
+                    [groupId]="currentGroupId" [indexingFormId]="currentIndexingModel.id"></app-indexing-form>
+            </div>
+            <div class="actions-indexing-form">
+                <button mat-button class="button-form-primary" [matMenuTriggerFor]="menu"
+                    style="flex:1;margin-right:20px;">
+                    <span class="menu-label">
+                        Enregistrer (par défaut)
+                    </span>
+                    <i class="fa fa-chevron-down menu-icon"></i></button>
+                <mat-menu #menu="matMenu" [class]="'menuForm'">
+                    <button mat-menu-item>Item 1</button>
+                    <button mat-menu-item>Item 2</button>
+                </mat-menu>
+                <button mat-button class="button-form-primary"
+                    style="width: 150px;align-items: center;justify-content: center;text-align: center;display: flex;"
+                    (click)="onSubmit()">Valider</button>
+            </div>
+        </ng-container>
+        <div *ngIf="indexingModels.length === 0" class="emptyModel">
+            Aucun modèle d'enregistrement disponible<br/><br/>
+            <small>Veuillez créer un modèle depuis Administation > Modèle d'enregistrement</small>
         </div>
     </mat-sidenav>
     <mat-sidenav-content>
@@ -62,7 +74,9 @@
                         <button mat-menu-item>Item 1</button>
                         <button mat-menu-item>Item 2</button>
                     </mat-menu>
-                    <button mat-button class="button-form-primary" style="align-items: center;justify-content: center;text-align: center;display: flex;">Choisissez votre fichier</button>
+                    <button mat-button class="button-form-primary"
+                        style="align-items: center;justify-content: center;text-align: center;display: flex;">Choisissez
+                        votre fichier</button>
                 </div>
             </div>
         </div>
diff --git a/src/frontend/app/indexation/indexation.component.scss b/src/frontend/app/indexation/indexation.component.scss
index 13c8adc0c3b..cef66867725 100644
--- a/src/frontend/app/indexation/indexation.component.scss
+++ b/src/frontend/app/indexation/indexation.component.scss
@@ -58,4 +58,18 @@
     box-shadow: 0 -5px 10px 0 rgba(0, 0, 0, 0.07);
     padding-left: 40px;
     padding-right: 40px;
+}
+
+.emptyModel {
+    display: flex;
+    flex-direction: column;
+    height: 100%;
+    align-items: center;
+    justify-content: center;
+    text-align: center;
+    padding-left: 20px;
+    padding-right: 20px;
+    font-size: 25px;
+    opacity: 0.3;
+    font-weight: bold;
 }
\ No newline at end of file
diff --git a/src/frontend/app/indexation/indexation.component.ts b/src/frontend/app/indexation/indexation.component.ts
index 27fbc5bbf56..e4c8f70ec08 100644
--- a/src/frontend/app/indexation/indexation.component.ts
+++ b/src/frontend/app/indexation/indexation.component.ts
@@ -62,6 +62,7 @@ export class IndexationComponent implements OnInit {
                 tap((data: any) => {
                     //
                     this.indexingModels = data.indexingModels;
+                    console.log(this.indexingModels.length);
                     this.currentIndexingModel = this.indexingModels.filter(model => model.default === true)[0];
                 }),
                 finalize(() => this.loading = false),
-- 
GitLab