From fe3c0eec75e001e11c06ac46045b78458d2d671e Mon Sep 17 00:00:00 2001
From: "hamza.hramchi" <hamza.hramchi@xelians.fr>
Date: Thu, 22 Oct 2020 14:52:15 +0200
Subject: [PATCH] FEAT #15056 TIME 0:21 add the button to bind mail + toogle
 method + language variables

---
 .../app/process/process.component.html        |  6 +++-
 .../app/process/process.component.scss        |  8 +++++
 src/frontend/app/process/process.component.ts | 30 +++++++++++++++----
 src/lang/lang-fr.json                         |  1 +
 4 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html
index 25f39edcbf3..1fc5210f3af 100644
--- a/src/frontend/app/process/process.component.html
+++ b/src/frontend/app/process/process.component.html
@@ -194,7 +194,11 @@
                             </button>
                             <button mat-icon-button [title]="this.translate.instant('lang.freezeRetentionRule')"
                             class="categoryLabel" (click)="toggleFreezing()">
-                                <mat-icon class="freezeThawIcon {{this.freezeThawResource ? 'fas':'far'}} fa-pause-circle" style="font-size: 30px;"></mat-icon>
+                                <mat-icon class="freezeThawIcon {{this.resourceFreezed ? 'fas':'far'}} fa-pause-circle" style="font-size: 20px;"></mat-icon>
+                            </button>
+                            <button mat-icon-button [title]="this.translate.instant('lang.setBindingDocument')"
+                            class="categoryLabel" (click)="toggleBinding()">
+                                <mat-icon class=" {{this.resourceBinded ? 'bindIcon' : 'noBindIcn'}} fas fa-paperclip" style="font-size: 20px;"></mat-icon>
                             </button>
                             <div class="content-item" *ngIf="this.currentResourceInformations.priority !== undefined">
                                 <b><i class="fas fa-flag" [style.color]="this.currentResourceInformations.priorityColor"
diff --git a/src/frontend/app/process/process.component.scss b/src/frontend/app/process/process.component.scss
index e87c9d93239..45581269669 100644
--- a/src/frontend/app/process/process.component.scss
+++ b/src/frontend/app/process/process.component.scss
@@ -414,6 +414,14 @@
     color: $secondary;
 }
 
+.bindIcon {
+    color: $secondary;
+}
+
+.noBindIcon {
+    color: $primary;
+}
+
 .tool-disabled {
     cursor: not-allowed;
     opacity: 0.3;
diff --git a/src/frontend/app/process/process.component.ts b/src/frontend/app/process/process.component.ts
index 668b5ebe202..0eebe7b5982 100755
--- a/src/frontend/app/process/process.component.ts
+++ b/src/frontend/app/process/process.component.ts
@@ -154,7 +154,8 @@ export class ProcessComponent implements OnInit, OnDestroy {
     hasContact: boolean = false;
 
     resourceFollowed: boolean = false;
-    freezeThawResource: boolean = false;
+    resourceFreezed: boolean = false;
+    resourceBinded: boolean = false;
 
     constructor(
         public translate: TranslateService,
@@ -322,7 +323,8 @@ export class ProcessComponent implements OnInit, OnDestroy {
             tap((data: any) => {
                 this.currentResourceInformations = data;
                 this.resourceFollowed = data.followed;
-                this.freezeThawResource = data.retentionFrozen;
+                this.resourceBinded = data.binding;
+                this.resourceFreezed = data.retentionFrozen;
                 if (this.currentResourceInformations.categoryId !== 'outgoing') {
                     this.loadSenders();
                 } else {
@@ -837,10 +839,10 @@ export class ProcessComponent implements OnInit, OnDestroy {
     }
 
     toggleFreezing() {
-        this.freezeThawResource = !this.freezeThawResource;
-            this.http.put('../rest/archival/freezeRetentionRule', { resources: [this.currentResourceInformations.resId], freeze : this.freezeThawResource }).pipe(
+        this.resourceFreezed = !this.resourceFreezed;
+            this.http.put('../rest/archival/freezeRetentionRule', { resources: [this.currentResourceInformations.resId], freeze : this.resourceFreezed }).pipe(
                 tap(() => {
-                    if (this.freezeThawResource) {
+                    if (this.resourceFreezed) {
                         this.notify.success(this.translate.instant('lang.retentionRuleFrozen'));
                     } else {
                         this.notify.success(this.translate.instant('lang.retentionRuleThawed'));
@@ -854,6 +856,24 @@ export class ProcessComponent implements OnInit, OnDestroy {
             ).subscribe();
     }
 
+    toggleBinding() {
+        this.resourceBinded = !this.resourceBinded;
+        this.http.put('../rest/archival/binding', { resources: [this.currentResourceInformations.resId], binding : this.resourceBinded }).pipe(
+            tap(() => {
+                if (this.resourceBinded) {
+                    this.notify.success(this.translate.instant('lang.bindingMail'));
+                } else {
+                    this.notify.success(this.translate.instant('lang.noBindingMal'));
+                }
+            }
+            ),
+            catchError((err: any) => {
+                this.notify.handleErrors(err);
+                return of(false);
+            })
+        ).subscribe();
+    }
+
     isToolEnabled(id: string) {
         if (id === 'history') {
             if (!this.privilegeService.hasCurrentUserPrivilege('view_full_history') && !this.privilegeService.hasCurrentUserPrivilege('view_doc_history')) {
diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json
index 8988a5e6578..5fede10c5b9 100644
--- a/src/lang/lang-fr.json
+++ b/src/lang/lang-fr.json
@@ -2112,6 +2112,7 @@
     "retentionRuleFrozen": "Durée d'utilité courante gelée",
     "retentionRuleThawed" : "Durée d'utilité courante dégelée",
     "bindingMail": "Document engageant",
+    "noBindingMal": "Document non engageant",
     "warningConnectionMsg": "Vous pouvez rendre l'application <b>indisponible</b> si les informations sont erronées !",
     "mappingHeaders": "Interfaçage des en-têtes",
     "ssoUrl": "Url du portail SSO",
-- 
GitLab