From 9b569e6ac3bfc0abf7c9efac8a88007592c6af97 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Mon, 8 Jul 2019 10:51:18 +0200 Subject: [PATCH] FIX #1183 TIME 0:30 refresh substitue and user list in profile --- src/frontend/app/profile/profile.component.html | 2 +- src/frontend/app/profile/profile.component.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/frontend/app/profile/profile.component.html b/src/frontend/app/profile/profile.component.html index 1d6df07982..0bd3f49d47 100644 --- a/src/frontend/app/profile/profile.component.html +++ b/src/frontend/app/profile/profile.component.html @@ -208,7 +208,7 @@ <div class="form-2-col"> <mat-form-field style="width:100%"> <mat-select placeholder="{{'lang.chooseSubstitute' | translate}}" name="usersList" - [(ngModel)]="profileInfo.substitute" (selectionChange)="selectSubstitute($event)"> + [(ngModel)]="profileInfo.substitute" (selectionChange)="selectSubstitute($event)" (openedChange)="refreshUserList($event)"> <ng-container *ngFor="let userRest of usersList"> <mat-option *ngIf="userRest.id !== profileInfo.id && !userRest.substitute" [value]="userRest.id"> diff --git a/src/frontend/app/profile/profile.component.ts b/src/frontend/app/profile/profile.component.ts index 1d62637ae8..dbefd3525c 100644 --- a/src/frontend/app/profile/profile.component.ts +++ b/src/frontend/app/profile/profile.component.ts @@ -352,6 +352,7 @@ export class ProfileComponent implements OnInit { this.drawSample(); } if (e.index === 2) { + this.refreshInfoSubstitute(); this.swithToAdmin(); } } @@ -404,4 +405,20 @@ export class ProfileComponent implements OnInit { this.http.patch('../rest/users/' + this.authService.user.id + '/signatures/substituted', { 'signatures': this.signaturesService.signaturesList }) .subscribe(); } + + refreshUserList(opened: any) { + if (opened) { + this.http.get('../rest/users') + .subscribe((data: any) => { + this.usersList = data.users; + }); + } + } + + refreshInfoSubstitute() { + this.http.get('../rest/users/' + this.authService.user.id + '/substitute') + .subscribe((data: any) => { + this.authService.user.substitute = data.substitute; + }); + } } -- GitLab