From c2854d0ae3fb927644f199a6ec38a8695bbbb91e Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Fri, 2 Apr 2021 17:56:56 +0200
Subject: [PATCH 1/3] report error on structur form list

---
 src/app/services/structure.service.ts         |  6 +++
 src/app/shared/components/index.ts            |  3 ++
 .../text-input-modal.component.html           | 14 +++++
 .../text-input-modal.component.scss           | 52 +++++++++++++++++++
 .../text-input-modal.component.spec.ts        | 25 +++++++++
 .../text-input-modal.component.ts             | 20 +++++++
 .../structure-details.component.html          | 17 ++++++
 .../structure-details.component.ts            | 20 +++++--
 8 files changed, 154 insertions(+), 3 deletions(-)
 create mode 100644 src/app/shared/components/text-input-modal/text-input-modal.component.html
 create mode 100644 src/app/shared/components/text-input-modal/text-input-modal.component.scss
 create mode 100644 src/app/shared/components/text-input-modal/text-input-modal.component.spec.ts
 create mode 100644 src/app/shared/components/text-input-modal/text-input-modal.component.ts

diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts
index fe7e09396..ecaa01eea 100644
--- a/src/app/services/structure.service.ts
+++ b/src/app/services/structure.service.ts
@@ -193,4 +193,10 @@ export class StructureService {
   public getStructureWithOwners(structureId: string, profile: User): Observable<StructureWithOwners> {
     return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile.email });
   }
+
+  public sendMailOnStructureError(structureId: string, content: string, profile: User): Observable<boolean> {
+    console.log('send:', content, ' to:', structureId);
+    return;
+    //return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile.email });
+  }
 }
diff --git a/src/app/shared/components/index.ts b/src/app/shared/components/index.ts
index 9cad91820..1b135b043 100644
--- a/src/app/shared/components/index.ts
+++ b/src/app/shared/components/index.ts
@@ -14,6 +14,7 @@ import { RadioFormComponent } from './radio-form/radio-form.component';
 import { ModalConfirmationComponent } from './modal-confirmation/modal-confirmation.component';
 import { StructureOptionsModalComponent } from './structure-options-modal/structure-options-modal.component';
 import { ModalOptionsComponent } from './modal-options/modal-options.component';
+import { TextInputModalComponent } from './text-input-modal/text-input-modal.component';
 
 // tslint:disable-next-line: max-line-length
 export {
@@ -33,6 +34,7 @@ export {
   ModalConfirmationComponent,
   StructureOptionsModalComponent,
   ModalOptionsComponent,
+  TextInputModalComponent,
 };
 
 // tslint:disable-next-line:variable-name
@@ -53,4 +55,5 @@ export const SharedComponents = [
   ModalConfirmationComponent,
   StructureOptionsModalComponent,
   ModalOptionsComponent,
+  TextInputModalComponent,
 ];
diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.html b/src/app/shared/components/text-input-modal/text-input-modal.component.html
new file mode 100644
index 000000000..d1835a7f3
--- /dev/null
+++ b/src/app/shared/components/text-input-modal/text-input-modal.component.html
@@ -0,0 +1,14 @@
+<div *ngIf="openned" class="modalBackground" ng-controller="myCtrl">
+  <div class="modal">
+    <div class="contentModal" fxLayout="column" fxLayoutAlign="space-around center">
+      <h3>ATTENTION</h3>
+      <p>{{ content }}</p>
+      <textarea ng-model="myContent" id="story" class="textarea" name="story" rows="6">{{ placeholder }}</textarea>
+      <div class="footerModal" fxLayout="row" fxLayoutAlign="space-around center">
+        <button class="btn-primary small leave" (click)="closeModal(true)">Confirmer</button>
+        <button class="btn-primary small" (click)="closeModal(false)">Annuler</button>
+      </div>
+      {{ myContent }}
+    </div>
+  </div>
+</div>
diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.scss b/src/app/shared/components/text-input-modal/text-input-modal.component.scss
new file mode 100644
index 000000000..c1dd63805
--- /dev/null
+++ b/src/app/shared/components/text-input-modal/text-input-modal.component.scss
@@ -0,0 +1,52 @@
+@import '../../../../assets/scss/color';
+@import '../../../../assets/scss/typography';
+@import '../../../../assets/scss/shapes';
+@import '../../../../assets/scss/z-index';
+
+.modalExitContainer {
+  width: 100%;
+  height: 100%;
+  z-index: $modal-z-index;
+  position: absolute;
+  content: '';
+  top: 0;
+  background-color: $modal-background;
+  .modal {
+    .contentModal {
+      width: 100%;
+      background: $white;
+      padding: 35px 20px 18px 20px;
+      h3 {
+        @include cn-bold-18;
+        color: $orange-warning;
+      }
+      p {
+        @include cn-bold-16;
+        color: $grey-1;
+        text-align: center;
+      }
+      .footerModal {
+        width: 100%;
+        margin-top: 14px;
+        @include cn-bold-16;
+        .leave {
+          background: none;
+          color: $grey-1;
+          text-decoration: underline;
+        }
+      }
+    }
+    width: 350px;
+    margin: auto;
+    border-radius: 6px;
+    @include background-hash($grey-2);
+    border: 1px solid $grey-4;
+    margin-top: 50vh;
+    transform: translateY(-50%);
+  }
+}
+
+.textarea {
+  width: 100%;
+  background-color: #f8f8f8;
+}
diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.spec.ts b/src/app/shared/components/text-input-modal/text-input-modal.component.spec.ts
new file mode 100644
index 000000000..75318c94d
--- /dev/null
+++ b/src/app/shared/components/text-input-modal/text-input-modal.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { TextInputModalComponent } from './text-input-modal.component';
+
+describe('ModalConfirmationComponent', () => {
+  let component: TextInputModalComponent;
+  let fixture: ComponentFixture<TextInputModalComponent>;
+
+  beforeEach(async () => {
+    await TestBed.configureTestingModule({
+      declarations: [ TextInputModalComponent ]
+    })
+    .compileComponents();
+  });
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(TextInputModalComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});
diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.ts b/src/app/shared/components/text-input-modal/text-input-modal.component.ts
new file mode 100644
index 000000000..57a132f12
--- /dev/null
+++ b/src/app/shared/components/text-input-modal/text-input-modal.component.ts
@@ -0,0 +1,20 @@
+import { Component, EventEmitter, Input, Output } from '@angular/core';
+
+@Component({
+  selector: 'app-text-input-modal',
+  templateUrl: './text-input-modal.component.html',
+  styleUrls: ['./text-input-modal.component.scss'],
+})
+export class TextInputModalComponent {
+  @Input() public openned: boolean;
+  @Input() public content: string;
+  @Input() public placeholder: string;
+  @Output() closed = new EventEmitter<boolean>();
+
+  public myContent: string;
+  constructor() {}
+
+  public closeModal(value: boolean): void {
+    this.closed.emit(value);
+  }
+}
diff --git a/src/app/structure-list/components/structure-details/structure-details.component.html b/src/app/structure-list/components/structure-details/structure-details.component.html
index 8d9190266..5df01d73d 100644
--- a/src/app/structure-list/components/structure-details/structure-details.component.html
+++ b/src/app/structure-list/components/structure-details/structure-details.component.html
@@ -124,6 +124,14 @@
       <div fxLayout="row" fxLayoutAlign="center center" class="hide-on-print">
         <a *ngIf="!isClaimed" (click)="handleClaim()" class="primary" tabindex="0">Revendiquer cette structure</a>
         <a *ngIf="displayJoin()" (click)="handleJoin()" class="primary" tabindex="0">Rejoindre cette structure</a>
+        <a
+          *ngIf="!profileService.isLinkedToStructure(structure._id) && !profileService.isAdmin()"
+          (click)="displayModalError()"
+          class="primary"
+          tabindex="0"
+        >
+          Signaler une erreur
+        </a>
         <!-- temporary remove edit -->
         <a
           *ngIf="profileService.isLinkedToStructure(structure._id) || profileService.isAdmin()"
@@ -369,3 +377,12 @@
   "
   (closed)="joinStructure($event)"
 ></app-modal-confirmation>
+
+<app-text-input-modal
+  [openned]="structureErrorModalOpenned"
+  [placeholder]="'Décrivez l\'erreur ici'"
+  [content]="
+    'Voulez-vous notifier res\'in d\'une erreur sur la fiche de cet acteur&nbsp;? Votre commentaire sera envoyé aux administrateurs.'
+  "
+  (closed)="sendErrorEmail($event)"
+></app-text-input-modal>
diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts
index 286c670b5..6203f7c3d 100644
--- a/src/app/structure-list/components/structure-details/structure-details.component.ts
+++ b/src/app/structure-list/components/structure-details/structure-details.component.ts
@@ -42,6 +42,7 @@ export class StructureDetailsComponent implements OnInit {
   public currentProfile: User = null;
   public deleteModalOpenned = false;
   public claimModalOpenned = false;
+  public structureErrorModalOpenned = false;
   public joinModalOpenned = false;
 
   constructor(
@@ -236,13 +237,13 @@ export class StructureDetailsComponent implements OnInit {
       _.find(this.accessRightsReferentiel.modules, { id: rights })
     );
     this.parentingHelp = this.structure.parentingHelp.map((help) =>
-    _.find(this.parentingHelpsReferentiel.modules, { id: help })
+      _.find(this.parentingHelpsReferentiel.modules, { id: help })
     );
     this.socialAndProfessional = this.structure.socialAndProfessional.map((skill) =>
-    _.find(this.socialAndProfessionalsReferentiel.modules, { id: skill })
+      _.find(this.socialAndProfessionalsReferentiel.modules, { id: skill })
     );
     this.digitalCultureSecurity = this.structure.digitalCultureSecurity.map((skill) =>
-    _.find(this.digitalCultureSecuritysReferentiel.modules, { id: skill })
+      _.find(this.digitalCultureSecuritysReferentiel.modules, { id: skill })
     );
   }
 
@@ -288,4 +289,17 @@ export class StructureDetailsComponent implements OnInit {
       !this.profileService.isPendingLinkedToStructure(this.structure._id)
     );
   }
+
+  public displayModalError(): void {
+    //do we need to check for user is logged ?
+    this.structureErrorModalOpenned = !this.structureErrorModalOpenned;
+  }
+
+  public sendErrorEmail(shouldSend: boolean, content: string): void {
+    this.displayModalError();
+    if (shouldSend) {
+      console.log('conrtent is:', content);
+      this.structureService.sendMailOnStructureError(this.structure._id, '', this.currentProfile);
+    }
+  }
 }
-- 
GitLab


From 7e474af4c9616595947272066c48f319c04ba2d9 Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Tue, 6 Apr 2021 14:14:47 +0200
Subject: [PATCH 2/3] add content value to modal

---
 src/app/services/structure.service.ts                    | 9 +++++----
 .../text-input-modal/text-input-modal.component.html     | 7 +++----
 .../text-input-modal/text-input-modal.component.ts       | 5 +++--
 .../structure-details/structure-details.component.html   | 1 +
 .../structure-details/structure-details.component.ts     | 9 +++++----
 5 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts
index ecaa01eea..507582392 100644
--- a/src/app/services/structure.service.ts
+++ b/src/app/services/structure.service.ts
@@ -194,9 +194,10 @@ export class StructureService {
     return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile.email });
   }
 
-  public sendMailOnStructureError(structureId: string, content: string, profile: User): Observable<boolean> {
-    console.log('send:', content, ' to:', structureId);
-    return;
-    //return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile.email });
+  public sendMailOnStructureError(structureId: string, content: string, profile: User) {
+    return this.http.post<any>(`${this.baseUrl}/reportStructureError`, {
+      structureId,
+      content: content,
+    });
   }
 }
diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.html b/src/app/shared/components/text-input-modal/text-input-modal.component.html
index d1835a7f3..15f690ba6 100644
--- a/src/app/shared/components/text-input-modal/text-input-modal.component.html
+++ b/src/app/shared/components/text-input-modal/text-input-modal.component.html
@@ -3,12 +3,11 @@
     <div class="contentModal" fxLayout="column" fxLayoutAlign="space-around center">
       <h3>ATTENTION</h3>
       <p>{{ content }}</p>
-      <textarea ng-model="myContent" id="story" class="textarea" name="story" rows="6">{{ placeholder }}</textarea>
+      <textarea #myText id="story" class="textarea" name="story" rows="6">{{ placeholder }}</textarea>
       <div class="footerModal" fxLayout="row" fxLayoutAlign="space-around center">
-        <button class="btn-primary small leave" (click)="closeModal(true)">Confirmer</button>
-        <button class="btn-primary small" (click)="closeModal(false)">Annuler</button>
+        <button class="btn-primary small leave" (click)="closeModal(true, myText.value)">Confirmer</button>
+        <button class="btn-primary small" (click)="closeModal(false, myText.value)">Annuler</button>
       </div>
-      {{ myContent }}
     </div>
   </div>
 </div>
diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.ts b/src/app/shared/components/text-input-modal/text-input-modal.component.ts
index 57a132f12..524396cda 100644
--- a/src/app/shared/components/text-input-modal/text-input-modal.component.ts
+++ b/src/app/shared/components/text-input-modal/text-input-modal.component.ts
@@ -10,11 +10,12 @@ export class TextInputModalComponent {
   @Input() public content: string;
   @Input() public placeholder: string;
   @Output() closed = new EventEmitter<boolean>();
+  @Output() newContent = new EventEmitter<{ content: string; shouldSend: boolean }>();
 
   public myContent: string;
   constructor() {}
 
-  public closeModal(value: boolean): void {
-    this.closed.emit(value);
+  public closeModal(shouldSend: boolean, content: string) {
+    this.newContent.emit({ content, shouldSend });
   }
 }
diff --git a/src/app/structure-list/components/structure-details/structure-details.component.html b/src/app/structure-list/components/structure-details/structure-details.component.html
index 5df01d73d..a4e2d0c4f 100644
--- a/src/app/structure-list/components/structure-details/structure-details.component.html
+++ b/src/app/structure-list/components/structure-details/structure-details.component.html
@@ -385,4 +385,5 @@
     'Voulez-vous notifier res\'in d\'une erreur sur la fiche de cet acteur&nbsp;? Votre commentaire sera envoyé aux administrateurs.'
   "
   (closed)="sendErrorEmail($event)"
+  (newContent)="sendErrorEmail($event)"
 ></app-text-input-modal>
diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts
index 6203f7c3d..79042b400 100644
--- a/src/app/structure-list/components/structure-details/structure-details.component.ts
+++ b/src/app/structure-list/components/structure-details/structure-details.component.ts
@@ -295,11 +295,12 @@ export class StructureDetailsComponent implements OnInit {
     this.structureErrorModalOpenned = !this.structureErrorModalOpenned;
   }
 
-  public sendErrorEmail(shouldSend: boolean, content: string): void {
+  public sendErrorEmail(modalValue: any): void {
     this.displayModalError();
-    if (shouldSend) {
-      console.log('conrtent is:', content);
-      this.structureService.sendMailOnStructureError(this.structure._id, '', this.currentProfile);
+    if (modalValue.shouldSend) {
+      this.structureService
+        .sendMailOnStructureError(this.structure._id, modalValue.content, this.currentProfile)
+        .subscribe(() => {});
     }
   }
 }
-- 
GitLab


From 107127e0fc2f50857aa2e52cec21f5614b5919e8 Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Wed, 7 Apr 2021 15:08:41 +0200
Subject: [PATCH 3/3] some changes after MR review

---
 .../text-input-modal/text-input-modal.component.html       | 2 +-
 .../text-input-modal/text-input-modal.component.scss       | 7 ++++++-
 .../structure-details/structure-details.component.html     | 4 ++--
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.html b/src/app/shared/components/text-input-modal/text-input-modal.component.html
index 15f690ba6..1ba0fc04d 100644
--- a/src/app/shared/components/text-input-modal/text-input-modal.component.html
+++ b/src/app/shared/components/text-input-modal/text-input-modal.component.html
@@ -3,7 +3,7 @@
     <div class="contentModal" fxLayout="column" fxLayoutAlign="space-around center">
       <h3>ATTENTION</h3>
       <p>{{ content }}</p>
-      <textarea #myText id="story" class="textarea" name="story" rows="6">{{ placeholder }}</textarea>
+      <textarea #myText id="story" class="textarea" name="story" rows="6" placeholder="{{ placeholder }}"></textarea>
       <div class="footerModal" fxLayout="row" fxLayoutAlign="space-around center">
         <button class="btn-primary small leave" (click)="closeModal(true, myText.value)">Confirmer</button>
         <button class="btn-primary small" (click)="closeModal(false, myText.value)">Annuler</button>
diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.scss b/src/app/shared/components/text-input-modal/text-input-modal.component.scss
index c1dd63805..91c7bbe39 100644
--- a/src/app/shared/components/text-input-modal/text-input-modal.component.scss
+++ b/src/app/shared/components/text-input-modal/text-input-modal.component.scss
@@ -47,6 +47,11 @@
 }
 
 .textarea {
+  padding: 13px 8px;
+  background: $grey-6;
+  border: 1px solid $grey-4;
+  border-radius: 1px;
+  resize: none;
   width: 100%;
-  background-color: #f8f8f8;
+  @include cn-regular-16;
 }
diff --git a/src/app/structure-list/components/structure-details/structure-details.component.html b/src/app/structure-list/components/structure-details/structure-details.component.html
index a4e2d0c4f..4f1daeeda 100644
--- a/src/app/structure-list/components/structure-details/structure-details.component.html
+++ b/src/app/structure-list/components/structure-details/structure-details.component.html
@@ -380,9 +380,9 @@
 
 <app-text-input-modal
   [openned]="structureErrorModalOpenned"
-  [placeholder]="'Décrivez l\'erreur ici'"
+  [placeholder]="'Décrivez l\'erreur ici. Ex: Horaires faux...'"
   [content]="
-    'Voulez-vous notifier res\'in d\'une erreur sur la fiche de cet acteur&nbsp;? Votre commentaire sera envoyé aux administrateurs.'
+    'Voulez-vous notifier res\'in d\'une erreur sur la fiche de cet acteur &nbsp;? Votre commentaire sera envoyé à l\'acteur en question ainsi qu\'aux administrateurs.'
   "
   (closed)="sendErrorEmail($event)"
   (newContent)="sendErrorEmail($event)"
-- 
GitLab