Skip to content
Snippets Groups Projects
Verified Commit e4268cb4 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FIX #11312 TIME 0:25 remove useless functions

parent bb0473fe
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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;
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment