From a96bfdcb590854c713ce096b6dd12ba3c961c44f Mon Sep 17 00:00:00 2001
From: "kevin.dezaphi" <kevin.dezaphi@maarch.org>
Date: Wed, 19 Sep 2018 15:54:10 +0200
Subject: [PATCH] FEAT #8345 fix errors and remove correctly message when it's
 blank

---
 sql/develop.sql                             | 2 +-
 src/app/home/controllers/HomeController.php | 2 +-
 src/frontend/app/home.component.html        | 4 ++--
 src/frontend/app/home.component.ts          | 2 ++
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/sql/develop.sql b/sql/develop.sql
index b221413e2f7..19dbbea8187 100644
--- a/sql/develop.sql
+++ b/sql/develop.sql
@@ -514,4 +514,4 @@ DELETE FROM status WHERE id = 'FRZ';
 INSERT INTO status (id, label_status, is_system, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES ('FRZ', 'PJ gelée', 'Y', 'fm-letter-status-inprogress', 'apps', 'Y', 'Y');
 
 DELETE FROM parameters WHERE id = 'homepage_message';
-INSERT INTO parameters (id, description, param_value_string) VALUES ('homepage_message', "Texte apparaissant dans la banière sur la page d'acceuil, laisser vide pour supprimer la banière.", 'Bienvenue dans votre <b>G</b>estion <b>E</b>lectronique du <b>C</b>ourrier.');
\ No newline at end of file
+INSERT INTO parameters (id, description, param_value_string) VALUES ('homepage_message', 'Texte apparaissant dans la banière sur la page d''acceuil, laisser vide pour supprimer la banière.', 'Bienvenue dans votre <b>G</b>estion <b>E</b>lectronique du <b>C</b>ourrier.');
\ No newline at end of file
diff --git a/src/app/home/controllers/HomeController.php b/src/app/home/controllers/HomeController.php
index b4cf9414483..d7f69a9b6eb 100644
--- a/src/app/home/controllers/HomeController.php
+++ b/src/app/home/controllers/HomeController.php
@@ -29,7 +29,7 @@ class HomeController
 
         $user = UserModel::getByUserId(['userId' => $GLOBALS['userId'], 'select' => ['id']]);
         $homeMessage = ParameterModel::getById(['select' => ['param_value_string'], 'id'=> 'homepage_message']);
-        $homeMessage = $homeMessage['param_value_string'];
+        $homeMessage = trim($homeMessage['param_value_string']);
 
         $redirectedBaskets = BasketModel::getRedirectedBasketsByUserId(['userId' => $GLOBALS['userId']]);
         $groups = UserModel::getGroupsByUserId(['userId' => $GLOBALS['userId']]);
diff --git a/src/frontend/app/home.component.html b/src/frontend/app/home.component.html
index b278e4dad63..01a0252fac6 100755
--- a/src/frontend/app/home.component.html
+++ b/src/frontend/app/home.component.html
@@ -10,12 +10,12 @@
         <mat-sidenav-content id="listContent">
             <mat-card class="card-app-content">
                 <mat-card id="viewThumbnail" style="display:none;position: absolute;z-index: 2;"><img src="{{thumbnailUrl}}"/></mat-card>
-                <mat-card *ngIf="homeData.homeMessage">
+                <mat-card *ngIf="homeMessage">
                     <div style="display: flex">
                         <div *ngIf="!mobileMode" style="text-align:center;flex: 1;background: url(static.php?filename=logo_only.svg);background-size: auto auto;height: 70px;background-size: contain;background-repeat: no-repeat;background-position: center;">
                         </div>
                         <div style="flex:10;padding-left: 10px;">
-                            <span [innerHTML]="homeData.homeMessage"></span>
+                            <span [innerHTML]="homeMessage"></span>
                         </div>
                     </div>
                     <div style="text-align: right;opacity: 0.5;">
diff --git a/src/frontend/app/home.component.ts b/src/frontend/app/home.component.ts
index a10c81f251c..17c038b76f1 100755
--- a/src/frontend/app/home.component.ts
+++ b/src/frontend/app/home.component.ts
@@ -36,6 +36,7 @@ export class HomeComponent extends AutoCompletePlugin implements OnInit {
 
     @ViewChildren(MatExpansionPanel) viewPanels: QueryList<MatExpansionPanel>;
     homeData: any;
+    homeMessage: string;
     dataSource: any;
     displayedColumns: string[] = ['res_id', 'subject', 'creation_date'];
 
@@ -67,6 +68,7 @@ export class HomeComponent extends AutoCompletePlugin implements OnInit {
         this.http.get(this.coreUrl + "rest/home")
         .subscribe((data: any) => {
             this.homeData = data;
+            this.homeMessage = data['homeMessage']
         });
     }
 
-- 
GitLab