diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html index 517892876170a96675e80b33c73c34c3347bc9a6..dbfe52fe2232339cf8146754edcdd8c96cfee9e4 100644 --- a/src/app/form/form.component.html +++ b/src/app/form/form.component.html @@ -5,8 +5,13 @@ (closed)="hasRedirectionAccepted($event)" ></app-modal-confirmation> <div class="content" *ngIf="!isLoading" [ngClass]="{ editMode: isEditMode }"> - <div class="headerEditMode" *ngIf="isEditMode"> + <div class="headerEditMode" *ngIf="isEditMode" fxLayout="row" fxLayoutAlign="space-between center"> <h2>Modification de {{ editForm.get('structureName').value }}</h2> + <app-structure-options-modal + [structure]="structureWithOwners" + [isEditFormView]="true" + (closed)="structureDeleted()" + ></app-structure-options-modal> </div> <div class="returnBtnSection" *ngIf="isEditMode && currentPage != 0"> <button class="btn-primary previous" (click)="goToSpecificPage(0, false)"> diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index 2b9b3f25ad39a8cb9d7e0adb223ebbc3ab9f1198..dcc151211a8f72f9e0b65eb1e66852d31a7457a1 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -18,6 +18,7 @@ import { AuthService } from '../services/auth.service'; import { first } from 'rxjs/operators'; import { PageTypeEnum } from './pageType.enum'; import { CustomRegExp } from '../utils/CustomRegExp'; +import { StructureWithOwners } from '../models/structureWithOwners.model'; const { DateTime } = require('luxon'); @Component({ selector: 'app-structureForm', @@ -71,6 +72,7 @@ export class FormComponent implements OnInit { public isJoinMode = false; public isLoading = false; public isWifiChoosen = false; + public structureWithOwners: StructureWithOwners; constructor( private structureService: StructureService, @@ -92,7 +94,11 @@ export class FormComponent implements OnInit { if (history.state.data) { this.isEditMode = true; this.isWifiChoosen = true; - this.initForm(new Structure(history.state.data)); + const editStructure = new Structure(history.state.data); + this.initForm(editStructure); + this.structureService.getStructureWithOwners(editStructure._id, this.profile).subscribe((s) => { + this.structureWithOwners = s; + }); } else if (history.state.newUser) { this.isClaimMode = true; // Handle join strucutre, the case is very similar to claim @@ -903,4 +909,8 @@ export class FormComponent implements OnInit { public displayClaimStructure(): boolean { return this.currentPage == this.pageTypeEnum.summary && !this.isEditMode && this.isClaimMode; } + + public structureDeleted(): void { + this.router.navigateByUrl('home'); + } } diff --git a/src/app/shared/components/modal-options/modal-options.component.html b/src/app/shared/components/modal-options/modal-options.component.html index 6d8a62025d9bdd3ba23176954b43e8dca002b8b4..0e45ca7cc1e91a5f82d66650fc0b615808afc922 100644 --- a/src/app/shared/components/modal-options/modal-options.component.html +++ b/src/app/shared/components/modal-options/modal-options.component.html @@ -28,7 +28,13 @@ <app-svg-icon [type]="'ico'" [iconColor]="'inherit'" [icon]="'remove'"></app-svg-icon> <p>Supprimer un compte</p> </div> - <div (click)="closeModal(functionType.editStructure)" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="9px"> + <div + *ngIf="!isEditFormView" + (click)="closeModal(functionType.editStructure)" + fxLayout="row" + fxLayoutAlign="start center" + fxLayoutGap="9px" + > <app-svg-icon [type]="'ico'" [iconColor]="'inherit'" [icon]="'edit'"></app-svg-icon> <p>Modifier la structure</p> </div> diff --git a/src/app/shared/components/modal-options/modal-options.component.ts b/src/app/shared/components/modal-options/modal-options.component.ts index 1fa03b1ed4ecf094413960397ffc3cb23104cf12..4de502a5c414fe46cc6ebf71b77002bb53ba0276 100644 --- a/src/app/shared/components/modal-options/modal-options.component.ts +++ b/src/app/shared/components/modal-options/modal-options.component.ts @@ -12,6 +12,7 @@ export class ModalOptionsComponent implements OnInit { constructor() {} @Input() isModalProfileOpts = false; @Input() hasOwners = true; + @Input() public isEditFormView? = false; @Output() closed = new EventEmitter<number>(); ngOnInit(): void {} diff --git a/src/app/shared/components/structure-options-modal/structure-options-modal.component.html b/src/app/shared/components/structure-options-modal/structure-options-modal.component.html index 1857d0baa2a6b04ef454ce6cb3553f03a18bd95e..a5f68cc4d0a307ce11d08f91d231ff29168fd1a1 100644 --- a/src/app/shared/components/structure-options-modal/structure-options-modal.component.html +++ b/src/app/shared/components/structure-options-modal/structure-options-modal.component.html @@ -7,6 +7,7 @@ <ul *ngIf="showModalOption" class="dropdown"> <app-modal-options [isModalProfileOpts]="!structure" + [isEditFormView]="structure && isEditFormView" [hasOwners]="structure && structure.owners.length > 0" (closed)="closeModalOpts($event)" ></app-modal-options> diff --git a/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts b/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts index 2ae893c849c3701099b3f1244bb9585cfaf2e29d..dccf978c4e929bdb5d20882d324656e9f4a42366 100644 --- a/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts +++ b/src/app/shared/components/structure-options-modal/structure-options-modal.component.ts @@ -21,6 +21,7 @@ export class StructureOptionsModalComponent implements OnInit { // Global var @Input() public structure?: StructureWithOwners; @Input() public userProfile?: User; + @Input() public isEditFormView? = false; @Output() closed = new EventEmitter(); public active: boolean;