From d8fd8cfa2bd2faf91933d34843c31fd4da632c84 Mon Sep 17 00:00:00 2001 From: Jerome_maarch Date: Tue, 4 Aug 2020 09:57:34 +0200 Subject: [PATCH 1/6] fix/14312 : add count and max Results --- .../Controller/archiveAccessTrait.php | 276 ++++++++++++++---- .../Controller/description.php | 52 +++- .../recordsManagement/Controller/log.php | 29 +- .../recordsManagement/archivesInterface.php | 116 ++++++-- .../Presenter/recordsManagement/archive.php | 20 +- .../Presenter/recordsManagement/welcome.php | 13 +- .../maarchRM/Resources/locale/fr/messages.po | 5 +- .../view/dashboard/mainScreen/folder.html | 10 +- .../archive/fulltextSearchForm.html | 6 +- .../recordsManagement/archive/resultList.html | 15 +- .../recordsManagement/archive/search.html | 8 +- .../maarchRM/UserStory/app/appInterface.php | 5 +- .../archiveManagement/retrieveInterface.php | 29 +- web/public/js/dataList_0.0.1/dataList.js | 37 ++- 14 files changed, 485 insertions(+), 136 deletions(-) diff --git a/src/bundle/recordsManagement/Controller/archiveAccessTrait.php b/src/bundle/recordsManagement/Controller/archiveAccessTrait.php index 32e30a906..1f7dd6ac7 100755 --- a/src/bundle/recordsManagement/Controller/archiveAccessTrait.php +++ b/src/bundle/recordsManagement/Controller/archiveAccessTrait.php @@ -29,30 +29,32 @@ trait archiveAccessTrait { /** * Search archives by profile / dates / agreement - * @param string $archiveId - * @param string $profileReference - * @param string $status - * @param string $archiveName - * @param string $agreementReference - * @param string $archiveExpired - * @param string $finalDisposition - * @param string $originatorOrgRegNumber - * @param string $originatorOwnerOrgId - * @param string $originatorArchiveId - * @param array $originatingDate - * @param string $filePlanPosition - * @param bool $hasParent - * @param string $description - * @param string $text - * @param bool $partialRetentionRule - * @param string $retentionRuleCode - * @param string $depositStartDate - * @param string $depositEndDate - * @param string $originatingStartDate - * @param string $originatingEndDate - * @param string $archiverArchiveId - * @param string $processingStatus - * @param bool $checkAccess + * + * @param string $archiveId + * @param string $profileReference + * @param string $status + * @param string $archiveName + * @param string $agreementReference + * @param string $archiveExpired + * @param string $finalDisposition + * @param string $originatorOrgRegNumber + * @param string $originatorOwnerOrgId + * @param string $originatorArchiveId + * @param array $originatingDate + * @param string $filePlanPosition + * @param bool $hasParent + * @param string $description + * @param string $text + * @param bool $partialRetentionRule + * @param string $retentionRuleCode + * @param string $depositStartDate + * @param string $depositEndDate + * @param string $originatingStartDate + * @param string $originatingEndDate + * @param string $archiverArchiveId + * @param string $processingStatus + * @param bool $checkAccess + * @param integer $maxResults * * @return recordsManagement/archive[] Array of recordsManagement/archive object */ @@ -80,13 +82,163 @@ trait archiveAccessTrait $originatingEndDate = null, $archiverArchiveId = null, $processingStatus = null, - $checkAccess = true + $checkAccess = true, + $maxResults = null ) { $accountController = \laabs::newController('auth/userAccount'); $accountController->isAuthorized('user'); $archives = []; + list($searchClasses, $archiveArgs) = $this->getClassesAndArchiveArgsForSearch( + $archiveId, + $profileReference, + $status, + $archiveName, + $agreementReference, + $archiveExpired, + $finalDisposition, + $originatorOrgRegNumber, + $originatorOwnerOrgId, + $originatorArchiveId, + $originatingDate, + $filePlanPosition, + $hasParent, + $partialRetentionRule, + $retentionRuleCode, + $depositStartDate, + $depositEndDate, + $originatingStartDate, + $originatingEndDate, + $archiverArchiveId, + $processingStatus + ); + + foreach ($searchClasses as $descriptionClass => $descriptionController) { + $archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs, $checkAccess, $maxResults)); + } + + return $archives; + } + + /** + * Count archives by profile / dates / agreement + * + * @param string $archiveId + * @param string $profileReference + * @param string $status + * @param string $archiveName + * @param string $agreementReference + * @param string $archiveExpired + * @param string $finalDisposition + * @param string $originatorOrgRegNumber + * @param string $originatorOwnerOrgId + * @param string $originatorArchiveId + * @param array $originatingDate + * @param string $filePlanPosition + * @param bool $hasParent + * @param string $description + * @param string $text + * @param bool $partialRetentionRule + * @param string $retentionRuleCode + * @param string $depositStartDate + * @param string $depositEndDate + * @param string $originatingStartDate + * @param string $originatingEndDate + * @param string $archiverArchiveId + * @param string $processingStatus + * @param bool $checkAccess + * @param integer $maxResults + * + * @return integer $count Count of archives from search + */ + public function count( + $archiveId = null, + $profileReference = null, + $status = null, + $archiveName = null, + $agreementReference = null, + $archiveExpired = null, + $finalDisposition = null, + $originatorOrgRegNumber = null, + $originatorOwnerOrgId = null, + $originatorArchiveId = null, + $originatingDate = null, + $filePlanPosition = null, + $hasParent = null, + $description = null, + $text = null, + $partialRetentionRule = null, + $retentionRuleCode = null, + $depositStartDate = null, + $depositEndDate = null, + $originatingStartDate = null, + $originatingEndDate = null, + $archiverArchiveId = null, + $processingStatus = null, + $checkAccess = true, + $maxResults = null + ) { + $accountController = \laabs::newController('auth/userAccount'); + $accountController->isAuthorized('user'); + + $archives = []; + + list($searchClasses, $archiveArgs) = $this->getClassesAndArchiveArgsForSearch( + $archiveId, + $profileReference, + $status, + $archiveName, + $agreementReference, + $archiveExpired, + $finalDisposition, + $originatorOrgRegNumber, + $originatorOwnerOrgId, + $originatorArchiveId, + $originatingDate, + $filePlanPosition, + $hasParent, + $partialRetentionRule, + $retentionRuleCode, + $depositStartDate, + $depositEndDate, + $originatingStartDate, + $originatingEndDate, + $archiverArchiveId, + $processingStatus + ); + + $count = 0; + foreach ($searchClasses as $descriptionClass => $descriptionController) { + $count += $descriptionController->count($description, $text, $archiveArgs, $checkAccess, $maxResults); + } + + return $count; + } + + protected function getClassesAndArchiveArgsForSearch( + $archiveId = null, + $profileReference = null, + $status = null, + $archiveName = null, + $agreementReference = null, + $archiveExpired = null, + $finalDisposition = null, + $originatorOrgRegNumber = null, + $originatorOwnerOrgId = null, + $originatorArchiveId = null, + $originatingDate = null, + $filePlanPosition = null, + $hasParent = null, + $partialRetentionRule = null, + $retentionRuleCode = null, + $depositStartDate = null, + $depositEndDate = null, + $originatingStartDate = null, + $originatingEndDate = null, + $archiverArchiveId = null, + $processingStatus = null + ) { $archiveArgs = [ 'archiveId' => $archiveId, 'profileReference' => $profileReference, @@ -121,7 +273,7 @@ trait archiveAccessTrait $descriptionSchemeController = \laabs::newController('recordsManagement/descriptionScheme'); foreach ($descriptionSchemeController->index() as $name => $descriptionScheme) { - if (isset($descriptionScheme->search) && !empty($descriptionScheme->search)) { + if (isset($descriptionScheme->search)) { $searchClasses[$name] = $this->useDescriptionController($descriptionScheme->search); } } @@ -133,11 +285,8 @@ trait archiveAccessTrait $searchClasses['recordsManagement/description'] = $this->useDescriptionController('recordsManagement/description'); } } - foreach ($searchClasses as $descriptionClass => $descriptionController) { - $archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs, $checkAccess)); - } - return $archives; + return [$searchClasses, $archiveArgs]; } /** @@ -273,8 +422,8 @@ trait archiveAccessTrait } if ($partialRetentionRule) { - $queryParts['partialRetentionRule'] = "(retentionDuration=NULL - OR retentionStartDate=NULL + $queryParts['partialRetentionRule'] = "(retentionDuration=NULL + OR retentionStartDate=NULL OR retentionRuleCode=NULL)"; } @@ -319,8 +468,31 @@ trait archiveAccessTrait */ public function index($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false) { - $queryParts = array(); - $queryParams = array(); + list($queryString, $queryParams) = $this->getQueryStringAndParams($originatorOrgRegNumber, $filePlanPosition, $archiveUnit); + + $maxResults = \laabs::configuration('presentation.maarchRM')['maxResults']; + $archives = $this->sdoFactory->find( + 'recordsManagement/archive', + $queryString, + $queryParams, + false, + false, + $maxResults + ); + + foreach ($archives as $archive) { + if (!empty($archive->disposalDate) && $archive->disposalDate <= \laabs::newDate()) { + $archive->disposable = true; + } + } + + return $archives; + } + + protected function getQueryStringAndParams($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false) + { + $queryParts = []; + $queryParams = []; $currentDate = \laabs::newDate(); $currentDateString = $currentDate->format('Y-m-d'); @@ -353,31 +525,33 @@ trait archiveAccessTrait if ($accessRuleAssert) { $queryParts[] = $accessRuleAssert; } - + $queryString = \laabs\implode(' AND ', $queryParts); - $maxResults = \laabs::configuration('presentation.maarchRM')['maxResults']; - $archives = $this->sdoFactory->find( - 'recordsManagement/archive', - $queryString, - $queryParams, - false, - false, - $maxResults - ); - foreach ($archives as $archive) { - if (!empty($archive->disposalDate) && $archive->disposalDate <= \laabs::newDate()) { - $archive->disposable = true; - } - } + return [$queryString, $queryParams]; + } - return $archives; + /** + * Get archives count + * + * @param string $originatorOrgRegNumber The organization registration number + * @param string $filePlanPosition The file plan position + * @param boolean $archiveUnit List the archive unit + * + * @return integer $count + */ + public function countList($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false) + { + list($queryString, $queryParams) = $this->getQueryStringAndParams($originatorOrgRegNumber, $filePlanPosition, $archiveUnit); + $count = $this->sdoFactory->count('recordsManagement/archive', $queryString, $queryParams); + + return $count; } /** * Get archive metadata * @param string $archiveId The archive identifier - * + * * @return recordsManagement/archive The archive metadata */ public function getMetadata($archiveId, $checkAccess = true) diff --git a/src/bundle/recordsManagement/Controller/description.php b/src/bundle/recordsManagement/Controller/description.php index 3b5913eb0..6b40769f6 100755 --- a/src/bundle/recordsManagement/Controller/description.php +++ b/src/bundle/recordsManagement/Controller/description.php @@ -130,11 +130,31 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip * @param string $text The search args on text * @param array $archiveArgs The search args on archive std properties * @param bool $checkAccess Use access control. If not, called MUST control access before or after retrieving data + * @param integer $maxResults Max results to display * * @return array The result of the research */ - public function search($description = null, $text = null, array $archiveArgs = [], $checkAccess = true) + public function search($description = null, $text = null, array $archiveArgs = [], $checkAccess = true, $maxResults = null) { + list($queryString, $queryParams) = $this->getQueryStringAndParams($description, $text, $archiveArgs, $checkAccess); + + $archiveUnits = $this->sdoFactory->find('recordsManagement/archiveUnit', $queryString, $queryParams, false, false, $maxResults); + + foreach ($archiveUnits as $archiveUnit) { + if (!empty($archiveUnit->description)) { + $archiveUnit->descriptionObject = json_decode($archiveUnit->description); + } + } + + return $archiveUnits; + } + + protected function getQueryStringAndParams( + $description = null, + $text = null, + array $archiveArgs = [], + $checkAccess = true + ) { $queryParams = []; $queryParts = ['(description!=null and text!=null)']; @@ -191,7 +211,7 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip // If at least one TS token, add search expression if (!empty($tsQueryTokens)) { $tsVectorExpression = "to_tsvector('french'::regconfig, ".$textPropertyExpr.")"; - $textQueryParts[] = $tsVectorExpression." @@ plainto_tsquery('".implode (' ', $tsQueryTokens)."')"; + $textQueryParts[] = $tsVectorExpression." @@ plainto_tsquery('". implode(' ', $tsQueryTokens)."')"; } if (!empty($textQueryParts)) { @@ -203,22 +223,34 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip $queryString = \laabs\implode(' and ', $queryParts); - $archiveUnits = $this->sdoFactory->find('recordsManagement/archiveUnit', $queryString, $queryParams); + return [$queryString, $queryParams]; + } - foreach ($archiveUnits as $archiveUnit) { - if (!empty($archiveUnit->description)) { - $archiveUnit->descriptionObject = json_decode($archiveUnit->description); - } - } + /** + * Count the description objects + * + * @param string $description The search args on description object + * @param string $text The search args on text + * @param array $archiveArgs The search args on archive std properties + * @param bool $checkAccess Use access control. If not, called MUST control access before or after retrieving data + * + * @return integer $count Research count + */ + public function count($description = null, $text = null, array $archiveArgs = [], $checkAccess = true) + { + list($queryString, $queryParams) = $this->getQueryStringAndParams($description, $text, $archiveArgs, $checkAccess); - return $archiveUnits; + $count = $this->sdoFactory->count('recordsManagement/archiveUnit', $queryString, $queryParams); + + return $count; } + /** * Update the description * @param mixed $description The description object * @param string $archiveId The archive identifier - * + * * @return bool The result of the operation */ public function update($archive) diff --git a/src/bundle/recordsManagement/Controller/log.php b/src/bundle/recordsManagement/Controller/log.php index e580e25c5..ae4ac2c37 100755 --- a/src/bundle/recordsManagement/Controller/log.php +++ b/src/bundle/recordsManagement/Controller/log.php @@ -131,13 +131,16 @@ class log implements archiveDescriptionInterface /** * Search the description objects - * @param string $description The search args on description object - * @param string $text The search args on text - * @param array $args The search args on archive std properties + * + * @param string $description The search args on description object + * @param string $text The search args on text + * @param array $args The search args on archive std properties + * @param bool $checkAccess Use access control. If not, called MUST control access before or after retrieving data + * @param integer $maxResults Max results to display * * @return object Array of description objects */ - public function search($description = null, $text = null, array $args = []) + public function search($description = null, $text = null, array $args = [], $checkAccess = null, $maxResults = null) { $queryParams = $queryParts = []; $queryString = ""; @@ -172,8 +175,8 @@ class log implements archiveDescriptionInterface $archives = []; $sortBy = ">fromDate"; - $numberOfResult = \laabs::configuration('presentation.maarchRM')['maxResults']; - $logs = $this->sdoFactory->find("recordsManagement/log", $queryString, [], $sortBy, 0, $numberOfResult); + + $logs = $this->sdoFactory->find("recordsManagement/log", $queryString, [], $sortBy, 0, $maxResults); foreach ($logs as $log) { try { @@ -187,6 +190,20 @@ class log implements archiveDescriptionInterface return $archives; } + /** + * Count log objects + * @param string $description The search args on description object + * @param string $text The search args on text + * @param array $args The search args on archive std properties + * + * @return object Array of description objects + */ + public function count($description = null, $text = null, array $args = [], $checkAccess = null, $maxResults = null) + { + return count($this->search($description, $text, $args, $checkAccess, $maxResults = null)); + } + + /** * Retrieve a journal by evenement date * @param string $type The journal type diff --git a/src/bundle/recordsManagement/archivesInterface.php b/src/bundle/recordsManagement/archivesInterface.php index 88c4c235a..7b1e02976 100755 --- a/src/bundle/recordsManagement/archivesInterface.php +++ b/src/bundle/recordsManagement/archivesInterface.php @@ -32,28 +32,30 @@ interface archivesInterface */ /** * Search archives by profile / dates / agreement - * @param string $archiveId - * @param string $profileReference - * @param string $status - * @param string $archiveName - * @param string $agreementReference - * @param string $archiveExpired - * @param string $finalDisposition - * @param string $originatorOrgRegNumber - * @param string $originatorOwnerOrgId - * @param string $originatorArchiveId - * @param array $originatingDate - * @param string $filePlanPosition - * @param bool $hasParent - * @param string $description - * @param string $text - * @param bool $partialRetentionRule - * @param string $retentionRuleCode - * @param string $depositStartDate - * @param string $depositEndDate - * @param string $originatingStartDate - * @param string $originatingEndDate - * @param string $archiverArchiveId + * + * @param string $archiveId + * @param string $profileReference + * @param string $status + * @param string $archiveName + * @param string $agreementReference + * @param string $archiveExpired + * @param string $finalDisposition + * @param string $originatorOrgRegNumber + * @param string $originatorOwnerOrgId + * @param string $originatorArchiveId + * @param array $originatingDate + * @param string $filePlanPosition + * @param bool $hasParent + * @param string $description + * @param string $text + * @param bool $partialRetentionRule + * @param string $retentionRuleCode + * @param string $depositStartDate + * @param string $depositEndDate + * @param string $originatingStartDate + * @param string $originatingEndDate + * @param string $archiverArchiveId + * @param integer $maxResults * * @action recordsManagement/archive/search * @@ -80,7 +82,64 @@ interface archivesInterface $depositEndDate = null, $originatingStartDate = null, $originatingEndDate = null, - $archiverArchiveId = null + $archiverArchiveId = null, + $maxResults = null + ); + + /** + * Count archives by profile / dates / agreement + * + * @param string $archiveId + * @param string $profileReference + * @param string $status + * @param string $archiveName + * @param string $agreementReference + * @param string $archiveExpired + * @param string $finalDisposition + * @param string $originatorOrgRegNumber + * @param string $originatorOwnerOrgId + * @param string $originatorArchiveId + * @param array $originatingDate + * @param string $filePlanPosition + * @param bool $hasParent + * @param string $description + * @param string $text + * @param bool $partialRetentionRule + * @param string $retentionRuleCode + * @param string $depositStartDate + * @param string $depositEndDate + * @param string $originatingStartDate + * @param string $originatingEndDate + * @param string $archiverArchiveId + * @param integer $maxResults + * + * @action recordsManagement/archive/count + * + */ + public function readCount( + $archiveId = null, + $profileReference = null, + $status = null, + $archiveName = null, + $agreementReference = null, + $archiveExpired = null, + $finalDisposition = null, + $originatorOrgRegNumber = null, + $originatorOwnerOrgId = null, + $originatorArchiveId = null, + $originatingDate = null, + $filePlanPosition = null, + $hasParent = null, + $description = null, + $text = null, + $partialRetentionRule = null, + $retentionRuleCode = null, + $depositStartDate = null, + $depositEndDate = null, + $originatingStartDate = null, + $originatingEndDate = null, + $archiverArchiveId = null, + $maxResults = null ); /** @@ -144,6 +203,17 @@ interface archivesInterface */ public function readList($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false); + /** + * Get archives Count without limit + * + * @param string $originatorOrgRegNumber The organization registration number + * @param string $filePlanPosition The file plan position + * @param boolean $archiveUnit List the archive unit + * + * @action recordsManagement/archive/countList + */ + public function readCountList($originatorOrgRegNumber, $filePlanPosition = null, $archiveUnit = false); + /* MODIFY ARCHIVES */ diff --git a/src/presentation/maarchRM/Presenter/recordsManagement/archive.php b/src/presentation/maarchRM/Presenter/recordsManagement/archive.php index a8e646ef1..39238d48c 100755 --- a/src/presentation/maarchRM/Presenter/recordsManagement/archive.php +++ b/src/presentation/maarchRM/Presenter/recordsManagement/archive.php @@ -94,6 +94,12 @@ class archive $deleteDescription = (bool) \laabs::configuration("recordsManagement")['deleteDescription']; } + $maxResults = null; + if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])) { + $maxResults = \laabs::configuration('presentation.maarchRM')['maxResults']; + } + + $this->view->setSource("maxResults", $maxResults); $this->view->setSource("retentionRules", $retentionRules); $this->view->setSource("emptyRole", $emptyRole); $this->view->setSource("profiles", $profiles); @@ -112,11 +118,12 @@ class archive /** * get archives with information - * @param array $archives Array of archive object + * @param array $archives Array of archive object + * @param integer $count Count of archive object without limit * * @return string */ - public function search($archives) + public function search($archives, $count) { $this->view->addContentFile("recordsManagement/archive/resultList.html"); @@ -198,6 +205,12 @@ class archive } } + $hasReachMaxResults = false; + if (isset(\laabs::configuration('presentation.maarchRM')['maxResults']) + && count($archives) >= \laabs::configuration('presentation.maarchRM')['maxResults']) { + $hasReachMaxResults = true; + } + $dataTable = $this->view->getElementsByClass("dataTable")->item(0)->plugin['dataTable']; $dataTable->setPaginationType("full_numbers"); @@ -233,6 +246,9 @@ class archive $this->readPrivilegesOnArchives(); + $this->view->setSource('hasReachMaxResults', $hasReachMaxResults); + $this->view->setSource('maxResults', \laabs::configuration('presentation.maarchRM')['maxResults']); + $this->view->setSource('totalResultsWithoutLimit', $count); $this->view->setSource("accessRules", $accessRules); $this->view->setSource("retentionRules", $retentionRules); $this->view->setSource('archive', $archives); diff --git a/src/presentation/maarchRM/Presenter/recordsManagement/welcome.php b/src/presentation/maarchRM/Presenter/recordsManagement/welcome.php index 1afb9d383..157a13ecf 100755 --- a/src/presentation/maarchRM/Presenter/recordsManagement/welcome.php +++ b/src/presentation/maarchRM/Presenter/recordsManagement/welcome.php @@ -112,11 +112,17 @@ class welcome $depositPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveDeposit/deposit"); + $maxResults = null; + if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])) { + $maxResults = \laabs::configuration('presentation.maarchRM')['maxResults']; + } + $this->view->setSource("userArchivalProfiles", $this->userArchivalProfiles); $this->view->setSource("depositPrivilege", $depositPrivilege); $this->view->setSource("syncImportPrivilege", $syncImportPrivilege); $this->view->setSource("asyncImportPrivilege", $asyncImportPrivilege); $this->view->setSource("filePlanPrivileges", $filePlanPrivileges); + $this->view->setSource("maxResults", $maxResults); $this->view->setSource('retentionRules', $retentionRules); $this->view->setSource('user', $user); @@ -184,11 +190,13 @@ class welcome /** * Show a folder content - * @param array $archives + * + * @param array $archives + * @param integer $count Archives count without limit * * @return string */ - public function folderContents($archives) + public function folderContents($archives, $count) { $organizations = \laabs::callService('organization/organization/readIndex'); $orgsName = []; @@ -212,6 +220,7 @@ class welcome } $this->json->archives = $archives; + $this->json->countWithoutLimit = $count; return $this->json->save(); } diff --git a/src/presentation/maarchRM/Resources/locale/fr/messages.po b/src/presentation/maarchRM/Resources/locale/fr/messages.po index d8a4627c5..e07d55ea5 100755 --- a/src/presentation/maarchRM/Resources/locale/fr/messages.po +++ b/src/presentation/maarchRM/Resources/locale/fr/messages.po @@ -612,4 +612,7 @@ msgid "Resource size is null" msgstr "La taille de la ressource est nulle" msgid "Attempt to access without a valid token" -msgstr "Une erreur est survenue. Si le problème persiste, veuillez recharger la page." \ No newline at end of file +msgstr "Une erreur est survenue. Si le problème persiste, veuillez recharger la page." + +msgid "Your query returns too much results, only first results are displayed." +msgstr "Le nombre de résultats retournés est trop important. Veuillez affiner votre recherche." diff --git a/src/presentation/maarchRM/Resources/view/dashboard/mainScreen/folder.html b/src/presentation/maarchRM/Resources/view/dashboard/mainScreen/folder.html index 9cddb6b82..f33e65cca 100755 --- a/src/presentation/maarchRM/Resources/view/dashboard/mainScreen/folder.html +++ b/src/presentation/maarchRM/Resources/view/dashboard/mainScreen/folder.html @@ -9,7 +9,7 @@
-
+

@@ -196,6 +196,7 @@ folderId : null, pathList : [], showArchivePath: false, + totalArchives: null, getfolderContents: function(orgRegNumber, folderId, archivalProfiles, disabled, locked, acceptArchivesWithoutProfiles, pathList) { this.orgRegNumber = orgRegNumber; @@ -230,7 +231,7 @@ type : "GET", dataType : 'json', success : function (response) { - ArchiveFolderList.buildResultList(response.archives); + ArchiveFolderList.buildResultList(response.archives, null, false, response.countWithoutLimit); if (locked || disabled) { ArchiveFolderList.folderPanel.find('.addChildrenArchive').remove(); } @@ -259,7 +260,7 @@ $("#folderToolbarSearch").data("orgregnumber", orgRegNumber).data("folderid", folderId); }, - buildResultList: function(archives, options, showArchivePath) { + buildResultList: function(archives, options, showArchivePath, totalResult) { // to inititate default value and avoid bug on IE 11 if (options === undefined) { options = null; @@ -285,8 +286,9 @@ defaultOptions = { datas: archives, + total: totalResult, rowMerge: ArchiveFolderList.mergeRow, - rowMaxNumber: 10, + rowMaxNumber: ($('#fullTextSearchForm').find('[name=maxResults]').val() != 'undefined' ? parseInt($('#fullTextSearchForm').find('[name=maxResults]').val(), 10) : 10), rowTranslation: $('#rows_text').text(), emptyMessage: ' <\/span>' + $('#emptyFolder_text').html() + '<\/i>', itemsName: [$('#archive_text').text(), $('#archives_text').text()], diff --git a/src/presentation/maarchRM/Resources/view/recordsManagement/archive/fulltextSearchForm.html b/src/presentation/maarchRM/Resources/view/recordsManagement/archive/fulltextSearchForm.html index e095ebeff..52c040489 100755 --- a/src/presentation/maarchRM/Resources/view/recordsManagement/archive/fulltextSearchForm.html +++ b/src/presentation/maarchRM/Resources/view/recordsManagement/archive/fulltextSearchForm.html @@ -7,6 +7,7 @@ #-->
+
@@ -259,7 +260,8 @@ FulltextSearchForm = { filePlanPosition : this.form.data('folderid'), orgRegNumber : this.form.data('orgregnumber'), originatingStartDate : advancedSearchPanel.find('[name="originatingDateMin"]').data('datepicker').getFormattedDate('yyyy-mm-dd'), - originatingEndDate : advancedSearchPanel.find('[name="originatingDateMax"]').data('datepicker').getFormattedDate('yyyy-mm-dd') + originatingEndDate : advancedSearchPanel.find('[name="originatingDateMax"]').data('datepicker').getFormattedDate('yyyy-mm-dd'), + maxResults : this.form.find('[name="maxResults"]').val() }; var text = this.form.find('[name="searchForm_inputSearch"]').val().trim(); @@ -377,7 +379,7 @@ FulltextSearchForm = { }, clearForm : function() { - $('#fullTextSearchForm > input').val(''); + this.form.find('input[type=search], input[type=text], input[type=number], input[type=date], select').val(''); this.advancedSearchForm.find('input[type=text], input[type=number], input[type=date], select').val(''); } } diff --git a/src/presentation/maarchRM/Resources/view/recordsManagement/archive/resultList.html b/src/presentation/maarchRM/Resources/view/recordsManagement/archive/resultList.html index 7a7230ca0..2537aaf36 100755 --- a/src/presentation/maarchRM/Resources/view/recordsManagement/archive/resultList.html +++ b/src/presentation/maarchRM/Resources/view/recordsManagement/archive/resultList.html @@ -1,9 +1,14 @@
+ +

Your query returns too much results, only first results are displayed.

-

result(s)

+ +

archive(s)

+ +

archive(s) on result(s)

+
@@ -84,8 +85,8 @@
-
-
+
+
@@ -96,7 +97,7 @@ - +
\ No newline at end of file + diff --git a/src/presentation/maarchRM/Resources/view/audit/search.html b/src/presentation/maarchRM/Resources/view/audit/search.html index aa0f2ee24..6a54d707e 100755 --- a/src/presentation/maarchRM/Resources/view/audit/search.html +++ b/src/presentation/maarchRM/Resources/view/audit/search.html @@ -18,6 +18,7 @@
+
@@ -128,8 +129,9 @@ event: $('#eventName').data('event-path'), accountId: $.trim($('#accountTypeahead').val()), term: $('#term').val(), + maxResults: $('#maxResults').val() }; - + if ($('#accountTypeahead').data('accountid')) { serializedObject.accountId = $('#accountTypeahead').data('accountid') ; } diff --git a/src/presentation/maarchRM/UserStory/journal/auditInterface.php b/src/presentation/maarchRM/UserStory/journal/auditInterface.php index dc4e4dcd4..2fcce47f1 100755 --- a/src/presentation/maarchRM/UserStory/journal/auditInterface.php +++ b/src/presentation/maarchRM/UserStory/journal/auditInterface.php @@ -34,19 +34,22 @@ interface auditInterface /** * Get search form for entries - *@param string $eventType Type of event - *@param Date $fromDate Start date - *@param Date $toDate End date - *@param string $accountId Id of account - *@param string $event Variables - *@param string $term Term to search - *@param string $wording Wording to search + * + * @param Date $fromDate Start date + * @param Date $toDate End date + * @param string $accountId Id of account + * @param string $event Variables + * @param string $status + * @param string $term Term to search + * @param integer $maxResults Max number of results to return * * * @uses audit/event/readSearch + * @uses audit/event/readCount + * * @return audit/event/search */ - public function readEvents($eventType = null, $fromDate = null, $toDate = null, $accountId = null, $event = null, $status = null, $term = null, $wording = null); + public function readEvents($fromDate = null, $toDate = null, $accountId = null, $event = null, $status = null, $term = null, $maxResults = null); /** * Get event @@ -56,11 +59,11 @@ interface auditInterface */ public function readEvent_eventId_(); - /** * List all users to display * * @uses auth/userAccount/readUserlist */ public function readUserTodisplay(); + } -- GitLab From 02007f47adbca7fa54e304607f8b836492f8177f Mon Sep 17 00:00:00 2001 From: Jerome_maarch Date: Wed, 5 Aug 2020 17:56:17 +0200 Subject: [PATCH 5/6] fix/14312 : add count on log search page --- .../recordsManagement/Controller/log.php | 94 ++++++++++++++----- src/bundle/recordsManagement/logInterface.php | 42 +++++++-- .../Presenter/recordsManagement/log.php | 22 ++++- .../locale/fr/recordsManagement/log.po | 2 + .../view/recordsManagement/log/result.html | 5 +- .../recordsManagement/log/searchForm.html | 8 +- .../journal/searchLogArchiveInterface.php | 4 +- 7 files changed, 138 insertions(+), 39 deletions(-) diff --git a/src/bundle/recordsManagement/Controller/log.php b/src/bundle/recordsManagement/Controller/log.php index ae4ac2c37..a75ef70d6 100755 --- a/src/bundle/recordsManagement/Controller/log.php +++ b/src/bundle/recordsManagement/Controller/log.php @@ -53,14 +53,15 @@ class log implements archiveDescriptionInterface /** * Get a search result - * @param string $archiveId The archive identifier - * @param string $type The type - * @param date $fromDate The date - * @param date $toDate The date - * @param string $processName The process name - * @param string $processId The process identifier - * @param string $sortBy The process identifier - * @param int $numberOfResult The process identifier + * + * @param string $archiveId The archive identifier + * @param string $type The type + * @param date $fromDate The date + * @param date $toDate The date + * @param string $processName The process name + * @param string $processId The process identifier + * @param string $sortBy The process identifier + * @param integer $maxResults The process identifier * * @return array Array of logs */ @@ -72,12 +73,44 @@ class log implements archiveDescriptionInterface $processName = null, $processId = null, $sortBy = ">fromDate", - $numberOfResult = null + $maxResults = null ) { - $queryParts = array(); - $queryParams = array(); + list($queryParams, $queryString) = $this->queryBuilder($archiveId, $type, $fromDate, $toDate, $processName, $processId); - //$queryParts[] = $this->auth->getUserAccessRule('recordsManagement/log'); + $logs = $this->sdoFactory->find( + "recordsManagement/log", + $queryString, + $queryParams, + $sortBy, + 0, + $maxResults + ); + + return $logs; + } + + /** + * Create query for search + * + * @param string $archiveId The archive identifier + * @param string $type The type + * @param date $fromDate The date + * @param date $toDate The date + * @param string $processName The process name + * @param string $processId The process identifier + * + * @return + */ + protected function queryBuilder( + $archiveId = null, + $type = null, + $fromDate = null, + $toDate = null, + $processName = null, + $processId = null + ) { + $queryParts = []; + $queryParams = []; if ($archiveId) { $queryParams['archiveId'] = $archiveId; @@ -113,20 +146,38 @@ class log implements archiveDescriptionInterface $queryString = implode(' AND ', $queryParts); - if (!$numberOfResult) { - $numberOfResult = \laabs::configuration('presentation.maarchRM')['maxResults']; - } + return [$queryParams, $queryString]; + } - $logs = $this->sdoFactory->find( + /** + * Count search results + * + * @param string $archiveId The archive identifier + * @param string $type The type + * @param date $fromDate The date + * @param date $toDate The date + * @param string $processName The process name + * @param string $processId The process identifier + * + * @return integer + */ + public function countFind( + $archiveId = null, + $type = null, + $fromDate = null, + $toDate = null, + $processName = null, + $processId = null + ) { + list($queryParams, $queryString) = $this->queryBuilder($archiveId, $type, $fromDate, $toDate, $processName, $processId); + + $count = $this->sdoFactory->count( "recordsManagement/log", $queryString, - $queryParams, - $sortBy, - 0, - $numberOfResult + $queryParams ); - return $logs; + return $count; } /** @@ -203,7 +254,6 @@ class log implements archiveDescriptionInterface return count($this->search($description, $text, $args, $checkAccess, $maxResults = null)); } - /** * Retrieve a journal by evenement date * @param string $type The journal type diff --git a/src/bundle/recordsManagement/logInterface.php b/src/bundle/recordsManagement/logInterface.php index d3636dba3..8e598104e 100755 --- a/src/bundle/recordsManagement/logInterface.php +++ b/src/bundle/recordsManagement/logInterface.php @@ -25,15 +25,16 @@ interface logInterface { /** * Get a search result - * @param string $archiveId The archive identifier - * @param string $type The type - * @param date $fromDate The date - * @param date $toDate The date - * @param string $processName The process name - * @param string $processId The process identifier - * @param string $sortBy The process identifier - * @param int $numberOfResult The process identifier - + * + * @param string $archiveId The archive identifier + * @param string $type The type + * @param date $fromDate The date + * @param date $toDate The date + * @param string $processName The process name + * @param string $processId The process identifier + * @param string $sortBy The process identifier + * @param integer $maxResults Max number of results to return + * * @action recordsManagement/log/find */ public function readFind( @@ -44,7 +45,28 @@ interface logInterface $processName = null, $processId = null, $sortBy = ">fromDate", - $numberOfResult = null + $maxResults = null + ); + + /** + * Count search results + * + * @param string $archiveId The archive identifier + * @param string $type The type + * @param date $fromDate The date + * @param date $toDate The date + * @param string $processName The process name + * @param string $processId The process identifier + + * @action recordsManagement/log/countFind + */ + public function countFind( + $archiveId = null, + $type = null, + $fromDate = null, + $toDate = null, + $processName = null, + $processId = null ); /** diff --git a/src/presentation/maarchRM/Presenter/recordsManagement/log.php b/src/presentation/maarchRM/Presenter/recordsManagement/log.php index df1e0cfda..97843874b 100755 --- a/src/presentation/maarchRM/Presenter/recordsManagement/log.php +++ b/src/presentation/maarchRM/Presenter/recordsManagement/log.php @@ -54,16 +54,26 @@ class log $this->view->addContentFile('recordsManagement/log/searchForm.html'); $this->view->translate(); + $maxResults = null; + if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])) { + $maxResults = \laabs::configuration('presentation.maarchRM')['maxResults']; + } + $this->view->setSource("maxResults", $maxResults); + $this->view->translate(); + $this->view->merge(); + return $this->view->saveHtml(); } /** * Show result log search - * @param array $logs The arry of object + * + * @param array $logs The arry of object + * @param integer $totalResults Max number of total results from query * * @return string */ - public function find($logs) + public function find($logs, $totalResults) { $this->view->addContentFile('recordsManagement/log/result.html'); $this->view->translate(); @@ -79,6 +89,14 @@ class log $log->resId = \laabs::callService('recordsManagement/archives/readArchivecontents_archive_', (string) $log->archiveId)->digitalResources[0]->resId; } + $hasReachMaxResults = false; + if (isset(\laabs::configuration('presentation.maarchRM')['maxResults']) + && $totalResults >= \laabs::configuration('presentation.maarchRM')['maxResults']) { + $hasReachMaxResults = true; + } + + $this->view->setSource('hasReachMaxResults', $hasReachMaxResults); + $this->view->setSource('totalResults', $totalResults); $this->view->setSource("logs", $logs); $this->view->merge(); diff --git a/src/presentation/maarchRM/Resources/locale/fr/recordsManagement/log.po b/src/presentation/maarchRM/Resources/locale/fr/recordsManagement/log.po index cbb4002a4..79cccbd2b 100755 --- a/src/presentation/maarchRM/Resources/locale/fr/recordsManagement/log.po +++ b/src/presentation/maarchRM/Resources/locale/fr/recordsManagement/log.po @@ -65,3 +65,5 @@ msgstr "La vérification d'intégrité du journal a échoué." msgid "The journal is integrity is valid." msgstr "Le journal est intègre." +msgid "result(s) on" +msgstr "résultat(s) sur" diff --git a/src/presentation/maarchRM/Resources/view/recordsManagement/log/result.html b/src/presentation/maarchRM/Resources/view/recordsManagement/log/result.html index 2fcd59af4..0c40728f9 100755 --- a/src/presentation/maarchRM/Resources/view/recordsManagement/log/result.html +++ b/src/presentation/maarchRM/Resources/view/recordsManagement/log/result.html @@ -20,7 +20,10 @@ along with this program. If not, see .
+

result(s)

+ +

result(s) on total

@@ -56,4 +59,4 @@ along with this program. If not, see .
-
\ No newline at end of file +
diff --git a/src/presentation/maarchRM/Resources/view/recordsManagement/log/searchForm.html b/src/presentation/maarchRM/Resources/view/recordsManagement/log/searchForm.html index 78f390bb2..8b2612738 100755 --- a/src/presentation/maarchRM/Resources/view/recordsManagement/log/searchForm.html +++ b/src/presentation/maarchRM/Resources/view/recordsManagement/log/searchForm.html @@ -37,6 +37,7 @@ along with this program. If not, see .
+
@@ -124,7 +125,8 @@ along with this program. If not, see . fromDate : $("#searchForm #fromDate").data('datepicker').getFormattedDate('yyyy-mm-dd'), toDate : $("#searchForm #toDate").data('datepicker').getFormattedDate('yyyy-mm-dd'), processId : $("#searchForm #processId").val(), - processName : $("#searchForm #processName").val() + processName : $("#searchForm #processName").val(), + maxResults: $('#maxResults').val() } ajax($(this), { @@ -138,10 +140,10 @@ along with this program. If not, see . $('#archiveList').append(response); } }); - }); + }); $("#contain").on("click",'[data-form-reset]', function () { - $("#searchForm").find('input').val(''); + $("#searchForm").find('input[type=text], input[type=number], input[type=date], select').val(''); $("#type").prop('selectedIndex', 0); $('#archiveList').html(''); }); diff --git a/src/presentation/maarchRM/UserStory/journal/searchLogArchiveInterface.php b/src/presentation/maarchRM/UserStory/journal/searchLogArchiveInterface.php index 3fe1c24b5..0b6df253d 100755 --- a/src/presentation/maarchRM/UserStory/journal/searchLogArchiveInterface.php +++ b/src/presentation/maarchRM/UserStory/journal/searchLogArchiveInterface.php @@ -31,8 +31,10 @@ interface searchLogArchiveInterface public function readLogSearch(); /** - * @return recordsManagement/log/find * @uses recordsManagement/log/readFind + * @uses recordsManagement/log/countFind + * + * @return recordsManagement/log/find */ public function readLogs(); -- GitLab From fb4f9d6a248a6754ac979d6ad1f7e7b03f83fbfd Mon Sep 17 00:00:00 2001 From: AGO Date: Thu, 6 Aug 2020 11:52:46 +0200 Subject: [PATCH 6/6] fix/14312: add trad --- .../maarchRM/Resources/locale/fr/recordsManagement/messages.po | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/presentation/maarchRM/Resources/locale/fr/recordsManagement/messages.po b/src/presentation/maarchRM/Resources/locale/fr/recordsManagement/messages.po index a3262b1ca..1c6d94944 100755 --- a/src/presentation/maarchRM/Resources/locale/fr/recordsManagement/messages.po +++ b/src/presentation/maarchRM/Resources/locale/fr/recordsManagement/messages.po @@ -420,6 +420,9 @@ msgstr "DUA" msgid "result(s)" msgstr "résultat(s)" +msgid "archive(s) on" +msgstr "archive(s) sur" + msgid "Search" msgstr "Rechercher" -- GitLab