From 86f93a1ce245b5c0ea7024e942df6de67305edb6 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Thu, 15 Mar 2018 18:42:25 +0100
Subject: [PATCH] FIX #208 notification wording

---
 .../js/angular/app/profile.component.ts       | 33 +++++++++----------
 .../js/angular/lang/lang-en.ts                |  7 ++++
 .../js/angular/lang/lang-fr.ts                |  7 ++++
 3 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/apps/maarch_entreprise/js/angular/app/profile.component.ts b/apps/maarch_entreprise/js/angular/app/profile.component.ts
index 75f182c37ac..dba427e00f7 100755
--- a/apps/maarch_entreprise/js/angular/app/profile.component.ts
+++ b/apps/maarch_entreprise/js/angular/app/profile.component.ts
@@ -5,8 +5,6 @@ import { NotificationService } from './notification.service';
 import { MatPaginator, MatTableDataSource, MatSort } from '@angular/material';
 
 declare function $j(selector: any) : any;
-declare function successNotification(message: string) : void;
-declare function errorNotification(message: string) : void;
 
 declare var tinymce : any;
 declare var angularGlobals : any;
@@ -132,7 +130,6 @@ export class ProfileComponent implements OnInit {
         this.updateBreadcrumb(angularGlobals.applicationName);
         this.coreUrl = angularGlobals.coreUrl;
 
-        console.log(this.coreUrl);
         this.loading = true;
 
         this.http.get('../../rest/currentUser/profile')
@@ -181,7 +178,7 @@ export class ProfileComponent implements OnInit {
             this.signatureModel.base64 = "";
             this.signatureModel.base64ForJs = "";
 
-            errorNotification("Taille maximum de fichier dépassée (2 MB)");
+            this.notify.error("Taille maximum de fichier dépassée (2 MB)");
         }
     }
 
@@ -330,9 +327,9 @@ export class ProfileComponent implements OnInit {
                     newPassword             : "",
                     reNewPassword           : "",
                 };
-                successNotification(data.success);
+                this.notify.success(this.lang.passwordUpdated);
             }, (err) => {
-                errorNotification(err.error.errors);
+                this.notify.error(err.error.errors);
             });
     }
 
@@ -342,7 +339,7 @@ export class ProfileComponent implements OnInit {
         this.http.post(this.coreUrl + 'rest/currentUser/emailSignature', this.mailSignatureModel)
             .subscribe((data : any) => {
                 if (data.errors) {
-                    errorNotification(data.errors);
+                    this.notify.error(data.errors);
                 } else {
                     this.user.emailSignatures = data.emailSignatures;
                     this.mailSignatureModel     = {
@@ -351,7 +348,7 @@ export class ProfileComponent implements OnInit {
                         title                   : "",
                     };
                     tinymce.get('emailSignature').setContent("");
-                    successNotification(data.success);
+                    this.notify.success(this.lang.emailSignatureAdded);
                 }
             });
     }
@@ -363,11 +360,11 @@ export class ProfileComponent implements OnInit {
         this.http.put(this.coreUrl + 'rest/currentUser/emailSignature/' + id, this.mailSignatureModel)
             .subscribe((data : any) => {
                 if (data.errors) {
-                    errorNotification(data.errors);
+                    this.notify.error(data.errors);
                 } else {
                     this.user.emailSignatures[this.mailSignatureModel.selected - 1].title = data.emailSignature.title;
                     this.user.emailSignatures[this.mailSignatureModel.selected - 1].html_body = data.emailSignature.html_body;
-                    successNotification(data.success);
+                    this.notify.success(this.lang.emailSignatureUpdated);
                 }
             });
     }
@@ -381,7 +378,7 @@ export class ProfileComponent implements OnInit {
             this.http.delete(this.coreUrl + 'rest/currentUser/emailSignature/' + id)
                 .subscribe((data : any) => {
                     if (data.errors) {
-                        errorNotification(data.errors);
+                        this.notify.error(data.errors);
                     } else {
                         this.user.emailSignatures = data.emailSignatures;
                         this.mailSignatureModel     = {
@@ -390,7 +387,7 @@ export class ProfileComponent implements OnInit {
                             title                   : "",
                         };
                         tinymce.get('emailSignature').setContent("");
-                        successNotification(data.success);
+                        this.notify.success(this.lang.emailSignatureDeleted);
                     }
                 });
         }
@@ -408,9 +405,9 @@ export class ProfileComponent implements OnInit {
                     size                    : 0,
                     label                   : "",
                 };
-                successNotification(data.success);
+                this.notify.success(this.lang.signatureAdded);
             }, (err) => {
-                errorNotification(err.error.errors);
+                this.notify.error(err.error.errors);
             });
     }
 
@@ -422,9 +419,9 @@ export class ProfileComponent implements OnInit {
                 this.user.signatures[this.selectedSignature].signature_label = data.signature.signature_label;
                 this.selectedSignature = -1;
                 this.selectedSignatureLabel = "";
-                successNotification(data.success);
+                this.notify.success(this.lang.signatureUpdated);
             }, (err) => {
-                errorNotification(err.error.errors);
+                this.notify.error(err.error.errors);
             });
     }
 
@@ -435,9 +432,9 @@ export class ProfileComponent implements OnInit {
             this.http.delete(this.coreUrl + "rest/users/" + this.user.id + "/signatures/" + id)
                 .subscribe((data : any) => {
                     this.user.signatures = data.signatures;
-                    successNotification(data.success);
+                    this.notify.success(this.lang.signatureDeleted);
                 }, (err) => {
-                    errorNotification(err.error.errors);
+                    this.notify.error(err.error.errors);
                 });
         }
     }
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-en.ts b/apps/maarch_entreprise/js/angular/lang/lang-en.ts
index bbddff6402a..4bc51d57558 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-en.ts
+++ b/apps/maarch_entreprise/js/angular/lang/lang-en.ts
@@ -383,5 +383,12 @@ export const LANG_EN = {
     "addFirstLevel"                     : "Add first level",
     "addSecondLevel"                    : "Add second level",
     "addDoctype"                        : "Add document type",
+    "passwordUpdated"                   : "Password updated",
+    "emailSignatureAdded"               : "Email signature added",
+    "emailSignatureUpdated"             : "Email signature updated",
+    "emailSignatureDeleted"             : "Email signature deleted",
+    "signatureAdded"                    : "Signature added",
+    "signatureUpdated"                  : "Signature updated",
+    "signatureDeleted"                  : "Signature deleted",
 
 };
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
index 44d96f9547b..1697117e30f 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
+++ b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
@@ -408,4 +408,11 @@ export const LANG_FR = {
     "addFirstLevel"                     : "Ajouter une chemise",
     "addSecondLevel"                    : "Ajouter une sous-chemise",
     "addDoctype"                        : "Ajouter un type de document",
+    "passwordUpdated"                   : "Mot de passe modifié",
+    "emailSignatureAdded"               : "Signature de mail ajoutée",
+    "emailSignatureUpdated"             : "Signature de mail modifiée",
+    "emailSignatureDeleted"             : "Signature de mail supprimée",
+    "signatureAdded"                    : "Signature ajoutée",
+    "signatureUpdated"                  : "Signature mise à jour",
+    "signatureDeleted"                  : "Signature supprimée",
 };
-- 
GitLab