From 5784d24298a3abae0342a022d06612ac83b124b9 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Wed, 6 Nov 2019 11:34:04 +0100
Subject: [PATCH] FEAT #12033 TIME 0:25 fix digest (limit + show more)

---
 .../attachments-resume.component.html         | 34 +++++++++----------
 .../attachments-resume.component.scss         | 17 ++++++++++
 .../attachments-resume.component.ts           |  9 +++--
 .../history-workflow-resume.component.html    | 18 +++++-----
 .../history-workflow-resume.component.scss    | 17 ++++++++++
 .../history-workflow-resume.component.ts      |  9 +++--
 .../mail-resume/mail-resume.component.html    | 24 ++++++-------
 .../mail-resume/mail-resume.component.scss    | 17 ++++++++++
 .../mail/mail-resume/mail-resume.component.ts |  9 +++--
 .../note-resume/note-resume.component.html    | 24 ++++++-------
 .../note-resume/note-resume.component.scss    | 17 ++++++++++
 .../note-resume/note-resume.component.ts      |  9 +++--
 .../app/process/process.component.html        |  8 ++---
 src/frontend/app/process/process.component.ts |  7 ++++
 src/frontend/lang/lang-en.ts                  |  1 +
 src/frontend/lang/lang-fr.ts                  |  1 +
 src/frontend/lang/lang-nl.ts                  |  1 +
 17 files changed, 156 insertions(+), 66 deletions(-)

diff --git a/src/frontend/app/attachments/attachments-resume/attachments-resume.component.html b/src/frontend/app/attachments/attachments-resume/attachments-resume.component.html
index 49f77dda04b..ce84e2bb533 100644
--- a/src/frontend/app/attachments/attachments-resume/attachments-resume.component.html
+++ b/src/frontend/app/attachments/attachments-resume/attachments-resume.component.html
@@ -4,27 +4,25 @@
     </div>
 </ng-container>
 <ng-template #elseTemplate>
-    <ng-container *ngFor="let attachment of attachments">
-        <div class="attachmentsList" (click)="showAttachment(attachment)">
-            <ng-container *ngIf="attachment.update_date !== null; else elseTemplate">
-                <div class="date" [title]="attachment.update_date | fullDate">
-                    {{attachment.update_date | timeAgo}}
-                </div>
-            </ng-container>
-            <ng-template #elseTemplate>
-                <div class="date" [title]="attachment.creation_date | fullDate">
-                    {{attachment.creation_date | timeAgo}}
-                </div>
-            </ng-template>
-            <div class="info">
-                {{attachment.title}}
+    <div class="attachmentsList" *ngFor="let attachment of attachments" (click)="showAttachment(attachment)">
+        <ng-container *ngIf="attachment.update_date !== null; else elseTemplate">
+            <div class="date" [title]="attachment.update_date | fullDate">
+                {{attachment.update_date | timeAgo}}
             </div>
-            <div class="attachmentType">
-                {{attachment.typeLabel}}
+        </ng-container>
+        <ng-template #elseTemplate>
+            <div class="date" [title]="attachment.creation_date | fullDate">
+                {{attachment.creation_date | timeAgo}}
             </div>
+        </ng-template>
+        <div class="info">
+            {{attachment.title}}
         </div>
-        <mat-divider></mat-divider>
-    </ng-container>
+        <div class="attachmentType">
+            {{attachment.typeLabel}}
+        </div>
+    </div>
+    <button mat-button *ngIf="attachments.length === 3" class="showMore" (click)="showMore()">{{lang.showMore}}</button>
     <div class="noData" *ngIf="attachments.length === 0">
         {{lang.noAttachment}}
     </div>
diff --git a/src/frontend/app/attachments/attachments-resume/attachments-resume.component.scss b/src/frontend/app/attachments/attachments-resume/attachments-resume.component.scss
index 8edeb08880c..92d43247cbc 100644
--- a/src/frontend/app/attachments/attachments-resume/attachments-resume.component.scss
+++ b/src/frontend/app/attachments/attachments-resume/attachments-resume.component.scss
@@ -7,6 +7,10 @@
     display: grid;
     grid-template-columns: 15% 65% 20%;
     align-items: center;
+
+    &:nth-child(2n) {
+        background: rgba($primary, .1);
+    }
 }
 
 .date {
@@ -33,4 +37,17 @@
     display: flex;
     justify-content: center;
     height: 100%;
+}
+
+.showMore {
+    float: right;
+    font-size: 10px;
+    position: absolute;
+    right: 10px;
+    margin-top: -2px;
+    padding: 0;
+    line-height: 20px;
+    width: 35px;
+    color: $secondary;
+    font-weight: bold;
 }
\ No newline at end of file
diff --git a/src/frontend/app/attachments/attachments-resume/attachments-resume.component.ts b/src/frontend/app/attachments/attachments-resume/attachments-resume.component.ts
index 96889925ca1..5cefd4debbf 100644
--- a/src/frontend/app/attachments/attachments-resume/attachments-resume.component.ts
+++ b/src/frontend/app/attachments/attachments-resume/attachments-resume.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
 import { LANG } from '../../translate.component';
 import { catchError, tap, finalize } from 'rxjs/operators';
@@ -25,6 +25,7 @@ export class AttachmentsResumeComponent implements OnInit {
     attachments: any[] = [];
 
     @Input('resId') resId: number = null;
+    @Output('goTo') goTo = new EventEmitter<string>();
 
     constructor(
         public http: HttpClient,
@@ -40,7 +41,7 @@ export class AttachmentsResumeComponent implements OnInit {
 
     loadAttachments(resId: number) {
         this.loading = true;
-        this.http.get(`../../rest/resources/${resId}/attachments?limit=2`).pipe(
+        this.http.get(`../../rest/resources/${resId}/attachments?limit=3`).pipe(
             tap((data: any) => {
                 this.attachments = data.attachments;
             }),
@@ -55,4 +56,8 @@ export class AttachmentsResumeComponent implements OnInit {
     showAttachment(attachment: any) {
         this.dialog.open(AttachmentShowModalComponent, { data: { attachment: attachment } });
     }
+
+    showMore() {
+        this.goTo.emit();
+    }
 }
\ No newline at end of file
diff --git a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.html b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.html
index 3966321b5dc..7ce47be4ee6 100644
--- a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.html
+++ b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.html
@@ -4,17 +4,15 @@
     </div>
 </ng-container>
 <ng-template #elseTemplate>
-    <ng-container *ngFor="let history of histories">
-        <div class="historyList">
-            <div class="date" [title]="history.event_date | fullDate">
-                {{history.event_date | timeAgo}}
-            </div>
-            <div class="info">
-                {{history.info}}
-            </div>
+    <div class="historyList" *ngFor="let history of histories">
+        <div class="date" [title]="history.event_date | fullDate">
+            {{history.event_date | timeAgo}}
         </div>
-        <mat-divider></mat-divider>
-    </ng-container>
+        <div class="info">
+            {{history.info}}
+        </div>
+    </div>
+    <button mat-button *ngIf="histories.length === 3" class="showMore" (click)="showMore()">{{lang.showMore}}</button>
     <div class="noData" *ngIf="histories.length === 0">
         {{lang.noEvent}}
     </div>
diff --git a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.scss b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.scss
index 8a6d80264df..99a77e53d89 100644
--- a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.scss
+++ b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.scss
@@ -6,6 +6,10 @@
     display: grid;
     grid-template-columns: 15% 85%;
     align-items: center;
+
+    &:nth-child(2n) {
+        background: rgba($primary, .1);
+    }
 }
 
 .date {
@@ -28,4 +32,17 @@
     display: flex;
     justify-content: center;
     height: 100%;
+}
+
+.showMore {
+    float: right;
+    font-size: 10px;
+    position: absolute;
+    right: 10px;
+    margin-top: -2px;
+    padding: 0;
+    line-height: 20px;
+    width: 35px;
+    color: $secondary;
+    font-weight: bold;
 }
\ No newline at end of file
diff --git a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.ts b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.ts
index a35ed2a601c..34d5ee84dc4 100644
--- a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.ts
+++ b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
 import { LANG } from '../../translate.component';
 import { catchError, tap, finalize } from 'rxjs/operators';
@@ -23,6 +23,7 @@ export class HistoryWorkflowResumeComponent implements OnInit {
     histories: any[] = [];
 
     @Input('resId') resId: number = null;
+    @Output('goTo') goTo = new EventEmitter<string>();
 
     constructor(
         public http: HttpClient,
@@ -37,7 +38,7 @@ export class HistoryWorkflowResumeComponent implements OnInit {
 
     loadHistory(resId: number) {
         this.loading = true;
-        this.http.get(`../../rest/histories/resources/${resId}/workflow?limit=2`).pipe(
+        this.http.get(`../../rest/histories/resources/${resId}/workflow?limit=3`).pipe(
             tap((data: any) => {
                 this.histories = data.history;
             }),
@@ -48,4 +49,8 @@ export class HistoryWorkflowResumeComponent implements OnInit {
             })
         ).subscribe();
     }
+
+    showMore() {
+        this.goTo.emit();
+    }
 }
\ No newline at end of file
diff --git a/src/frontend/app/mail/mail-resume/mail-resume.component.html b/src/frontend/app/mail/mail-resume/mail-resume.component.html
index af5fb0853b9..e27238fab2c 100644
--- a/src/frontend/app/mail/mail-resume/mail-resume.component.html
+++ b/src/frontend/app/mail/mail-resume/mail-resume.component.html
@@ -4,20 +4,18 @@
     </div>
 </ng-container>
 <ng-template #elseTemplate>
-    <ng-container *ngFor="let mail of mails">
-        <div class="mailList">
-            <div class="date" [title]="mail.creation_date | fullDate">
-                {{mail.send_date | timeAgo}}
-            </div>
-            <div class="info">
-                {{mail.object}}
-            </div>
-            <div class="date">
-                {{mail.userInfo}}
-            </div>
+    <div class="mailList" *ngFor="let mail of mails">
+        <div class="date" [title]="mail.creation_date | fullDate">
+            {{mail.send_date | timeAgo}}
         </div>
-        <mat-divider></mat-divider>
-    </ng-container>
+        <div class="info">
+            {{mail.object}}
+        </div>
+        <div class="date">
+            {{mail.userInfo}}
+        </div>
+    </div>
+    <button mat-button *ngIf="mails.length === 3" class="showMore" (click)="showMore()">{{lang.showMore}}</button>
     <div class="noData" *ngIf="mails.length === 0">
         {{lang.noSendmail}}
     </div>
diff --git a/src/frontend/app/mail/mail-resume/mail-resume.component.scss b/src/frontend/app/mail/mail-resume/mail-resume.component.scss
index 61b296c982b..4362deb31e5 100644
--- a/src/frontend/app/mail/mail-resume/mail-resume.component.scss
+++ b/src/frontend/app/mail/mail-resume/mail-resume.component.scss
@@ -6,6 +6,10 @@
     display: grid;
     grid-template-columns: 15% 70% 15%;
     align-items: center;
+
+    &:nth-child(2n) {
+        background: rgba($primary, .1);
+    }
 }
 
 .date {
@@ -28,4 +32,17 @@
     display: flex;
     justify-content: center;
     height: 100%;
+}
+
+.showMore {
+    float: right;
+    font-size: 10px;
+    position: absolute;
+    right: 10px;
+    margin-top: -2px;
+    padding: 0;
+    line-height: 20px;
+    width: 35px;
+    color: $secondary;
+    font-weight: bold;
 }
\ No newline at end of file
diff --git a/src/frontend/app/mail/mail-resume/mail-resume.component.ts b/src/frontend/app/mail/mail-resume/mail-resume.component.ts
index b56de933c36..5adea2cf954 100644
--- a/src/frontend/app/mail/mail-resume/mail-resume.component.ts
+++ b/src/frontend/app/mail/mail-resume/mail-resume.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
 import { LANG } from '../../translate.component';
 import { catchError, tap, finalize } from 'rxjs/operators';
@@ -23,6 +23,7 @@ export class MailResumeComponent implements OnInit {
     mails: any[] = [];
 
     @Input('resId') resId: number = null;
+    @Output('goTo') goTo = new EventEmitter<string>();
 
     constructor(
         public http: HttpClient,
@@ -37,7 +38,7 @@ export class MailResumeComponent implements OnInit {
 
     loadMails(resId: number) {
         this.loading = true;
-        this.http.get(`../../rest/externalSummary/${resId}?limit=2`).pipe(
+        this.http.get(`../../rest/externalSummary/${resId}?limit=3`).pipe(
             tap((data: any) => {
                 this.mails = data.elementsSend;
             }),
@@ -48,4 +49,8 @@ export class MailResumeComponent implements OnInit {
             })
         ).subscribe();
     }
+
+    showMore() {
+        this.goTo.emit();
+    }
 }
\ No newline at end of file
diff --git a/src/frontend/app/notes/note-resume/note-resume.component.html b/src/frontend/app/notes/note-resume/note-resume.component.html
index dba777db3af..9c791285fa2 100644
--- a/src/frontend/app/notes/note-resume/note-resume.component.html
+++ b/src/frontend/app/notes/note-resume/note-resume.component.html
@@ -4,20 +4,18 @@
     </div>
 </ng-container>
 <ng-template #elseTemplate>
-    <ng-container *ngFor="let note of notes">
-        <div class="noteList">
-            <div class="date" [title]="note.creation_date | fullDate">
-                {{note.creation_date | timeAgo}}
-            </div>
-            <div class="info">
-                {{note.value}}
-            </div>
-            <div class="date">
-                {{note.firstname}} {{note.lastname}}
-            </div>
+    <div class="noteList" *ngFor="let note of notes">
+        <div class="date" [title]="note.creation_date | fullDate">
+            {{note.creation_date | timeAgo}}
         </div>
-        <mat-divider></mat-divider>
-    </ng-container>
+        <div class="info">
+            {{note.value}}
+        </div>
+        <div class="date">
+            {{note.firstname}} {{note.lastname}}
+        </div>
+    </div>
+    <button mat-button *ngIf="notes.length === 3" class="showMore" (click)="showMore()">{{lang.showMore}}</button>
     <div class="noData" *ngIf="notes.length === 0">
         {{lang.noNote}}
     </div>
diff --git a/src/frontend/app/notes/note-resume/note-resume.component.scss b/src/frontend/app/notes/note-resume/note-resume.component.scss
index e3b8791997a..fe772e0b38e 100644
--- a/src/frontend/app/notes/note-resume/note-resume.component.scss
+++ b/src/frontend/app/notes/note-resume/note-resume.component.scss
@@ -6,6 +6,10 @@
     display: grid;
     grid-template-columns: 15% 70% 15%;
     align-items: center;
+
+    &:nth-child(2n) {
+        background: rgba($primary, .1);
+    }
 }
 
 .date {
@@ -29,4 +33,17 @@
     display: flex;
     justify-content: center;
     height: 100%;
+}
+
+.showMore {
+    float: right;
+    font-size: 10px;
+    position: absolute;
+    right: 10px;
+    margin-top: -2px;
+    padding: 0;
+    line-height: 20px;
+    width: 35px;
+    color: $secondary;
+    font-weight: bold;
 }
\ No newline at end of file
diff --git a/src/frontend/app/notes/note-resume/note-resume.component.ts b/src/frontend/app/notes/note-resume/note-resume.component.ts
index 3765fc7545a..4f23e18a604 100644
--- a/src/frontend/app/notes/note-resume/note-resume.component.ts
+++ b/src/frontend/app/notes/note-resume/note-resume.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
 import { LANG } from '../../translate.component';
 import { catchError, tap, finalize } from 'rxjs/operators';
@@ -23,6 +23,7 @@ export class NoteResumeComponent implements OnInit {
     notes: any[] = [];
 
     @Input('resId') resId: number = null;
+    @Output('goTo') goTo = new EventEmitter<string>();
 
     constructor(
         public http: HttpClient,
@@ -37,7 +38,7 @@ export class NoteResumeComponent implements OnInit {
 
     loadNotes(resId: number) {
         this.loading = true;
-        this.http.get(`../../rest/resources/${resId}/notes?limit=2`).pipe(
+        this.http.get(`../../rest/resources/${resId}/notes?limit=3`).pipe(
             tap((data: any) => {
                 this.notes = data.notes;
             }),
@@ -48,4 +49,8 @@ export class NoteResumeComponent implements OnInit {
             })
         ).subscribe();
     }
+
+    showMore() {
+        this.goTo.emit();
+    }
 }
\ No newline at end of file
diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html
index 2ef14dc5ba4..d92b56ab8f9 100644
--- a/src/frontend/app/process/process.component.html
+++ b/src/frontend/app/process/process.component.html
@@ -36,7 +36,7 @@
                         <div class="title-divider"></div>
                     </div>
                     <div class="content">
-                        <app-history-workflow-resume *ngIf="!loading" [resId]="currentResourceInformations.resId">
+                        <app-history-workflow-resume *ngIf="!loading" [resId]="currentResourceInformations.resId" (goTo)="currentTool = 'history'">
                         </app-history-workflow-resume>
                     </div>
                 </div>
@@ -46,7 +46,7 @@
                         <div class="title-divider"></div>
                     </div>
                     <div class="content">
-                        <app-note-resume *ngIf="!loading" [resId]="currentResourceInformations.resId"></app-note-resume>
+                        <app-note-resume *ngIf="!loading" [resId]="currentResourceInformations.resId" (goTo)="currentTool = 'notes'"></app-note-resume>
                     </div>
                 </div>
                 <div class="banner" [style.borderColor]="currentPriorityColor">
@@ -55,7 +55,7 @@
                         <div class="title-divider"></div>
                     </div>
                     <div class="content">
-                        <app-attachments-resume *ngIf="!loading" [resId]="currentResourceInformations.resId">
+                        <app-attachments-resume *ngIf="!loading" [resId]="currentResourceInformations.resId" (goTo)="currentTool = 'attachments'">
                         </app-attachments-resume>
                     </div>
                 </div>
@@ -65,7 +65,7 @@
                         <div class="title-divider"></div>
                     </div>
                     <div class="content">
-                        <app-mail-resume *ngIf="!loading" [resId]="currentResourceInformations.resId"></app-mail-resume>
+                        <app-mail-resume *ngIf="!loading" [resId]="currentResourceInformations.resId" (goTo)="currentTool = 'mails'"></app-mail-resume>
                     </div>
                 </div>
             </ng-container>
diff --git a/src/frontend/app/process/process.component.ts b/src/frontend/app/process/process.component.ts
index 231f4a54ea3..be8ab8fa113 100644
--- a/src/frontend/app/process/process.component.ts
+++ b/src/frontend/app/process/process.component.ts
@@ -190,6 +190,13 @@ export class ProcessComponent implements OnInit {
     }
 
     lockResource() {
+        this.http.put(`../../rest/resourcesList/users/${this.currentUserId}/groups/${this.currentGroupId}/baskets/${this.currentBasketId}/lock`, { resources: [this.currentResourceInformations.resId] }).pipe(
+            catchError((err: any) => {
+                this.notify.handleErrors(err);
+                return of(false);
+            })
+        ).subscribe();
+        
         this.currentResourceLock = setInterval(() => {
             this.http.put(`../../rest/resourcesList/users/${this.currentUserId}/groups/${this.currentGroupId}/baskets/${this.currentBasketId}/lock`, { resources: [this.currentResourceInformations.resId] }).pipe(
                 catchError((err: any) => {
diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts
index aefc5a7b614..81d713666c4 100755
--- a/src/frontend/lang/lang-en.ts
+++ b/src/frontend/lang/lang-en.ts
@@ -1249,4 +1249,5 @@ export const LANG_EN = {
     "backBasket" : "Back to basket",
     "openInExternalModal" : "Open in external modal",
     "openedInExternalModal" : "Opened in external modal",
+    "showMore" : "Show more",
 };
diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts
index 0a2758dfa3d..03bbb169702 100755
--- a/src/frontend/lang/lang-fr.ts
+++ b/src/frontend/lang/lang-fr.ts
@@ -1286,4 +1286,5 @@ export const LANG_FR = {
     "backBasket" : "Retour bannette",
     "openInExternalModal" : "Ouvrir dans une nouvelle modale",
     "openedInExternalModal" : "Ouvert dans une modale",
+    "showMore" : "Voir plus",
 };
diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts
index 9e00f0d607e..c9d8821b462 100755
--- a/src/frontend/lang/lang-nl.ts
+++ b/src/frontend/lang/lang-nl.ts
@@ -1274,4 +1274,5 @@ export const LANG_NL = {
     "backBasket" : "Back to basket", //_TO_TRANSLATE
     "openInExternalModal" : "Open in external modal", //_TO_TRANSLATE
     "openedInExternalModal" : "Opened in external modal", //_TO_TRANSLATE
+    "showMore" : "Show more", //_TO_TRANSLATE
 };
-- 
GitLab