From c9cf482b2d1c15aa601656870088e5acc14aa789 Mon Sep 17 00:00:00 2001
From: Guillaume Heurtier <guillaume.heurtier@maarch.org>
Date: Thu, 2 Jan 2020 17:12:54 +0100
Subject: [PATCH] FEAT #12327 TIME 1:10 disable view document icon if no
 document

---
 src/app/resource/controllers/ResourceListController.php | 4 +++-
 src/frontend/app/list/basket-list.component.html        | 5 +++--
 src/frontend/app/list/basket-list.component.ts          | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/app/resource/controllers/ResourceListController.php b/src/app/resource/controllers/ResourceListController.php
index a85764979c9..2ba91589c70 100644
--- a/src/app/resource/controllers/ResourceListController.php
+++ b/src/app/resource/controllers/ResourceListController.php
@@ -101,7 +101,8 @@ class ResourceListController
             $select = [
                 'res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.barcode', 'res_letterbox.alt_identifier',
                 'status.label_status AS "status.label_status"', 'status.img_filename AS "status.img_filename"', 'priorities.color AS "priorities.color"',
-                'res_letterbox.closing_date', 'res_letterbox.locker_user_id', 'res_letterbox.locker_time', 'res_letterbox.confidentiality'
+                'res_letterbox.closing_date', 'res_letterbox.locker_user_id', 'res_letterbox.locker_time', 'res_letterbox.confidentiality',
+                'res_letterbox.filename as res_filename'
             ];
             $tableFunction = ['status', 'priorities'];
             $leftJoinFunction = ['res_letterbox.status = status.id', 'res_letterbox.priority = priorities.id'];
@@ -772,6 +773,7 @@ class ResourceListController
             $formattedResources[$key]['priorityColor']      = $resource['priorities.color'];
             $formattedResources[$key]['closing_date']       = $resource['closing_date'];
             $formattedResources[$key]['countAttachments']   = 0;
+            $formattedResources[$key]['hasDocument']        = $resource['res_filename'] != null;
             foreach ($attachments as $attachment) {
                 if ($attachment['res_id_master'] == $resource['res_id']) {
                     $formattedResources[$key]['countAttachments'] = $attachment['count'];
diff --git a/src/frontend/app/list/basket-list.component.html b/src/frontend/app/list/basket-list.component.html
index cf3da057077..a1561c1eaee 100644
--- a/src/frontend/app/list/basket-list.component.html
+++ b/src/frontend/app/list/basket-list.component.html
@@ -160,7 +160,8 @@
                                                 <mat-icon fontSet="fas" fontIcon="fa-sitemap fa-2x" [color]="snav2.opened && row.checked && currentMode == 'diffusion' ? 'primary' : ''"></mat-icon>
                                             </button>
                                             <button mat-icon-button title="{{lang.viewResource}}" (click)="$event.stopPropagation();viewDocument(row)"
-                                                (mouseenter)="viewThumbnail(row);" (mouseleave)="closeThumbnail();">
+                                                (mouseenter)="viewThumbnail(row);" (mouseleave)="closeThumbnail();"
+                                                [disabled]="!row.hasDocument">
                                                 <mat-icon  fontSet="fas" fontIcon="fa-eye fa-2x"></mat-icon>
                                             </button>
                                             <button mat-icon-button title="{{lang.linkDetails}}"
@@ -204,4 +205,4 @@
     </mat-sidenav-container>
     <app-actions-list (refreshEvent)="refreshDao()" (refreshEventAfterAction)="refreshDaoAfterAction()" #actionsListContext [contextMode]="true"
         [totalRes]="allResInBasket.length" [selectedRes]="selectedRes" [currentBasketInfo]="currentBasketInfo" (refreshPanelFolders)="panelFolder.refreshFoldersTree()">
-    </app-actions-list>
\ No newline at end of file
+    </app-actions-list>
diff --git a/src/frontend/app/list/basket-list.component.ts b/src/frontend/app/list/basket-list.component.ts
index fd2905c1f2e..30dc65a6ab9 100755
--- a/src/frontend/app/list/basket-list.component.ts
+++ b/src/frontend/app/list/basket-list.component.ts
@@ -300,7 +300,7 @@ export class BasketListComponent implements OnInit {
             Object.keys(element).forEach((key) => {
                 if (key == 'statusImage' && element[key] == null) {
                     element[key] = 'fa-question undefined';
-                } else if ((element[key] == null || element[key] == '') && ['closingDate', 'countAttachments', 'countNotes', 'display', 'folders'].indexOf(key) === -1) {
+                } else if ((element[key] == null || element[key] == '') && ['closingDate', 'countAttachments', 'countNotes', 'display', 'folders', 'hasDocument'].indexOf(key) === -1) {
                     element[key] = this.lang.undefined;
                 }
             });
-- 
GitLab