From c27e3664b7d45e641bbaa0e6569e9c36806a66b6 Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Tue, 29 Dec 2020 14:18:13 +0100
Subject: [PATCH] FIX #15677 TIME 0:30 Count circuit history + space fix

---
 src/app/entity/controllers/ListInstanceController.php        | 5 +++--
 src/app/entity/controllers/ListInstanceHistoryController.php | 1 +
 .../history/history-diffusions-list.component.html           | 4 +++-
 .../app/visa/history/history-visa-workflow.component.html    | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/app/entity/controllers/ListInstanceController.php b/src/app/entity/controllers/ListInstanceController.php
index 8e9db680bb8..c60a016c59b 100755
--- a/src/app/entity/controllers/ListInstanceController.php
+++ b/src/app/entity/controllers/ListInstanceController.php
@@ -98,10 +98,11 @@ class ListInstanceController
         $hasHistory = ListInstanceHistoryDetailModel::get([
             'select'    => [1],
             'where'     => ['difflist_type = ?', 'res_id = ?'],
-            'data'      => ['VISA_CIRCUIT', $aArgs['resId']]
+            'data'      => ['VISA_CIRCUIT', $aArgs['resId']],
+            'groupBy'   => ['listinstance_history_id']
         ]);
 
-        return $response->withJson(['circuit' => $listInstances, 'hasHistory' => !empty($hasHistory)]);
+        return $response->withJson(['circuit' => $listInstances, 'hasHistory' => count($hasHistory) > 1]);
     }
 
     public function getOpinionCircuitByResId(Request $request, Response $response, array $aArgs)
diff --git a/src/app/entity/controllers/ListInstanceHistoryController.php b/src/app/entity/controllers/ListInstanceHistoryController.php
index 480c0c1eb0b..33e5ad90f22 100644
--- a/src/app/entity/controllers/ListInstanceHistoryController.php
+++ b/src/app/entity/controllers/ListInstanceHistoryController.php
@@ -134,6 +134,7 @@ class ListInstanceHistoryController
                 ];
             }
         }
+        array_pop($formattedHistory);
         $formattedHistory = array_reverse($formattedHistory);
 
         return $response->withJson(['listInstanceHistory' => $formattedHistory]);
diff --git a/src/frontend/app/diffusions/history/history-diffusions-list.component.html b/src/frontend/app/diffusions/history/history-diffusions-list.component.html
index 56c1e098f90..cbe9d48651d 100644
--- a/src/frontend/app/diffusions/history/history-diffusions-list.component.html
+++ b/src/frontend/app/diffusions/history/history-diffusions-list.component.html
@@ -1,7 +1,9 @@
 <ng-container *ngIf="!loading">
     <ng-container *ngFor="let diffList of diffListHistory">
         <div class="dateTitle">
-            <div mat-subheader color="primary" [title]="diffList.creationDate | fullDate">{{'lang.list' | translate}}&nbsp;<b>{{diffList.creationDate | timeAgo : 'full'}}</b>&nbsp;{{'lang.by' | translate | lowercase}}&nbsp;<b>{{diffList.user}}</b></div>
+            <div mat-subheader color="primary" [title]="diffList.creationDate | fullDate">
+                {{'lang.createdBy' | translate}}&nbsp;<b>{{diffList.user}}</b> &nbsp;<b>{{diffList.creationDate | timeAgo : 'full'}}</b>
+            </div>
             <mat-divider></mat-divider>
         </div>
         <ng-container *ngFor="let role of availableRoles">
diff --git a/src/frontend/app/visa/history/history-visa-workflow.component.html b/src/frontend/app/visa/history/history-visa-workflow.component.html
index a44f4951c40..1dea5cf343c 100644
--- a/src/frontend/app/visa/history/history-visa-workflow.component.html
+++ b/src/frontend/app/visa/history/history-visa-workflow.component.html
@@ -3,7 +3,7 @@
         <mat-list>
             <div class="dateTitle">
                 <div mat-subheader class="primary" [title]="visaWorkflow.creationDate | fullDate">
-                    {{'lang.createdBy' | translate }} {{visaWorkflow.user}} &nbsp;<b>{{visaWorkflow.creationDate | timeAgo : 'full'}}</b>
+                    {{'lang.createdBy' | translate }}&nbsp;<b>{{visaWorkflow.user}}</b> &nbsp;<b>{{visaWorkflow.creationDate | timeAgo : 'full'}}</b>
                 </div>
                 <mat-divider></mat-divider>
             </div>
-- 
GitLab