From 13581c5498a84c5fa918c44d787d9bd12426e6d6 Mon Sep 17 00:00:00 2001
From: FORESTIER Fabien <fabien.forestier@soprasteria.com>
Date: Thu, 1 Aug 2019 10:57:45 +0200
Subject: [PATCH] Resource message warning become two field, one in english and
 one in french

---
 .../detail/resource-detail.component.html         | 15 ++++++++++++---
 .../resources/edit/resource-form.component.html   | 11 +++++++++--
 .../resources/edit/resource-form.component.ts     | 11 +++--------
 src/app/models/resource.model.ts                  | 12 ++++++++----
 src/app/services/organization.service.ts          |  4 ++--
 5 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/src/app/components/resources/detail/resource-detail.component.html b/src/app/components/resources/detail/resource-detail.component.html
index 142398b..226ef92 100644
--- a/src/app/components/resources/detail/resource-detail.component.html
+++ b/src/app/components/resources/detail/resource-detail.component.html
@@ -74,9 +74,18 @@
               </ng-template>
             </div>
 
-            <div *ngIf="resource.messageWarning">
-              <span class="has-text-weight-bold">Message d'alerte: </span>
-              <span *ngIf="resource.messageWarning; else emptyMessageWarning">{{resource.messageWarning}}</span>
+            <div>
+              <span class="has-text-weight-bold">Message d'alerte (Français): </span>
+              <span *ngIf="resource.messageWarningFr; else emptyMessageWarning">{{resource.messageWarningFr}}</span>
+              <ng-template #emptyMessageWarning>
+                <span class="empty-property">Non renseigné</span>
+              </ng-template>
+            </div>
+            <br>
+
+            <div>
+              <span class="has-text-weight-bold">Message d'alerte (Anglais): </span>
+              <span *ngIf="resource.messageWarningEn; else emptyMessageWarning">{{resource.messageWarningEn}}</span>
               <ng-template #emptyMessageWarning>
                 <span class="empty-property">Non renseigné</span>
               </ng-template>
diff --git a/src/app/components/resources/edit/resource-form.component.html b/src/app/components/resources/edit/resource-form.component.html
index c41e9d4..d19b840 100644
--- a/src/app/components/resources/edit/resource-form.component.html
+++ b/src/app/components/resources/edit/resource-form.component.html
@@ -94,9 +94,16 @@
       </div>
 
       <div class="field">
-        <label class="label" for="messageWarning">Message d'alerte</label>
+        <label class="label" for="messageWarningFr">Message d'alerte (Français)</label>
         <div class="control">
-          <input class="input" type="text" formControlName="messageWarning" id="messageWarning">
+          <input class="input" type="text" formControlName="messageWarningFr" id="messageWarningFr">
+        </div>
+      </div>
+
+      <div class="field">
+        <label class="label" for="messageWarningEn">Message d'alerte (Anglais)</label>
+        <div class="control">
+          <input class="input" type="text" formControlName="messageWarningEn" id="messageWarningEn">
         </div>
       </div>
 
diff --git a/src/app/components/resources/edit/resource-form.component.ts b/src/app/components/resources/edit/resource-form.component.ts
index c669623..b69a143 100644
--- a/src/app/components/resources/edit/resource-form.component.ts
+++ b/src/app/components/resources/edit/resource-form.component.ts
@@ -71,7 +71,8 @@ export class ResourceFormComponent implements OnInit {
         isStandard: [this.resource.isStandard, Validators.required],
         description: [this.resource.description],
         parametersUrl: [this.resource.parametersUrl],
-        messageWarning: [this.resource.messageWarning],
+        messageWarningFr: [this.resource.messageWarningFr],
+        messageWarningEn: [this.resource.messageWarningEn],
       });
   }
 
@@ -134,6 +135,7 @@ export class ResourceFormComponent implements OnInit {
 
           return res;
         }),
+        map(() => { return savedResource.id; }),
         catchError(() => {
           return throwError('Une erreur s\'est produite lors de l\'association des formats à la ressource.');
         }),
@@ -160,9 +162,6 @@ export class ResourceFormComponent implements OnInit {
   }
 
   addResourceFormat() {
-    // if (!this.form.controls.links) {
-    //   this.organization.links = [];
-    // }
     (this.form.controls.resourceFormats as FormArray).push(this._fb.group({
       formatId: [null, Validators.required],
       isProjectable: 0,
@@ -199,10 +198,6 @@ export class ResourceFormComponent implements OnInit {
     return this.form.controls.resourceFormats as FormArray;
   }
 
-  // get outputFormats() {
-  //   return this.form.controls['outputFormats'];
-  // }
-
   get formInvalid() {
     return this.form.invalid;
   }
diff --git a/src/app/models/resource.model.ts b/src/app/models/resource.model.ts
index 2d28cdd..bbbf4eb 100644
--- a/src/app/models/resource.model.ts
+++ b/src/app/models/resource.model.ts
@@ -10,7 +10,8 @@ export class Resource {
   isDownloadable: number;
   isStandard: number;
   parametersUrl: string;
-  messageWarning: string;
+  messageWarningFr: string;
+  messageWarningEn: string;
   resourceFormats: IResourceFormat[];
 
   constructor(resource?: IResource) {
@@ -27,7 +28,8 @@ export class Resource {
       this.isDownloadable = resource.isDownloadable;
       this.isStandard = resource.isStandard;
       this.parametersUrl = resource.parametersUrl;
-      this.messageWarning = resource.messageWarning;
+      this.messageWarningFr = resource.messageWarningFr;
+      this.messageWarningEn = resource.messageWarningEn;
       this.resourceFormats = resource.resourceFormats ? resource.resourceFormats : [];
     } else {
       this.name = '';
@@ -38,7 +40,8 @@ export class Resource {
       this.isDownloadable = 0;
       this.isStandard = 0;
       this.parametersUrl = '';
-      this.messageWarning = '';
+      this.messageWarningFr = '';
+      this.messageWarningEn = '';
       this.resourceFormats = [];
     }
   }
@@ -64,7 +67,8 @@ export interface IResource {
   isDownloadable: number;
   isStandard: number;
   parametersUrl: string;
-  messageWarning: string;
+  messageWarningFr: string;
+  messageWarningEn: string;
   resourceFormats: IResourceFormat[];
 }
 
diff --git a/src/app/services/organization.service.ts b/src/app/services/organization.service.ts
index 752a7af..491c87a 100644
--- a/src/app/services/organization.service.ts
+++ b/src/app/services/organization.service.ts
@@ -30,7 +30,7 @@ export class OrganizationService {
     query += `&offset=${(this.pageNumber ? (this.pageNumber - 1) * this.limit : 0)}`;
     query += `&sort_by=${this.sortOptions.value}.${this.sortOptions.order}`;
 
-    return this._httpClient.get<IOrganization[]>(APP_CONFIG.organizations.url + query, { observe: 'response' }).pipe(
+    return this._httpClient.get<IOrganization[]>(APP_CONFIG.organizations.url + query, { withCredentials: true, observe: 'response' }).pipe(
       map((response) => {
         const totalCount = response.headers.get('Content-Range');
         const organizations = [];
@@ -42,7 +42,7 @@ export class OrganizationService {
   }
 
   findById(id): Observable<Organization> {
-    return this._httpClient.get<IOrganization>(APP_CONFIG.organizations.url + id).pipe(
+    return this._httpClient.get<IOrganization>(APP_CONFIG.organizations.url + id, { withCredentials: true }).pipe(
       map((response) => {
         return new Organization(response);
       }),
-- 
GitLab