Skip to content

Commit

Permalink
pkp/pkp-lib#2612 Update submission filtering by section to fit ListPa…
Browse files Browse the repository at this point in the history
…nelFilter pattern
  • Loading branch information
NateWr committed Aug 14, 2017
1 parent b91f11c commit 668bea8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
6 changes: 3 additions & 3 deletions classes/services/SectionService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class SectionService {
/**
* Get array of sections
*
* @param \Journal $journal
* @param int $contextId
*
* @return array
*/
public function getSectionList(\Journal $journal) {
public function getSectionList(int $contextId) {
$sectionDao = \DAORegistry::getDAO('SectionDAO');
$sectionIterator = $sectionDao->getByContextId($journal);
$sectionIterator = $sectionDao->getByContextId($contextId);

$sections = array();
while ($section = $sectionIterator->next()) {
Expand Down
56 changes: 45 additions & 11 deletions controllers/list/submissions/SubmissionsListHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ public function getConfig() {

$request = Application::getRequest();
if ($request->getContext()) {
import('classes.core.ServicesContainer');
$config['sections'] = ServicesContainer::instance()
->get('section')
->getSectionList($request->getContext());
}
if (!isset($config['filters'])) {
$config['filters'] = array();
}
$config['filters']['sectionIds'] = array(
'heading' => __('section.sections'),
'filters' => $this->getSectionFilters(),
);

$config['i18n']['sections'] = __('section.sections');
// Put the incomplete filter at the end
if (isset($config['filters']['isIncomplete'])) {
$isIncompleteFilter = $config['filters']['isIncomplete'];
unset($config['filters']['isIncomplete']);
$config['filters']['isIncomplete'] = $isIncompleteFilter;
}
}

return $config;
}
Expand All @@ -42,21 +50,47 @@ public function getConfig() {
public function getWorkflowStages() {
return array(
array(
'id' => WORKFLOW_STAGE_ID_SUBMISSION,
'val' => WORKFLOW_STAGE_ID_SUBMISSION,
'title' => __('manager.publication.submissionStage'),
),
array(
'id' => WORKFLOW_STAGE_ID_EXTERNAL_REVIEW,
'val' => WORKFLOW_STAGE_ID_EXTERNAL_REVIEW,
'title' => __('manager.publication.reviewStage'),
),
array(
'id' => WORKFLOW_STAGE_ID_EDITING,
'title' => __('manager.publication.editorialStage'),
'val' => WORKFLOW_STAGE_ID_EDITING,
'title' => __('submission.copyediting'),
),
array(
'id' => WORKFLOW_STAGE_ID_PRODUCTION,
'val' => WORKFLOW_STAGE_ID_PRODUCTION,
'title' => __('manager.publication.productionStage'),
),
);
}

/**
* Compile the sections for passing as filters
*
* @return array
*/
public function getSectionFilters() {
$request = Application::getRequest();
$context = $request->getContext();

if (!$context) {
return array();
}

import('classes.core.ServicesContainer');
$sections = ServicesContainer::instance()
->get('section')
->getSectionList($context->getId());

return array_map(function($section) {
return array(
'val' => $section['id'],
'title' => $section['title'],
);
}, $sections);
}
}

0 comments on commit 668bea8

Please sign in to comment.