From c880e5d1336010df8755ff7f877117acb37b185f Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Mon, 29 Jun 2020 11:28:53 +0200
Subject: [PATCH] FEAT #14235 TIME 2 fix prod error

---
 src/frontend/app/actions/actions.module.ts    |   2 -
 .../send-shipping-action.component.ts         |   2 +-
 .../contact-duplicate.component.html          |   2 +-
 .../user/user-administration.component.ts     |   2 +-
 src/frontend/app/app-common.module.ts         |   7 +
 src/frontend/app/app-list.module.ts           |   4 +-
 src/frontend/app/app-service.module.ts        |   1 -
 .../attachment-page.component.ts              |   2 +
 .../indexing/folder-input.component.html      |   2 +-
 .../printed-folder-modal.component.html       |   2 +-
 src/frontend/app/process/process.module.ts    |   5 +-
 .../sent-resource-page.component.html         |   2 +-
 .../app/tag/indexing/tag-input.component.html |   2 +-
 src/frontend/plugins/timeAgo.pipe.ts          | 211 +++++++++---------
 14 files changed, 126 insertions(+), 120 deletions(-)

diff --git a/src/frontend/app/actions/actions.module.ts b/src/frontend/app/actions/actions.module.ts
index ab32be12d91..3da25951258 100644
--- a/src/frontend/app/actions/actions.module.ts
+++ b/src/frontend/app/actions/actions.module.ts
@@ -4,7 +4,6 @@ import { SharedModule } from '../app-common.module';
 
 import { CriteriaToolComponent } from '../adv-search/criteria-tool/criteria-tool.component';
 import { SearchAdvListComponent } from '../adv-search/list/search-adv-list.component';
-import { NoteModule } from '../notes/note.module';
 import { DocumentViewerModule } from '../viewer/document-viewer.module';
 
 import { ConfirmActionComponent } from './confirm-action/confirm-action.component';
@@ -44,7 +43,6 @@ import { SendAlfrescoActionComponent } from './send-alfresco-action/send-alfresc
 @NgModule({
     imports: [
         SharedModule,
-        NoteModule,
         DocumentViewerModule
     ],
     declarations: [
diff --git a/src/frontend/app/actions/send-shipping-action/send-shipping-action.component.ts b/src/frontend/app/actions/send-shipping-action/send-shipping-action.component.ts
index 96bde89e121..7a326a83679 100644
--- a/src/frontend/app/actions/send-shipping-action/send-shipping-action.component.ts
+++ b/src/frontend/app/actions/send-shipping-action/send-shipping-action.component.ts
@@ -43,7 +43,7 @@ export class SendShippingActionComponent implements OnInit {
             icon: 'fas fa-shipping-fast'
         }
     };
-    fatalError: any[] = [];
+    fatalError: any = '';
 
     @ViewChild('noteEditor', { static: false }) noteEditor: NoteEditorComponent;
 
diff --git a/src/frontend/app/administration/contact/contact-duplicate/contact-duplicate.component.html b/src/frontend/app/administration/contact/contact-duplicate/contact-duplicate.component.html
index 6e3807c1ccc..155150eb691 100644
--- a/src/frontend/app/administration/contact/contact-duplicate/contact-duplicate.component.html
+++ b/src/frontend/app/administration/contact/contact-duplicate/contact-duplicate.component.html
@@ -56,7 +56,7 @@
                     <em>{{lang.noDuplicatesFound}}</em>
                 </div>
                 <div *ngIf="duplicatesContacts.length > 0" style="padding: 10px;text-align: right;color: rgba(0,0,0,0.54);">
-                    {{lang.duplicatesContactDisplayed | scan: [duplicatesContactsRealCount, duplicatesContactsCount]}}
+                    {{lang.duplicatesContactDisplayed | scan: [''+duplicatesContactsRealCount+'', ''+duplicatesContactsCount+'']}}
                 </div>
                 <mat-list role="list" *ngIf="duplicatesContacts.length > 0">
                     <mat-list-item role="listitem">
diff --git a/src/frontend/app/administration/user/user-administration.component.ts b/src/frontend/app/administration/user/user-administration.component.ts
index badb0e13efa..f35707155ae 100755
--- a/src/frontend/app/administration/user/user-administration.component.ts
+++ b/src/frontend/app/administration/user/user-administration.component.ts
@@ -369,7 +369,7 @@ export class UserAdministrationComponent implements OnInit {
         this.selectedSignatureLabel = this.user.signatures[index].signature_label;
     }
 
-    resendActivationNotification(user: any) {
+    resendActivationNotification() {
         let r = confirm(this.lang.confirmAction + ' ' + this.lang.sendActivationNotification);
 
         if (r) {
diff --git a/src/frontend/app/app-common.module.ts b/src/frontend/app/app-common.module.ts
index 180da1b1698..c3550a9d769 100755
--- a/src/frontend/app/app-common.module.ts
+++ b/src/frontend/app/app-common.module.ts
@@ -40,6 +40,9 @@ import { AlertComponent } from '../plugins/modal/alert.component';
 import { ConfirmComponent } from '../plugins/modal/confirm.component';
 
 /*PLUGIN COMPONENT*/
+import { NotesListComponent } from './notes/notes.component';
+import { NoteEditorComponent } from './notes/note-editor.component';
+
 import { PluginAutocomplete } from '../plugins/autocomplete/autocomplete.component';
 import { PluginSelectSearchComponent } from '../plugins/select-search/select-search.component';
 
@@ -108,6 +111,8 @@ import { LinkedResourceListComponent } from './linkedResource/linked-resource-li
         FolderMenuComponent,
         FolderActionListComponent,
         LinkedResourceListComponent,
+        NotesListComponent,
+        NoteEditorComponent,
 
     ],
     exports: [
@@ -148,6 +153,8 @@ import { LinkedResourceListComponent } from './linkedResource/linked-resource-li
         FolderMenuComponent,
         FolderActionListComponent,
         LinkedResourceListComponent,
+        NotesListComponent,
+        NoteEditorComponent,
     ],
     providers: [],
     entryComponents: [
diff --git a/src/frontend/app/app-list.module.ts b/src/frontend/app/app-list.module.ts
index a9c39cb20ea..858b69c4cef 100644
--- a/src/frontend/app/app-list.module.ts
+++ b/src/frontend/app/app-list.module.ts
@@ -9,13 +9,11 @@ import { PrintedFolderModalComponent } from './printedFolder/printed-folder-moda
 import { ActionsListComponent } from './actions/actions-list.component';
 import { FollowedActionListComponent } from './home/followed-action-list/followed-action-list.component';
 import { NgPipesModule } from 'ngx-pipes';
-import { NoteModule } from './notes/note.module';
 
 @NgModule({
     imports: [
         SharedModule,
         NgPipesModule,
-        NoteModule
     ],
     declarations: [
         FiltersToolComponent,
@@ -26,9 +24,9 @@ import { NoteModule } from './notes/note.module';
         PrintedFolderModalComponent,
         ActionsListComponent,
         FollowedActionListComponent,
-
     ],
     exports: [
+        SharedModule,
         FiltersToolComponent,
         PanelListComponent,
         SummarySheetComponent,
diff --git a/src/frontend/app/app-service.module.ts b/src/frontend/app/app-service.module.ts
index b2c57bbd734..a1e34b52bd8 100644
--- a/src/frontend/app/app-service.module.ts
+++ b/src/frontend/app/app-service.module.ts
@@ -39,7 +39,6 @@ import { SortPipe } from '../plugins/sorting.pipe';
     providers: [
         LatinisePipe,
         CookieService,
-        SortPipe
     ],
 })
 export class AppServiceModule {}
diff --git a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts
index 666cb006c3a..94669cd4e41 100644
--- a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts
+++ b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts
@@ -43,6 +43,8 @@ export class AttachmentPageComponent implements OnInit {
 
     editMode: boolean = false;
 
+    now: Date = new Date();
+
     @ViewChild('appAttachmentViewer', { static: false }) appAttachmentViewer: DocumentViewerComponent;
 
     constructor(
diff --git a/src/frontend/app/folder/indexing/folder-input.component.html b/src/frontend/app/folder/indexing/folder-input.component.html
index 0c296651207..9a8b47c213e 100755
--- a/src/frontend/app/folder/indexing/folder-input.component.html
+++ b/src/frontend/app/folder/indexing/folder-input.component.html
@@ -10,7 +10,7 @@
         <mat-autocomplete #auto="matAutocomplete" (optionSelected)="selectOpt($event)">
             <ng-container *ngIf="options.length > 0 && !loading">
                 <mat-option *ngFor="let option of filteredOptions | async | sortBy: key" [value]="option" [title]="option[key]">
-                    <span color="primary">{{option[key]}}</span>&nbsp;<small>{{option[subInfoKey]}}</small>
+                    <span color="primary">{{option[key]}}</span>
                 </mat-option>
             </ng-container>
             <mat-option class="autoCompleteInfoResult smallInputInfo" *ngIf="options.length === 0 && !loading" disabled
diff --git a/src/frontend/app/printedFolder/printed-folder-modal.component.html b/src/frontend/app/printedFolder/printed-folder-modal.component.html
index 7ae910e2e6a..e67885d0167 100644
--- a/src/frontend/app/printedFolder/printed-folder-modal.component.html
+++ b/src/frontend/app/printedFolder/printed-folder-modal.component.html
@@ -88,7 +88,7 @@
 
                                         <div color="primary" [title]="element.creationDate | fullDate"
                                             style="flex:1;justify-content: flex-end;display: flex;font-size: 80%;">
-                                            {{element.creationDate | timeAgo : 'full' | ucfirst}}
+                                            {{element.creationDate}} {{element.creationDate | timeAgo : 'full'}}
                                         </div>
                                     </div>
                                 </mat-list-option>
diff --git a/src/frontend/app/process/process.module.ts b/src/frontend/app/process/process.module.ts
index 149dc1dbdb0..0fa654f6ee0 100644
--- a/src/frontend/app/process/process.module.ts
+++ b/src/frontend/app/process/process.module.ts
@@ -18,7 +18,6 @@ import { SentNumericPackagePageComponent } from '../sentResource/sent-numeric-pa
 import { ThesaurusModalComponent } from '../tag/indexing/thesaurus/thesaurus-modal.component';
 import { SelectIndexingModelComponent } from '../indexation/select-indexing-model/select-indexing-model.component';
 import { DocumentFormModule } from '../document-form.module';
-import { NoteModule } from '../notes/note.module';
 
 @NgModule({
     imports: [
@@ -26,7 +25,6 @@ import { NoteModule } from '../notes/note.module';
         ActionsModule,
         ProcessRoutingModule,
         DocumentFormModule,
-        NoteModule
     ],
     declarations: [
         ProcessComponent,
@@ -42,6 +40,9 @@ import { NoteModule } from '../notes/note.module';
         ThesaurusModalComponent,
         SelectIndexingModelComponent,
     ],
+    exports: [
+        SharedModule,
+    ],
     entryComponents: [
         LinkResourceModalComponent,
         SentResourcePageComponent,
diff --git a/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.html b/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.html
index 22e36d45a6a..8baf100bb42 100644
--- a/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.html
+++ b/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.html
@@ -56,7 +56,7 @@
                 (cdkDropListDropped)="drop($event)">
                 <mat-chip cdkDrag [cdkDragDisabled]="emailStatus == 'SENT' || emailStatus == 'ERROR'" class="copy"
                     *ngFor="let copy of copies" [removable]="canManageMail()"
-                    (removed)="remove(copy, 'copies')" (click)="remove(copycopy, 'recipients')" [title]="copy.email"
+                    (removed)="remove(copy, 'copies')" (click)="remove(copy, 'recipients')" [title]="copy.email"
                     [class.badFormat]="copy.badFormat">
                     {{copy.label}}{{copy.label !== copy.email ? ' (' + copy.email + ')' : ''}}
                     <mat-icon matChipRemove class="fa fa-times" *ngIf="canManageMail()"></mat-icon>
diff --git a/src/frontend/app/tag/indexing/tag-input.component.html b/src/frontend/app/tag/indexing/tag-input.component.html
index 727118dafbd..8bc737b5f9e 100644
--- a/src/frontend/app/tag/indexing/tag-input.component.html
+++ b/src/frontend/app/tag/indexing/tag-input.component.html
@@ -13,7 +13,7 @@
         <mat-autocomplete #auto="matAutocomplete" (optionSelected)="selectOpt($event)">
             <ng-container *ngIf="options.length > 0 && !loading">
                 <mat-option *ngFor="let option of filteredOptions | async | sortBy: key" [value]="option" [title]="option[key]">
-                    <span color="primary">{{option[key]}}</span>&nbsp;<small>{{option[subInfoKey]}}</small>
+                    <span color="primary">{{option[key]}}</span>
                 </mat-option>
             </ng-container>
             <mat-option class="autoCompleteInfoResult smallInputInfo" *ngIf="options.length === 0 && !loading" disabled
diff --git a/src/frontend/plugins/timeAgo.pipe.ts b/src/frontend/plugins/timeAgo.pipe.ts
index 69fbdbf046c..6cb42caa3bb 100755
--- a/src/frontend/plugins/timeAgo.pipe.ts
+++ b/src/frontend/plugins/timeAgo.pipe.ts
@@ -2,112 +2,113 @@ import { Pipe, PipeTransform, NgZone, ChangeDetectorRef, OnDestroy } from "@angu
 import { LANG } from '../app/translate.component';
 
 @Pipe({
-	name: 'timeAgo',
-	pure: false
+    name: 'timeAgo',
+    pure: false
 })
 export class TimeAgoPipe implements PipeTransform, OnDestroy {
-	private timer: number;
-	lang: any = LANG;
-	constructor(private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) { }
-	transform(value: string, args: string = null) {
-		this.removeTimer();
-		let d = new Date(value);
-		let dayNumber = ('0' + d.getDate()).slice(-2);
-		const realMonth = d.getMonth() + 1;
-		let monthNumber = ('0' + realMonth).slice(-2);
-		let hourNumber = ('0' + d.getHours()).slice(-2);
-		let minuteNumber = ('0' + d.getMinutes()).slice(-2);
-		let now = new Date();
-		let month = [];
-		month[0] = this.lang.januaryShort;
-		month[1] = this.lang.februaryShort;
-		month[2] = this.lang.marchShort;
-		month[3] = this.lang.aprilShort;
-		month[4] = this.lang.mayShort;
-		month[5] = this.lang.juneShort;
-		month[6] = this.lang.julyShort;
-		month[7] = this.lang.augustShort;
-		month[8] = this.lang.septemberShort;
-		month[9] = this.lang.octoberShort;
-		month[10] = this.lang.novemberShort;
-		month[11] = this.lang.decemberShort;
-		let seconds = Math.round(Math.abs((now.getTime() - d.getTime()) / 1000));
-		let curentDayNumber = ('0' + now.getDate()).slice(-2);
-		let timeToUpdate = (Number.isNaN(seconds)) ? 1000 : this.getSecondsUntilUpdate(seconds) * 1000;
-		this.timer = this.ngZone.runOutsideAngular(() => {
-			if (typeof window !== 'undefined') {
-				return window.setTimeout(() => {
-					this.ngZone.run(() => this.changeDetectorRef.markForCheck());
-				}, timeToUpdate);
-			}
-			return null;
-		});
-		let minutes = Math.round(Math.abs(seconds / 60));
-		let hours = Math.round(Math.abs(minutes / 60));
-		let days = Math.round(Math.abs(hours / 24));
-		let months = Math.round(Math.abs(days / 30.416));
-		let years = Math.round(Math.abs(days / 365));
-		if (value == this.lang.undefined) {
-			return this.lang.undefined;
-		} else if (Number.isNaN(seconds)) {
-			return '';
-		} else if (seconds <= 45) {
-			return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), this.lang.fewSeconds, args);
-		} else if (seconds <= 90) {
-			return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), this.lang.oneMinute, args);
-		} else if (minutes <= 45) {
-			return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), minutes + ' ' + this.lang.minutes, args);
-		} else if (minutes <= 90) {
-			return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), this.lang.oneHour, args);
-		} else if (hours <= 24 && dayNumber === curentDayNumber) {
-			return this.getFormatedDate(this.lang.at.toLowerCase(), hourNumber + ':' + minuteNumber, args);
-			//return hours + ' heures';
-		} else if (hours <= 24) {
-			return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), days + ' ' + this.lang.dayS, args);
-			//return 'un jour';
-		} else if (days <= 5) {
-			return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), days + ' ' + this.lang.dayS, args);
-			//return days + ' jours';
-		} else if (days <= 345) {
-			return this.getFormatedDate(this.lang.dateTo.toLowerCase(), d.getDate() + ' ' + month[d.getMonth()], args);
-			//return months + ' mois';
-		} else if (days <= 545) {
-			return this.getFormatedDate(this.lang.dateTo.toLowerCase(), dayNumber + '/' + monthNumber + '/' + d.getFullYear(), args);
-			//return 'un an';
-		} else { // (days > 545)
-			return this.getFormatedDate(this.lang.dateTo.toLowerCase(), dayNumber + '/' + monthNumber + '/' + d.getFullYear(), args);
-			//return years + ' ans';
-		}
-	}
-	ngOnDestroy(): void {
-		this.removeTimer();
-	}
-	private removeTimer() {
-		if (this.timer) {
-			window.clearTimeout(this.timer);
-			this.timer = null;
-		}
-	}
-	private getSecondsUntilUpdate(seconds: number) {
-		let min = 60;
-		let hr = min * 60;
-		let day = hr * 24;
-		if (seconds < min) { // less than 1 min, update every 2 secs
-			return 2;
-		} else if (seconds < hr) { // less than an hour, update every 30 secs
-			return 30;
-		} else if (seconds < day) { // less then a day, update every 5 mins
-			return 300;
-		} else { // update every hour
-			return 3600;
-		}
-	}
+    private timer: number;
+    lang: any = LANG;
+    constructor(private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) { }
+    transform(value: string, args: string = null) {
 
-	getFormatedDate(prefix: string, content: string, mode: string) {
-		if (mode === 'full') {
-			return `${prefix} ${content}`;
-		} else {
-			return content;
-		}
-	}
+        this.removeTimer();
+        let d = new Date(value);
+        let dayNumber = ('0' + d.getDate()).slice(-2);
+        const realMonth = d.getMonth() + 1;
+        let monthNumber = ('0' + realMonth).slice(-2);
+        let hourNumber = ('0' + d.getHours()).slice(-2);
+        let minuteNumber = ('0' + d.getMinutes()).slice(-2);
+        let now = new Date();
+        let month = [];
+        month[0] = this.lang.januaryShort;
+        month[1] = this.lang.februaryShort;
+        month[2] = this.lang.marchShort;
+        month[3] = this.lang.aprilShort;
+        month[4] = this.lang.mayShort;
+        month[5] = this.lang.juneShort;
+        month[6] = this.lang.julyShort;
+        month[7] = this.lang.augustShort;
+        month[8] = this.lang.septemberShort;
+        month[9] = this.lang.octoberShort;
+        month[10] = this.lang.novemberShort;
+        month[11] = this.lang.decemberShort;
+        let seconds = Math.round(Math.abs((now.getTime() - d.getTime()) / 1000));
+        let curentDayNumber = ('0' + now.getDate()).slice(-2);
+        let timeToUpdate = (Number.isNaN(seconds)) ? 1000 : this.getSecondsUntilUpdate(seconds) * 1000;
+        this.timer = this.ngZone.runOutsideAngular(() => {
+            if (typeof window !== 'undefined') {
+                return window.setTimeout(() => {
+                    this.ngZone.run(() => this.changeDetectorRef.markForCheck());
+                }, timeToUpdate);
+            }
+            return null;
+        });
+        let minutes = Math.round(Math.abs(seconds / 60));
+        let hours = Math.round(Math.abs(minutes / 60));
+        let days = Math.round(Math.abs(hours / 24));
+        let months = Math.round(Math.abs(days / 30.416));
+        let years = Math.round(Math.abs(days / 365));
+        if (value == this.lang.undefined) {
+            return this.lang.undefined;
+        } else if (Number.isNaN(seconds)) {
+            return '';
+        } else if (seconds <= 45) {
+            return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), this.lang.fewSeconds, args);
+        } else if (seconds <= 90) {
+            return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), this.lang.oneMinute, args);
+        } else if (minutes <= 45) {
+            return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), minutes + ' ' + this.lang.minutes, args);
+        } else if (minutes <= 90) {
+            return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), this.lang.oneHour, args);
+        } else if (hours <= 24 && dayNumber === curentDayNumber) {
+            return this.getFormatedDate(this.lang.at.toLowerCase(), hourNumber + ':' + minuteNumber, args);
+            //return hours + ' heures';
+        } else if (hours <= 24) {
+            return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), days + ' ' + this.lang.dayS, args);
+            //return 'un jour';
+        } else if (days <= 5) {
+            return this.getFormatedDate(this.lang.dateAgo.toLowerCase(), days + ' ' + this.lang.dayS, args);
+            //return days + ' jours';
+        } else if (days <= 345) {
+            return this.getFormatedDate(this.lang.dateTo.toLowerCase(), d.getDate() + ' ' + month[d.getMonth()], args);
+            //return months + ' mois';
+        } else if (days <= 545) {
+            return this.getFormatedDate(this.lang.dateTo.toLowerCase(), dayNumber + '/' + monthNumber + '/' + d.getFullYear(), args);
+            //return 'un an';
+        } else { // (days > 545)
+            return this.getFormatedDate(this.lang.dateTo.toLowerCase(), dayNumber + '/' + monthNumber + '/' + d.getFullYear(), args);
+            //return years + ' ans';
+        }
+    }
+    ngOnDestroy(): void {
+        this.removeTimer();
+    }
+    private removeTimer() {
+        if (this.timer) {
+            window.clearTimeout(this.timer);
+            this.timer = null;
+        }
+    }
+    private getSecondsUntilUpdate(seconds: number) {
+        let min = 60;
+        let hr = min * 60;
+        let day = hr * 24;
+        if (seconds < min) { // less than 1 min, update every 2 secs
+            return 2;
+        } else if (seconds < hr) { // less than an hour, update every 30 secs
+            return 30;
+        } else if (seconds < day) { // less then a day, update every 5 mins
+            return 300;
+        } else { // update every hour
+            return 3600;
+        }
+    }
+
+    getFormatedDate(prefix: string, content: string, mode: string) {
+        if (mode === 'full') {
+            return `${prefix} ${content}`;
+        } else {
+            return content;
+        }
+    }
 }
\ No newline at end of file
-- 
GitLab