diff --git a/lang/en.json b/lang/en.json index 16e3700c69a18932b50996cd1f2b6c17dc7c420d..8c7c4bfaa0f88dbe6c922fd669c7ffe0012cab0a 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 d04aa454213068aadcfffe38f84504a650ae7396..656eb5090ebdbb7e1bb4ebca24e83f4647fa9f07 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 2bf3e72042435ebc85ff8a9cb4a1e078286177bd..4b20e7ab08eaeb37d3a30165ad3e9783bf14ecc9 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 6e8e42bb3d11aefdbf56b6aee268cb47b9a1feae..1d6df07982f365a0c39280df1602cd741e0cb074 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 24e9e79e66cd7968b6128989a7e633f5ddc421d1..1d62637ae8292e3e946c6a5b037a394a2db04deb 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);