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 <vitor@php.rio>
  • Loading branch information
vitormattos committed Apr 8, 2024
1 parent d907eab commit 83c0f08
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 83c0f08

Please sign in to comment.