Skip to content

Commit

Permalink
feat: implement filter at file list
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos committed Apr 8, 2024
1 parent 845db20 commit 0387549
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 @@ -351,9 +351,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 @@ -450,6 +451,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 0387549

Please sign in to comment.