diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index fe7e093961d7a19e4887e3cc944cece615040cfd..5075823924774b30c36cf6d98ab111f7a74ed495 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -193,4 +193,11 @@ 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) { + return this.http.post<any>(`${this.baseUrl}/reportStructureError`, { + structureId, + content: content, + }); + } } diff --git a/src/app/shared/components/index.ts b/src/app/shared/components/index.ts index 9cad91820ad53c6195edba75cd07a1d27d01aac1..1b135b0434953e6a4df2c462451832b238a7a4a2 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 0000000000000000000000000000000000000000..1ba0fc04d93cef1364cd11e8e0201c94aed4a6da --- /dev/null +++ b/src/app/shared/components/text-input-modal/text-input-modal.component.html @@ -0,0 +1,13 @@ +<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 #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> + </div> + </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 0000000000000000000000000000000000000000..91c7bbe39709576c2582a2dd3875982cf1de7791 --- /dev/null +++ b/src/app/shared/components/text-input-modal/text-input-modal.component.scss @@ -0,0 +1,57 @@ +@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 { + padding: 13px 8px; + background: $grey-6; + border: 1px solid $grey-4; + border-radius: 1px; + resize: none; + width: 100%; + @include cn-regular-16; +} 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 0000000000000000000000000000000000000000..75318c94dccbbe3ffb5cda8aea349fd58f4e7ca4 --- /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 0000000000000000000000000000000000000000..524396cda60cc474a8de4e2af85c3a3a06166244 --- /dev/null +++ b/src/app/shared/components/text-input-modal/text-input-modal.component.ts @@ -0,0 +1,21 @@ +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>(); + @Output() newContent = new EventEmitter<{ content: string; shouldSend: boolean }>(); + + public myContent: string; + constructor() {} + + 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 8d9190266c447c4cc1bcf153707c2b7e724a819f..4f1daeedae31b92c9963dd47bfadc9907babc144 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,13 @@ " (closed)="joinStructure($event)" ></app-modal-confirmation> + +<app-text-input-modal + [openned]="structureErrorModalOpenned" + [placeholder]="'Décrivez l\'erreur ici. Ex: Horaires faux...'" + [content]=" + 'Voulez-vous notifier res\'in d\'une erreur sur la fiche de cet acteur ? Votre commentaire sera envoyé à l\'acteur en question ainsi qu\'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 286c670b546355071898ec2e35b9b2875598f51e..79042b4009613950ac749f5670025022d78f4dfe 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,18 @@ 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(modalValue: any): void { + this.displayModalError(); + if (modalValue.shouldSend) { + this.structureService + .sendMailOnStructureError(this.structure._id, modalValue.content, this.currentProfile) + .subscribe(() => {}); + } + } }