Skip to content
Snippets Groups Projects
Commit 011e7fd9 authored by Quentin Ribac's avatar Quentin Ribac
Browse files

Merge branch 'fix/20508/21.03' into '21.03'

[20508] [Délégation] L'image de la signature reste accessible par l'utilisateur délégataire après suppression du délégation (21.03)

See merge request maarch/MaarchParapheur!128
parents 6c8534c0 f7540891
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ import { Router } from '@angular/router';
import { tap, exhaustMap, filter, catchError, finalize, switchMap } from 'rxjs/operators';
import { AuthService } from '../service/auth.service';
import { Observable, of } from 'rxjs';
import { ModalController } from '@ionic/angular';
import { AlertController, ModalController } from '@ionic/angular';
@Component({
selector: 'app-my-profile',
......@@ -75,17 +75,19 @@ export class ProfileComponent implements OnInit {
signatureScaling: any = 25;
originalSize: boolean = false;
constructor(private translate: TranslateService,
constructor(
public http: HttpClient,
private router: Router,
public sanitizer: DomSanitizer,
public notificationService: NotificationService,
public signaturesService: SignaturesContentService,
public authService: AuthService,
private cookieService: CookieService,
public filtersService: FiltersService,
public modalController: ModalController,
private renderer: Renderer2,
public modalController: ModalController
private translate: TranslateService,
private alertController: AlertController,
private cookieService: CookieService,
private router: Router,
) { }
ngOnInit(): void {
......@@ -321,22 +323,54 @@ export class ProfileComponent implements OnInit {
});
}
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']);
async deleteSubstitute() {
const alert = await this.alertController.create({
header: this.translate.instant('lang.confirmMsg'),
buttons: [
{
text: this.translate.instant('lang.no'),
role: 'cancel',
cssClass: 'secondary',
handler: () => { }
},
{
text: this.translate.instant('lang.yes'),
handler: () => {
const substitutedSignatures: any[] = this.signaturesService.signaturesList.filter((signature: any) => signature.substituted);
this.profileInfo.substitute = null;
this.http.put('../rest/users/' + this.authService.user.id + '/substitute', { substitute: this.profileInfo.substitute }).pipe(
tap((data: any) => {
this.authService.updateUserInfoWithTokenRefresh();
this.filtersService.resfreshDocuments();
if (substitutedSignatures.length > 0) {
substitutedSignatures.forEach((signature: any) => {
this.http.patch('../rest/users/' + this.authService.user.id + '/signatures/' + signature.id + '/substituted', { 'substituted': false }).pipe(
tap(() => {
this.signaturesService.signaturesList.find((item: any) => item.id === signature.id).substituted = false;
}),
catchError((err: any) => {
this.notificationService.handleErrors(err);
return of(false);
})
).subscribe();
});
}
if (this.signaturesService.documentsList.length > 0 && this.signaturesService.documentsList[this.signaturesService.indexDocumentsList].owner === false) {
this.router.navigate(['/documents']);
}
this.notificationService.success('lang.substitutionDeleted');
}),
catchError((err: any) => {
this.notificationService.handleErrors(err);
return of(false);
})
).subscribe();
}
this.notificationService.success('lang.substitutionDeleted');
});
}
}
]
});
await alert.present();
}
handleFileInput(files: FileList) {
......
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