From e4268cb49605c19446a8dd0a858d82aab4c50962 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Mon, 26 Aug 2019 11:26:47 +0200 Subject: [PATCH] FIX #11312 TIME 0:25 remove useless functions --- .../app/profile/profile.component.html | 31 ++++---- src/frontend/app/profile/profile.component.ts | 73 +------------------ 2 files changed, 17 insertions(+), 87 deletions(-) diff --git a/src/frontend/app/profile/profile.component.html b/src/frontend/app/profile/profile.component.html index f1cf21a3a7..e7979e10b4 100644 --- a/src/frontend/app/profile/profile.component.html +++ b/src/frontend/app/profile/profile.component.html @@ -15,8 +15,7 @@ </div> <div class="panel-content"> <form (ngSubmit)="submitProfile()" #profileForm="ngForm"> - <mat-tab-group #tabProfile (selectedTabChange)="initProfileTab($event);" - (swipeleft)="switchToleft(tabProfile)" (swiperight)="switchToRight(tabProfile)"> + <mat-tab-group #tabProfile (selectedTabChange)="initProfileTab($event);"> <mat-tab label="{{'lang.informations' | translate}}"> <div class="profile-content"> <mat-form-field class="input-row"> @@ -202,19 +201,21 @@ <legend align="left">{{'lang.substitute' | translate}}</legend> <div class="form-container"> <div class="form-col"> - <ng-container *ngFor="let user of usersList"> - <mat-form-field class="selectedSubstitute" *ngIf="user.id === authService.user.substitute"> - <input matInput - [value]="user.lastname + ' ' + user.firstname" readonly> - <button matSuffix mat-icon-button type="button" - (tap)="deleteSubstitute()" color="warn" title="{{'lang.deleteSubstitution' | translate}}"> - <mat-icon fontSet="fas" fontIcon="fa-times fa-2x"></mat-icon> - </button> - </mat-form-field> - </ng-container> - <plugin-autocomplete *ngIf="authService.user.substitute === null" [labelPlaceholder]="'lang.chooseSubstitute' | translate" - [routeDatas]="['/rest/autocomplete/users']" [targetSearchKey]="['lastname', 'firstname']" [subInfoKey]="'email'" - (triggerEvent)="selectSubstitute($event)" [excludeClause]="[{id:profileInfo.id}, {substitute: true}]"></plugin-autocomplete> + <mat-form-field class="selectedSubstitute" + *ngIf="authService.user.substitute !== null"> + <input matInput [value]="authService.user.substituteUser" readonly> + <button matSuffix mat-icon-button type="button" (tap)="deleteSubstitute()" + color="warn" title="{{'lang.deleteSubstitution' | translate}}"> + <mat-icon fontSet="fas" fontIcon="fa-times fa-2x"></mat-icon> + </button> + </mat-form-field> + <plugin-autocomplete *ngIf="authService.user.substitute === null" + [labelPlaceholder]="'lang.chooseSubstitute' | translate" + [routeDatas]="['/rest/autocomplete/users']" + [targetSearchKey]="['lastname', 'firstname']" [subInfoKey]="'email'" + (triggerEvent)="selectSubstitute($event)" + [excludeClause]="[{id:profileInfo.id}, {substitute: true}]"> + </plugin-autocomplete> </div> </div> </fieldset> diff --git a/src/frontend/app/profile/profile.component.ts b/src/frontend/app/profile/profile.component.ts index 58697aa9eb..31af9acaab 100644 --- a/src/frontend/app/profile/profile.component.ts +++ b/src/frontend/app/profile/profile.component.ts @@ -278,6 +278,7 @@ export class ProfileComponent implements OnInit { } selectSubstitute(newUserSubtituted: any) { + if (this.profileInfo.substitute !== null) { alert(this.translate.instant('lang.substitutionWarn')); } @@ -371,85 +372,13 @@ export class ProfileComponent implements OnInit { if (e.index === 1) { this.drawSample(); } - if (e.index === 2) { - this.refreshInfoSubstitute(); - this.swithToAdmin(); - } } counter(i: number) { return new Array(i); } - switchToleft(tab: MatTabGroup) { - tab.selectedIndex++; - - if (tab.selectedIndex === 2) { - this.swithToAdmin(); - } - } - - switchToRight(tab: MatTabGroup) { - if (tab.selectedIndex > 0) { - tab.selectedIndex--; - - if (tab.selectedIndex === 2) { - this.swithToAdmin(); - } - } - } - - swithToAdmin() { - if (this.authService.user.substitute || this.usersList.length === 0) { - this.http.get('../rest/users').pipe( - map((data: any) => { - data.users.forEach((element: any) => { - if (element.id !== this.profileInfo.id && !element.substitute) { - element.disabled = false; - } else { - element.disabled = true; - } - }); - return data; - }), - tap((data: any) => this.usersList = data.users), - ).subscribe(); - } - - if (this.signaturesService.signaturesList.length === 0) { - this.http.get('../rest/users/' + this.profileInfo.id + '/signatures') - .subscribe((data: any) => { - this.signaturesService.signaturesList = data.signatures; - }); - } - } - setLang(lang: any) { this.translate.use(lang); } - - refreshUserList() { - this.usersList = []; - this.http.get('../rest/users').pipe( - map((data: any) => { - data.users.forEach((element: any) => { - if (element.id !== this.profileInfo.id && !element.substitute) { - element.disabled = false; - } else { - element.disabled = true; - } - }); - return data; - }), - tap((data: any) => this.usersList = data.users), - ).subscribe(); - } - - refreshInfoSubstitute() { - this.http.get('../rest/users/' + this.authService.user.id + '/substitute') - .subscribe((data: any) => { - this.authService.user.substitute = data.substitute; - this.profileInfo.substitute = data.substitute; - }); - } } -- GitLab