mirror of
https://github.com/LibreSign/libresign.git
synced 2025-12-18 05:20:45 +01:00
Merge pull request #6111 from LibreSign/feat/add-status-text-to-signers
feat: add status text to signers
This commit is contained in:
commit
ce39b110e7
9 changed files with 70 additions and 2 deletions
|
|
@ -283,6 +283,8 @@ class IdDocsMapper extends QBMapper {
|
|||
->format('Y-m-d H:i:s'),
|
||||
'sign_date' => null,
|
||||
'signRequestId' => $signer->getId(),
|
||||
'status' => $signer->getStatus(),
|
||||
'statusText' => $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()),
|
||||
];
|
||||
if ($signer->getSigned()) {
|
||||
$data['sign_date'] = (new \DateTime())
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
namespace OCA\Libresign\Db;
|
||||
|
||||
use DateTimeInterface;
|
||||
use OCA\Libresign\Enum\SignRequestStatus;
|
||||
use OCA\Libresign\Helper\Pagination;
|
||||
use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod;
|
||||
use OCA\Libresign\Service\IdentifyMethodService;
|
||||
|
|
@ -640,4 +641,8 @@ class SignRequestMapper extends QBMapper {
|
|||
$result = preg_replace($extensionPattern, '', $name);
|
||||
return $result ?? $name;
|
||||
}
|
||||
|
||||
public function getTextOfSignerStatus(int $status): string {
|
||||
return SignRequestStatus::from($status)->getLabel($this->l10n);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,21 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Libresign\Enum;
|
||||
|
||||
use OCP\IL10N;
|
||||
|
||||
enum SignRequestStatus: int {
|
||||
case DRAFT = 0;
|
||||
case ABLE_TO_SIGN = 1;
|
||||
case SIGNED = 2;
|
||||
|
||||
public function getLabel(IL10N $l10n): string {
|
||||
return match($this) {
|
||||
// TRANSLATORS Name of the status when signer document is in draft state
|
||||
self::DRAFT => $l10n->t('Draft'),
|
||||
// TRANSLATORS Name of the status when signer can sign the document
|
||||
self::ABLE_TO_SIGN => $l10n->t('Pending'),
|
||||
// TRANSLATORS Name of the status when signer has already signed
|
||||
self::SIGNED => $l10n->t('Signed'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ namespace OCA\Libresign;
|
|||
* hash_algorithm?: string,
|
||||
* me: bool,
|
||||
* signRequestId: non-negative-int,
|
||||
* status: 0|1|2,
|
||||
* statusText: string,
|
||||
* signingOrder?: non-negative-int,
|
||||
* identifyMethods?: LibresignIdentifyMethod[],
|
||||
* visibleElements?: LibresignVisibleElement[],
|
||||
|
|
|
|||
|
|
@ -387,6 +387,8 @@ class FileService {
|
|||
$this->fileData->signers[$index]['me'] = false;
|
||||
$this->fileData->signers[$index]['signRequestId'] = $signer->getId();
|
||||
$this->fileData->signers[$index]['description'] = $signer->getDescription();
|
||||
$this->fileData->signers[$index]['status'] = $signer->getStatus();
|
||||
$this->fileData->signers[$index]['statusText'] = $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus());
|
||||
$this->fileData->signers[$index]['signingOrder'] = $signer->getSigningOrder();
|
||||
$this->fileData->signers[$index]['visibleElements'] = $this->getVisibleElements($signer->getId());
|
||||
$this->fileData->signers[$index]['request_sign_date'] = $signer->getCreatedAt()->format(DateTimeInterface::ATOM);
|
||||
|
|
@ -487,6 +489,9 @@ class FileService {
|
|||
private function loadSignersFromCertData(): void {
|
||||
$this->loadCertDataFromLibreSignFile();
|
||||
foreach ($this->certData as $index => $signer) {
|
||||
$this->fileData->signers[$index]['status'] = 2;
|
||||
$this->fileData->signers[$index]['statusText'] = $this->signRequestMapper->getTextOfSignerStatus(2);
|
||||
|
||||
if (isset($signer['timestamp'])) {
|
||||
$this->fileData->signers[$index]['timestamp'] = $signer['timestamp'];
|
||||
if (isset($signer['timestamp']['genTime']) && $signer['timestamp']['genTime'] instanceof DateTimeInterface) {
|
||||
|
|
@ -836,6 +841,7 @@ class FileService {
|
|||
'signRequestId' => $signer->getId(),
|
||||
'signingOrder' => $signer->getSigningOrder(),
|
||||
'status' => $signer->getStatus(),
|
||||
'statusText' => $this->signRequestMapper->getTextOfSignerStatus($signer->getStatus()),
|
||||
'me' => array_reduce($identifyMethodsOfSigner, function (bool $carry, IdentifyMethod $identifyMethod) use ($user): bool {
|
||||
if ($identifyMethod->getIdentifierKey() === IdentifyMethodService::IDENTIFY_ACCOUNT) {
|
||||
if ($user->getUID() === $identifyMethod->getIdentifierValue()) {
|
||||
|
|
|
|||
|
|
@ -852,7 +852,9 @@
|
|||
"request_sign_date",
|
||||
"signed",
|
||||
"me",
|
||||
"signRequestId"
|
||||
"signRequestId",
|
||||
"status",
|
||||
"statusText"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
|
|
@ -918,6 +920,18 @@
|
|||
"format": "int64",
|
||||
"minimum": 0
|
||||
},
|
||||
"status": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
]
|
||||
},
|
||||
"statusText": {
|
||||
"type": "string"
|
||||
},
|
||||
"signingOrder": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
|
|
|
|||
16
openapi.json
16
openapi.json
|
|
@ -702,7 +702,9 @@
|
|||
"request_sign_date",
|
||||
"signed",
|
||||
"me",
|
||||
"signRequestId"
|
||||
"signRequestId",
|
||||
"status",
|
||||
"statusText"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
|
|
@ -768,6 +770,18 @@
|
|||
"format": "int64",
|
||||
"minimum": 0
|
||||
},
|
||||
"status": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
]
|
||||
},
|
||||
"statusText": {
|
||||
"type": "string"
|
||||
},
|
||||
"signingOrder": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
|
|
|
|||
|
|
@ -1716,6 +1716,12 @@ export type components = {
|
|||
me: boolean;
|
||||
/** Format: int64 */
|
||||
signRequestId: number;
|
||||
/**
|
||||
* Format: int64
|
||||
* @enum {integer}
|
||||
*/
|
||||
status: 0 | 1 | 2;
|
||||
statusText: string;
|
||||
/** Format: int64 */
|
||||
signingOrder?: number;
|
||||
identifyMethods?: components["schemas"]["IdentifyMethod"][];
|
||||
|
|
|
|||
|
|
@ -1238,6 +1238,12 @@ export type components = {
|
|||
me: boolean;
|
||||
/** Format: int64 */
|
||||
signRequestId: number;
|
||||
/**
|
||||
* Format: int64
|
||||
* @enum {integer}
|
||||
*/
|
||||
status: 0 | 1 | 2;
|
||||
statusText: string;
|
||||
/** Format: int64 */
|
||||
signingOrder?: number;
|
||||
identifyMethods?: components["schemas"]["IdentifyMethod"][];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue