-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkp/pkp-lib#2612 Submission filtering #2704
Changes from 6 commits
6e5194f
472e2b3
3990faa
0d5f666
dc1598f
6d7836c
8bdb241
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<?php | ||
/** | ||
* @file controllers/list/submissions/SubmissionsListHandler.inc.php | ||
* @file controllers/list/submissions/PKPSubmissionsListHandler.inc.php | ||
* | ||
* Copyright (c) 2014-2017 Simon Fraser University | ||
* Copyright (c) 2000-2016 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @class SubmissionsListHandler | ||
* @class PKPSubmissionsListHandler | ||
* @ingroup classes_controllers_list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is ingroup classes? |
||
* | ||
* @brief Instantiates and manages a UI component to list submissions. | ||
|
@@ -15,7 +15,7 @@ | |
import('lib.pkp.classes.db.DBResultRange'); | ||
import('lib.pkp.classes.submission.Submission'); | ||
|
||
class SubmissionsListHandler extends ListHandler { | ||
abstract class PKPSubmissionsListHandler extends ListHandler { | ||
|
||
/** | ||
* Count of items to retrieve in initial page/request | ||
|
@@ -97,6 +97,27 @@ public function getConfig() { | |
|
||
$config['getParams'] = $this->_getParams; | ||
|
||
$config['filters'] = array( | ||
'attention' => array( | ||
'filters' => array( | ||
array( | ||
'param' => 'isOverdue', | ||
'val' => true, | ||
'title' => __('common.overdue'), | ||
), | ||
array( | ||
'param' => 'isIncomplete', | ||
'val' => true, | ||
'title' => __('submissions.incomplete'), | ||
), | ||
), | ||
), | ||
'stageIds' => array( | ||
'heading' => __('settings.roles.stages'), | ||
'filters' => $this->getWorkflowStages(), | ||
), | ||
); | ||
|
||
// Load grid localisation files | ||
AppLocale::requireComponents(LOCALE_COMPONENT_PKP_GRID); | ||
AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION); | ||
|
@@ -159,4 +180,11 @@ public function getItems() { | |
->get('submission') | ||
->getSubmissionList($contextId, $params); | ||
} | ||
|
||
/** | ||
* Get an array of workflow stages supported by the current app | ||
* | ||
* @return array | ||
*/ | ||
abstract function getWorkflowStages(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,34 @@ export default { | |
}, | ||
methods: { | ||
/** | ||
* Emit an event to filter items in the list panel | ||
* Check if a filter is currently active | ||
*/ | ||
filterList: function(data) { | ||
this.$emit('filterList', data); | ||
isFilterActive: function(type, val) { | ||
return this.activeFilters.filter(filter => { | ||
return filter.type === type && filter.val === val; | ||
}).length | ||
}, | ||
|
||
/** | ||
* Add a filter | ||
*/ | ||
filterBy: function(type, val) { | ||
if (this.isFilterActive(type, val)) { | ||
this.clearFilter(type, val); | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is happening here: when a filter that is active is added, it will be removed? :-\ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a toggle feature. Click once to activate it. If you click on the filter again, you deactivate it. |
||
this.activeFilters.push({type: type, val: val}); | ||
this.filterList(this.compileFilterParams()); | ||
}, | ||
|
||
/** | ||
* Remove a filter | ||
*/ | ||
clearFilter: function(type, val) { | ||
this.activeFilters = this.activeFilters.filter(filter => { | ||
return filter.type !== type || filter.val !== val; | ||
}); | ||
this.filterList(this.compileFilterParams()); | ||
}, | ||
|
||
/** | ||
|
@@ -37,6 +61,27 @@ export default { | |
this.activeFilters = []; | ||
this.filterList({}); | ||
}, | ||
|
||
/** | ||
* Compile active filters into filter parameters | ||
*/ | ||
compileFilterParams: function() { | ||
let params = {}; | ||
for (var filter of this.activeFilters) { | ||
if (params[filter.type] === undefined) { | ||
params[filter.type] = []; | ||
} | ||
params[filter.type].push(filter.val); | ||
} | ||
return params; | ||
}, | ||
|
||
/** | ||
* Emit an event to filter items in the list panel | ||
*/ | ||
filterList: function(data) { | ||
this.$emit('filterList', data); | ||
}, | ||
}, | ||
mounted: function() { | ||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be 2017?