getData();
$columnId = $column->getId();
assert($reviewAssignment instanceof \PKP\core\DataObject && !empty($columnId));
/** @var ReviewAssignment $reviewAssignment */
switch ($columnId) {
case 'name':
case 'method':
return '';
case 'considered':
case 'actions':
return $reviewAssignment->getStatus();
}
}
/**
* Extracts variables for a given column from a data element
* so that they may be assigned to template before rendering.
*
* @param \PKP\controllers\grid\GridRow $row
* @param GridColumn $column
*
* @return array
*/
public function getTemplateVarsFromRowColumn($row, $column)
{
$element = $row->getData();
$columnId = $column->getId();
assert($element instanceof \PKP\core\DataObject && !empty($columnId));
/** @var ReviewAssignment $element */
switch ($columnId) {
case 'name':
return ['label' => $element->getReviewerFullName()];
case 'method':
return ['label' => __($element->getReviewMethodKey())];
case 'considered':
$statusText = $this->_getStatusText($this->getCellState($row, $column), $row);
$reviewAssignment = $row->getData();
$competingInterests = $reviewAssignment->getCompetingInterests();
if ($competingInterests) {
$statusText .= '' . __('reviewer.competingInterests') . '';
}
return ['label' => $statusText];
case 'actions':
// Only attach actions to this column. See self::getCellActions()
return ['label' => ''];
}
return parent::getTemplateVarsFromRowColumn($row, $column);
}
/**
* Get cell actions associated with this row/column combination
*
* @param \PKP\controllers\grid\GridRow $row
* @param GridColumn $column
*
* @return ?array an array of LinkAction instances
*/
public function getCellActions($request, $row, $column, $position = GridHandler::GRID_ACTION_POSITION_DEFAULT)
{
$reviewAssignment = $row->getData();
$actionArgs = [
'submissionId' => $reviewAssignment->getSubmissionId(),
'reviewAssignmentId' => $reviewAssignment->getId(),
'stageId' => $reviewAssignment->getStageId(),
];
$submission = Repo::submission()->get($reviewAssignment->getSubmissionId());
// Only attach actions to the actions column. The actions and status
// columns share state values.
$columnId = $column->getId();
if ($columnId == 'actions') {
switch ($this->getCellState($row, $column)) {
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_COMPLETE:
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_THANKED:
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_RECEIVED:
$user = $request->getUser();
return [new ReviewNotesLinkAction($request, $reviewAssignment, $submission, $user, 'grid.users.reviewer.AuthorReviewerGridHandler', true)];
default:
return null;
}
}
return parent::getCellActions($request, $row, $column, $position);
}
/**
* Provide meaningful locale keys for the various grid status states.
*
* @param string $state
* @param \PKP\controllers\grid\GridRow $row
*
* @return string
*/
public function _getStatusText($state, $row)
{
$reviewAssignment = $row->getData();
switch ($state) {
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE:
return '' . __('editor.review.requestSent') . '' . __('editor.review.responseDue', ['date' => substr($reviewAssignment->getDateResponseDue(), 0, 10)]) . '';
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_ACCEPTED:
return '' . __('editor.review.requestAccepted') . '' . __('editor.review.reviewDue', ['date' => substr($reviewAssignment->getDateDue(), 0, 10)]) . '';
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_COMPLETE:
return $this->_getStatusWithRecommendation('common.complete', $reviewAssignment);
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_REVIEW_OVERDUE:
return '' . __('common.overdue') . '' . __('editor.review.reviewDue', ['date' => substr($reviewAssignment->getDateDue(), 0, 10)]) . '';
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_RESPONSE_OVERDUE:
return '' . __('common.overdue') . '' . __('editor.review.responseDue', ['date' => substr($reviewAssignment->getDateResponseDue(), 0, 10)]) . '';
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_DECLINED:
return '' . __('common.declined') . '';
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_CANCELLED:
return '' . __('common.cancelled') . '';
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_RECEIVED:
return $this->_getStatusWithRecommendation('editor.review.reviewSubmitted', $reviewAssignment);
default:
return '';
}
}
/**
* Retrieve a formatted HTML string that displays the state of the review
* with the review recommendation if one exists. Or return just the state.
* Only works with some states.
*
* @param string $statusKey Locale key for status text
* @param \PKP\submission\reviewAssignment\ReviewAssignment $reviewAssignment
*
* @return string
*/
public function _getStatusWithRecommendation($statusKey, $reviewAssignment)
{
if (!$reviewAssignment->getRecommendation()) {
return __($statusKey);
}
return '' . __($statusKey) . '' . __('submission.recommendation', ['recommendation' => $reviewAssignment->getLocalizedRecommendation()]) . '';
}
}