diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index fe7e093961d7a19e4887e3cc944cece615040cfd..ecaa01eea467f9ac33b4ae75b2d60923171b89e4 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 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..d1835a7f3bfb7c6820c8341cc2f55784e6a993b1 --- /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 0000000000000000000000000000000000000000..c1dd6380533aa8b6cd2c19e79b8bcad496bb1e29 --- /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 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..57a132f12398e7181f4773df59f3d247e5f0400e --- /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 8d9190266c447c4cc1bcf153707c2b7e724a819f..5df01d73dc5fe0d8355d96e3275dd778fe44ae74 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 ? 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 286c670b546355071898ec2e35b9b2875598f51e..6203f7c3df0d490cce2087ab726f76ab61a80dba 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); + } + } }