diff --git a/src/frontend/app/attachments/attachments-list.component.html b/src/frontend/app/attachments/attachments-list.component.html index 3b7b35b03ab5a3225b32ce41d9bcb94350dd33ed..f0eafe96a5eeebd75721f6199173e0e9c91ec1f9 100644 --- a/src/frontend/app/attachments/attachments-list.component.html +++ b/src/frontend/app/attachments/attachments-list.component.html @@ -22,7 +22,7 @@ <div class="layout" *ngIf="attachment.hideMainInfo" [@myAnimation] (click)="showAttachment(attachment)"> <button mat-raised-button color="primary" (click)="$event.stopPropagation();showAttachment(attachment)">{{lang.viewResource}}</button> - <button mat-raised-button color="warn" *ngIf="attachment.status!=='SIGN' && attachment.status!=='FRZ'" + <button mat-raised-button color="warn" *ngIf="attachment.status!=='SIGN' && attachment.status!=='FRZ' && canModify" (click)="$event.stopPropagation();deleteAttachment(attachment)" [disabled]="!attachment.canDelete">{{lang.deleteResource}}</button> </div> diff --git a/src/frontend/app/attachments/attachments-list.component.ts b/src/frontend/app/attachments/attachments-list.component.ts index 5e33c41d202d3f43035321bd84d300cf839d9bd6..df4ece050f4a01836d26d02eb0c0aae72d8cfac0 100644 --- a/src/frontend/app/attachments/attachments-list.component.ts +++ b/src/frontend/app/attachments/attachments-list.component.ts @@ -53,11 +53,12 @@ export class AttachmentsListComponent implements OnInit { dialogRef: MatDialogRef<any>; - @Input('injectDatas') injectDatas: any; - @Input('resId') resId: number = null; - @Input('target') target: string = 'panel'; - @Input('autoOpenCreation') autoOpenCreation: boolean = false; - @Output('reloadBadgeAttachments') reloadBadgeAttachments = new EventEmitter<string>(); + @Input() injectDatas: any; + @Input() resId: number = null; + @Input() target: string = 'panel'; + @Input() autoOpenCreation: boolean = false; + @Input() canModify: boolean = false; + @Output() reloadBadgeAttachments = new EventEmitter<string>(); @Output() afterActionAttachment = new EventEmitter<string>(); @@ -175,7 +176,7 @@ export class AttachmentsListComponent implements OnInit { } showAttachment(attachment: any) { - this.dialogRef = this.dialog.open(AttachmentPageComponent, { height: '99vh', width: this.appService.getViewMode() ? '99vw' : '90vw', maxWidth: this.appService.getViewMode() ? '99vw' : '90vw', panelClass: 'attachment-modal-container', disableClose: true, data: { resId: attachment.resId } }); + this.dialogRef = this.dialog.open(AttachmentPageComponent, { height: '99vh', width: this.appService.getViewMode() ? '99vw' : '90vw', maxWidth: this.appService.getViewMode() ? '99vw' : '90vw', panelClass: 'attachment-modal-container', disableClose: true, data: { resId: attachment.resId, editMode : this.canModify } }); this.dialogRef.afterClosed().pipe( filter((data: string) => data === 'success'), diff --git a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts index 94669cd4e414895cd33385d41c86a3b3d9fd8793..bca839bf0ed23c389bb82ddf5a395fdac5ab0aae 100644 --- a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts +++ b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts @@ -99,7 +99,9 @@ export class AttachmentPageComponent implements OnInit { tap((data: any) => { let contact: any = null; - if ((this.privilegeService.hasCurrentUserPrivilege('manage_attachments') || this.headerService.user.id === data.typist) && data.status !== 'SIGN' && data.status !== 'FRZ') { + if (!this.functions.empty(this.data.editMode)) { + this.editMode = this.data.editMode; + } else if ((this.privilegeService.hasCurrentUserPrivilege('manage_attachments') || this.headerService.user.id === data.typist) && data.status !== 'SIGN' && data.status !== 'FRZ') { this.editMode = true; } diff --git a/src/frontend/app/signature-book.component.html b/src/frontend/app/signature-book.component.html index 41323f89927cb88486d1470eac37994577caf8ea..29d55b1da29ea1698c6842c63c0d8d5860630b8b 100755 --- a/src/frontend/app/signature-book.component.html +++ b/src/frontend/app/signature-book.component.html @@ -276,7 +276,7 @@ </div> </div> <app-attachments-list *ngIf="showAttachmentPanel" #appAttachmentsList [resId]="resId" - [target]="'process'" (reloadBadgeAttachments)="refreshAttachments()" + [target]="'process'" [canModify]="canUpdateDocument" (reloadBadgeAttachments)="refreshAttachments()" (afterActionAttachment)="refreshAttachments()"> </app-attachments-list> </div> @@ -318,12 +318,12 @@ <i class="fa fa-plus" style="position:absolute;"></i> </div> <div *ngIf="signatureBook.attachments[rightSelectedThumbnail]"> - <div [ngClass]="{'visaDisabledButton': !signatureBook.attachments[rightSelectedThumbnail].canModify || signatureBook.attachments[rightSelectedThumbnail].status == 'SIGN'}" + <div [ngClass]="{'visaDisabledButton': !canUpdateDocument || signatureBook.attachments[rightSelectedThumbnail].status == 'SIGN'}" title="{{lang.updateAtt}}" class="visaPjUp" (click)="showAttachment(signatureBook.attachments[rightSelectedThumbnail])"> <i class="fa fa-edit fa-2x"></i> </div> - <div [ngClass]="{'visaDisabledButton': !signatureBook.attachments[rightSelectedThumbnail].canDelete}" + <div [ngClass]="{'visaDisabledButton': !canUpdateDocument}" title="{{lang.deleteAtt}}" class="visaPjDel" (click)="delAttachment(signatureBook.attachments[rightSelectedThumbnail])"> <i class="fa fa-trash-alt fa-2x"></i> diff --git a/src/frontend/app/signature-book.component.ts b/src/frontend/app/signature-book.component.ts index 7a97170a48a00029f67b99eb76ac6d63db0de812..4714d306d68e9ff15cf13569958845cfc41c3252 100755 --- a/src/frontend/app/signature-book.component.ts +++ b/src/frontend/app/signature-book.component.ts @@ -54,6 +54,7 @@ export class SignatureBookComponent implements OnInit, OnDestroy { showSignaturesPanel: boolean = false; loading: boolean = false; loadingSign: boolean = false; + canUpdateDocument: boolean = false; subscription: Subscription; currentResourceLock: any = null; @@ -126,6 +127,16 @@ export class SignatureBookComponent implements OnInit, OnDestroy { this.actionService.lockResource(this.userId, this.groupId, this.basketId, [this.resId]); + this.http.get(`../rest/resources/${this.resId}/users/${this.userId}/groups/${this.groupId}/baskets/${this.basketId}/processingData`).pipe( + tap((data: any) => { + this.canUpdateDocument = data.listEventData.canUpdateDocument; + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + this.http.get('../rest/signatureBook/users/' + this.userId + '/groups/' + this.groupId + '/baskets/' + this.basketId + '/resources/' + this.resId) .subscribe((data: any) => { if (data.error) { @@ -344,7 +355,7 @@ export class SignatureBookComponent implements OnInit, OnDestroy { } delAttachment(attachment: any) { - if (attachment.canDelete) { + if (this.canUpdateDocument) { let r = false; if (this.signatureBook.attachments.length <= 1) { r = confirm('Attention, ceci est votre dernière pièce jointe pour ce courrier, voulez-vous vraiment la supprimer ?'); @@ -527,7 +538,7 @@ export class SignatureBookComponent implements OnInit, OnDestroy { } showAttachment(attachment: any) { - if (attachment.canModify && attachment.status !== 'SIGN') { + if (this.canUpdateDocument && attachment.status !== 'SIGN') { if (attachment.isResource) { this.appDocumentViewer.editResource(); } else {