Skip to content

Commit

Permalink
Merge pull request #2686 from LibreSign/backport/2680/stable29
Browse files Browse the repository at this point in the history
[stable29] feat: implement filter at file list
  • Loading branch information
vitormattos authored Apr 8, 2024
2 parents e1ade7a + 83c0f08 commit ee1e2fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/Controller/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ public function validate(?string $type = null, $identifier = null): JSONResponse

#[NoAdminRequired]
#[NoCSRFRequired]
public function list($page = null, $length = null): JSONResponse {
public function list($page = null, $length = null, ?array $filter = []): JSONResponse {
$return = $this->fileService
->setMe($this->userSession->getUser())
->listAssociatedFilesOfSignFlow($page, $length);
->listAssociatedFilesOfSignFlow($page, $length, $filter);
return new JSONResponse($return, Http::STATUS_OK);
}

Expand Down
10 changes: 8 additions & 2 deletions lib/Db/SignRequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@ public function getByFileIdAndSignRequestId(int $fileId, int $signRequestId): Si
public function getFilesAssociatedFilesWithMeFormatted(
IUser $user,
int $page = null,
int $length = null
int $length = null,
array $filter,
): array {
$pagination = $this->getFilesAssociatedFilesWithMeStmt($user->getUID(), $user->getEMailAddress());
$pagination = $this->getFilesAssociatedFilesWithMeStmt($user->getUID(), $user->getEMailAddress(), $filter);
$pagination->setMaxPerPage($length);
$pagination->setCurrentPage($page);
$currentPageResults = $pagination->getCurrentPageResults();
Expand Down Expand Up @@ -488,6 +489,11 @@ private function getFilesAssociatedFilesWithMeQueryBuilder(string $userId, ?stri
}
$qb->where($qb->expr()->orX(...$or));
if ($filter) {
if (isset($filter['signer_uuid'])) {
$qb->andWhere(
$qb->expr()->eq('sr.uuid', $qb->createNamedParameter($filter['signer_uuid']))
);
}
if (isset($filter['nodeId'])) {
$qb->andWhere(
$qb->expr()->eq('f.node_id', $qb->createNamedParameter($filter['nodeId'], IQueryBuilder::PARAM_INT))
Expand Down

0 comments on commit ee1e2fd

Please sign in to comment.