From 9697e5e7d17e5f6098d34ad055fac25b5ca0487b Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Mon, 10 Feb 2020 18:38:46 +0100 Subject: [PATCH] FEAT #12346 TIME 0:35 change control to unsign document --- src/app/resource/controllers/ResController.php | 5 +++-- src/frontend/app/viewer/document-viewer.component.html | 6 ++++-- src/frontend/app/viewer/document-viewer.component.ts | 2 ++ src/frontend/lang/lang-en.ts | 1 + src/frontend/lang/lang-fr.ts | 1 + src/frontend/lang/lang-nl.ts | 1 + 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index c79a750a475..2f1fab45b28 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -375,13 +375,14 @@ class ResController extends ResourceControlController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } - $document = ResModel::getById(['select' => ['filename', 'format'], 'resId' => $aArgs['resId']]); + $document = ResModel::getById(['select' => ['filename', 'format', 'typist'], 'resId' => $aArgs['resId']]); if (empty($document)) { return $response->withStatus(400)->withJson(['errors' => 'Document does not exist']); } elseif (empty($document['filename'])) { return $response->withStatus(400)->withJson(['errors' => 'Document has no file']); } $originalFormat = $document['format']; + $creatorId = $document['typist']; $convertedDocument = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resId'], 'collId' => 'letterbox_coll']); if (!empty($convertedDocument['errors'])) { @@ -426,7 +427,7 @@ class ResController extends ResourceControlController $data = $request->getQueryParams(); if ($data['mode'] == 'base64') { - return $response->withJson(['encodedDocument' => base64_encode($fileContent), 'originalFormat' => $originalFormat]); + return $response->withJson(['encodedDocument' => base64_encode($fileContent), 'originalFormat' => $originalFormat, 'originalCreatorId' => $creatorId]); } else { $finfo = new \finfo(FILEINFO_MIME_TYPE); $mimeType = $finfo->buffer($fileContent); diff --git a/src/frontend/app/viewer/document-viewer.component.html b/src/frontend/app/viewer/document-viewer.component.html index 4c4c1fff572..989050e8308 100644 --- a/src/frontend/app/viewer/document-viewer.component.html +++ b/src/frontend/app/viewer/document-viewer.component.html @@ -114,8 +114,10 @@ (click)="saveMainDocument()"> <mat-icon style="height:auto;font-size:20px;" class="fas fa-check"></mat-icon> </button> -<button mat-raised-button *ngIf="!isDocModified && mode === 'mainDocument' && resId !== null && !functions.empty(file.subinfos) && file.subinfos.signedDocVersions && privilegeService.hasCurrentUserPrivilege('sign_document');" color="warn" +<button mat-raised-button + *ngIf="!isDocModified && mode === 'mainDocument' && resId !== null && !functions.empty(file.subinfos) && file.subinfos.signedDocVersions && (privilegeService.hasCurrentUserPrivilege('sign_document') || this.headerService.user.id == file.creatorId)" + color="warn" [title]="lang.unsign" style="position: fixed;z-index: 1;bottom: 30px;right: 70px;" (click)="unsignMainDocument()"> - Supprimer la signature + {{lang.removeSignature}} </button> \ No newline at end of file diff --git a/src/frontend/app/viewer/document-viewer.component.ts b/src/frontend/app/viewer/document-viewer.component.ts index 7776184b190..6cea2aa0230 100644 --- a/src/frontend/app/viewer/document-viewer.component.ts +++ b/src/frontend/app/viewer/document-viewer.component.ts @@ -521,6 +521,7 @@ export class DocumentViewerComponent implements OnInit { if (data.encodedDocument) { this.file.contentMode = 'route'; this.file.format = data.originalFormat; + this.file.creatorId = data.originalCreatorId; this.file.content = `../../rest/attachments/${resId}/originalContent`; this.file.contentView = `../../rest/attachments/${resId}/content?mode=view`; this.file.src = this.base64ToArrayBuffer(data.encodedDocument); @@ -548,6 +549,7 @@ export class DocumentViewerComponent implements OnInit { if (this.file.subinfos.mainDocVersions.length > 0) { this.requestWithLoader(`../../rest/resources/${resId}/content?mode=base64`).subscribe( (data: any) => { + this.file.creatorId = data.originalCreatorId; if (!this.file.subinfos.mainDocPDFVersions) { this.file.contentMode = 'route'; this.file.content = `../../rest/resources/${resId}/originalContent`; diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index c8b012ce31a..e30c9d81abe 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1484,6 +1484,7 @@ export const LANG_EN = { "noMailContact" : "No (external) contact linked to this mail", "noSelectedAddress": "No selected address", "documentUnsigned": "This document has been unsigned", + "removeSignature" : "Remove signature", "sent" : "Sent", "notSent" : "Not sent", "delivery" : "Delivery", diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 140a2274cec..7ca8df863fe 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1525,6 +1525,7 @@ export const LANG_FR = { "documentUnsigned": "La signature du document a été retirée", "m2m_ARCHIVETRANSFER" : "Pli numérique", "m2m_ARCHIVETRANSFERREPLY" : "Réponse envoyée", + "removeSignature" : "Supprimer la signature", "sent" : "Envoyé", "notSent" : "Non envoyé", "delivery" : "Pris en charge", diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 6c936c6dee2..5f4b6da211d 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1509,6 +1509,7 @@ export const LANG_NL = { "noMailContact" : "No (external) contact linked to this mail", //_TO_TRANSLATE "noSelectedAddress": "No selected address", //_TO_TRANSLATE "documentUnsigned": "This document has been unsigned", //_TO_TRANSLATE + "removeSignature" : "Remove signature", //_TO_TRANSLATE "sent" : "Sent", //_TO_TRANSLATE "notSent" : "Not sent", //_TO_TRANSLATE "delivery" : "Delivery", //_TO_TRANSLATE -- GitLab