From 18a933a19b98fdb1c80d967486999dd7fe987a1b Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 3 Jul 2019 17:02:51 +0200 Subject: [PATCH] FIX #11183 TIME 0:15 fix substitute delete + add --- lang/en.json | 3 ++- lang/fr.json | 3 ++- .../app/document/document.component.ts | 5 +--- .../app/profile/profile.component.html | 4 +-- src/frontend/app/profile/profile.component.ts | 25 ++++++++++++++++--- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/lang/en.json b/lang/en.json index 16e3700c69..8c7c4bfaa0 100755 --- a/lang/en.json +++ b/lang/en.json @@ -253,6 +253,7 @@ "groupDeleted" : "Group deleted", "importNewSignature" : "Import a new signature", "restUser" : "Webservice user", - "unlinkUser" : "Unlink user" + "unlinkUser" : "Unlink user", + "substituteEnabled" : "Substitute enabled" } } diff --git a/lang/fr.json b/lang/fr.json index d04aa45421..656eb5090e 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -254,6 +254,7 @@ "groupDeleted" : "Groupe supprimé", "importNewSignature" : "Importer une signature", "restUser" : "Utilisateur webservice", - "unlinkUser" : "Dissocier l'utilisateur" + "unlinkUser" : "Dissocier l'utilisateur", + "substituteEnabled" : "Délégation activée" } } diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts index 2bf3e72042..4b20e7ab08 100755 --- a/src/frontend/app/document/document.component.ts +++ b/src/frontend/app/document/document.component.ts @@ -507,10 +507,7 @@ export class DocumentComponent implements OnInit { const r = confirm(this.translate.instant('lang.deleteSubstitution') + ' ?'); if (r) { - const userUpdated = this.authService.user; - userUpdated.substitute = null; - - this.http.put('../rest/users/' + this.authService.user.id, userUpdated) + this.http.put('../rest/users/' + this.authService.user.id + '/substitute', { substitute: null }) .subscribe(() => { this.authService.updateUserInfoWithTokenRefresh(); this.notificationService.success('lang.substitutionDeleted'); diff --git a/src/frontend/app/profile/profile.component.html b/src/frontend/app/profile/profile.component.html index 6e8e42bb3d..1d6df07982 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)="toggleSubstitute($event)"> + [(ngModel)]="profileInfo.substitute" (selectionChange)="selectSubstitute($event)"> <ng-container *ngFor="let userRest of usersList"> <mat-option *ngIf="userRest.id !== profileInfo.id && !userRest.substitute" [value]="userRest.id"> @@ -217,7 +217,7 @@ </ng-container> </mat-select> <button matSuffix *ngIf="profileInfo.substitute != null" mat-icon-button type="button" - (tap)="profileInfo.substitute = null" color="warn" title="{{'lang.deleteSubstitution' | translate}}"> + (tap)="deleteSubstitute()" color="warn" title="{{'lang.deleteSubstitution' | translate}}"> <mat-icon fontSet="fas" fontIcon="fa-times fa-2x"></mat-icon> </button> </mat-form-field> diff --git a/src/frontend/app/profile/profile.component.ts b/src/frontend/app/profile/profile.component.ts index 24e9e79e66..1d62637ae8 100644 --- a/src/frontend/app/profile/profile.component.ts +++ b/src/frontend/app/profile/profile.component.ts @@ -255,24 +255,41 @@ export class ProfileComponent implements OnInit { }); } - toggleSubstitute(ev: any) { + selectSubstitute(ev: any) { if (this.profileInfo.substitute !== null) { alert(this.translate.instant('lang.substitutionWarn')); } const newUserSubtituted = ev.value; - // TO DO : ROUTE IS FAKE - this.http.put('../rest/users/' + this.authService.user.id + '/substitute', newUserSubtituted) + this.http.put('../rest/users/' + this.authService.user.id + '/substitute', { substitute: newUserSubtituted }) .subscribe(() => { this.authService.updateUserInfoWithTokenRefresh(); this.filtersService.resfreshDocuments(); if (this.signaturesService.documentsList.length > 0 && this.signaturesService.documentsList[this.signaturesService.indexDocumentsList].owner === false) { this.router.navigate(['/documents']); } - this.notificationService.success('lang.userSubstituted'); + this.notificationService.success('lang.substituteEnabled'); }); } + deleteSubstitute() { + const r = confirm(this.translate.instant('lang.deleteSubstitution') + ' ?'); + + if (r) { + this.profileInfo.substitute = null; + + this.http.put('../rest/users/' + this.authService.user.id + '/substitute', { substitute: this.profileInfo.substitute }) + .subscribe(() => { + this.authService.updateUserInfoWithTokenRefresh(); + this.filtersService.resfreshDocuments(); + if (this.signaturesService.documentsList.length > 0 && this.signaturesService.documentsList[this.signaturesService.indexDocumentsList].owner === false) { + this.router.navigate(['/documents']); + } + this.notificationService.success('lang.substitutionDeleted'); + }); + } + } + handleFileInput(files: FileList) { this.passwordContent.close(); const fileToUpload = files.item(0); -- GitLab