Skip to content

Commit

Permalink
*6747* add reviewer modal was not supposed to have tabs. Provide link…
Browse files Browse the repository at this point in the history
… to other types of adding modals and provide method for reloading form content with other forms.
  • Loading branch information
jalperin committed Aug 12, 2011
1 parent c4bd3c6 commit d51ba6f
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 97 deletions.
35 changes: 18 additions & 17 deletions controllers/grid/users/reviewer/ReviewerGridHandler.inc.php
Expand Up @@ -46,7 +46,7 @@ function ReviewerGridHandler() {
$this->addRoleAssignment(
array(ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_MANAGER),
array(
'fetchGrid', 'fetchRow', 'addReviewer', 'showReviewerForm', 'editReviewer', 'updateReviewer', 'deleteReviewer',
'fetchGrid', 'fetchRow', 'showReviewerForm', 'reloadReviewerForm', 'editReviewer', 'updateReviewer', 'deleteReviewer',
'getReviewersNotAssignedToMonograph', 'getUsersNotAssignedAsReviewers', 'readReview', 'reviewRead', 'thankReviewer',
'createReviewer', 'editReminder', 'sendReminder'
)
Expand Down Expand Up @@ -129,11 +129,12 @@ function initialize(&$request) {
// Grid actions
import('lib.pkp.classes.linkAction.request.AjaxModal');
$router =& $request->getRouter();
$actionArgs = array_merge($this->getRequestArgs(), array('selectionType' => REVIEWER_SELECT_SEARCH_BY_NAME));
$this->addAction(
new LinkAction(
'addReviewer',
new AjaxModal(
$router->url($request, null, null, 'addReviewer', null, $this->getRequestArgs()),
$router->url($request, null, null, 'showReviewerForm', null, $actionArgs),
__('editor.monograph.addReviewer')
),
__('editor.monograph.addReviewer')
Expand Down Expand Up @@ -212,21 +213,6 @@ function loadData($request, $filter) {
//
// Public actions
//
/**
* An action to manually add a new reviewer
* @param $args array
* @param $request PKPRequest
*/
function addReviewer($args, &$request) {
$templateMgr =& TemplateManager::getManager();
//FIXME: #6200. see other methods in this file.
$templateMgr->assign('stageId', $this->getStageId());
$templateMgr->assign('round', $this->getRound());
$monograph =& $this->getMonograph();
$templateMgr->assign('monographId', $monograph->getId());
return $templateMgr->fetchJson('controllers/grid/users/reviewer/form/addReviewerForm.tpl');
}

/**
* Add a reviewer that already exists
* @param $args array
Expand All @@ -247,6 +233,21 @@ function showReviewerForm($args, &$request) {
return $json->getString();
}

function reloadReviewerForm($args, &$request) {
$selectionType = $request->getUserVar('selectionType');
assert(!empty($selectionType));
$formClassName = $this->_getReviewerFormClassName($selectionType);

// Form handling.
import('controllers.grid.users.reviewer.form.' . $formClassName );
$reviewerForm = new $formClassName($this->getMonograph());
$reviewerForm->initData($args, $request);

$json = new JSONMessage(true);
$json->setEvent('refreshForm', $reviewerForm->fetch($request));
return $json->getString();
}

/**
* Edit a reviewer
* @param $args array
Expand Down
Expand Up @@ -42,13 +42,8 @@ function readInputData() {
* @param $request PKPRequest
*/
function execute($args, &$request) {
$seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO');
$submission =& $seriesEditorSubmissionDao->getSeriesEditorSubmission($this->getMonographId());
$press =& $request->getPress();

// Assign a reviewer user group to an existing non-reviewer
$userId = (int) $this->getData('userId');
$userGroupId = (int) $this->getData('userGroupId');

$userGroupId = (int) $this->getData('userGroupId');
$userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */
Expand Down
22 changes: 21 additions & 1 deletion controllers/grid/users/reviewer/form/ReviewerForm.inc.php
Expand Up @@ -19,6 +19,9 @@ class ReviewerForm extends Form {
/** The monograph associated with the review assignment **/
var $_monograph;

/** An array of actions for the other reviewer forms */
var $_reviewerFormActions;

/**
* Constructor.
*/
Expand Down Expand Up @@ -61,6 +64,21 @@ function setMonograph($monograph) {
$this->_monograph =& $monograph;
}

/**
* Set a reviewer form action
* @param $action LinkAction
*/
function setReviewerFormAction($action) {
$this->_reviewerFormActions[$action->getId()] =& $action;
}

/**
* Get all of the reviewer form actions
* @return array
*/
function getReviewerFormActions() {
return $this->_reviewerFormActions;
}
//
// Overridden template methods
//
Expand Down Expand Up @@ -129,6 +147,9 @@ function initData($args, &$request) {
* @see Form::fetch()
*/
function fetch(&$request) {
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('reviewerActions', $this->getReviewerFormActions());

// Get the reviewer user groups for the create new reviewer/enroll existing user tabs
$press =& $request->getPress();
$userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */
Expand Down Expand Up @@ -211,7 +232,6 @@ function execute($args, &$request) {
$reviewer =& $userDao->getUser($reviewerId);
$user = $submission->getUser();
$mail->addRecipient($reviewer->getEmail(), $reviewer->getFullName());
$press =& $request->getPress();

$paramArray = array(
'reviewerName' => $reviewer->getFullName(),
Expand Down
Expand Up @@ -34,6 +34,41 @@ function readInputData() {

$this->readUserVars(array('reviewerId'));
}

/**
* Fetch the form
* @see Form::fetch
*/
function fetch(&$request) {
// Pass along the request vars
$actionArgs = $request->getUserVars();
$actionArgs['selectionType'] = REVIEWER_SELECT_ADVANCED_SEARCH;
// but change the selectionType for each action
$advancedSearchAction = new LinkAction(
'advancedSearch',
new AjaxAction($request->url(null, null, 'reloadReviewerForm', null, $actionArgs)),
__('manager.reviewerSearch.advancedSearch.short')
);
$this->setReviewerFormAction($advancedSearchAction);
$actionArgs['selectionType'] = REVIEWER_SELECT_CREATE;
// but change the selectionType for each action
$advancedSearchAction = new LinkAction(
'selectCreate',
new AjaxAction($request->url(null, null, 'reloadReviewerForm', null, $actionArgs)),
__('editor.review.createReviewer')
);
$this->setReviewerFormAction($advancedSearchAction);
$actionArgs['selectionType'] = REVIEWER_SELECT_ENROLL_EXISTING;
// but change the selectionType for each action
$advancedSearchAction = new LinkAction(
'enrolExisting',
new AjaxAction($request->url(null, null, 'reloadReviewerForm', null, $actionArgs)),
__('editor.review.enrollReviewer.short')
);
$this->setReviewerFormAction($advancedSearchAction);

return parent::fetch($request);
}
}

?>
Expand Up @@ -27,7 +27,7 @@ class ReviewerSelectGridHandler extends GridHandler {
function ReviewerSelectGridHandler() {
parent::GridHandler();

$this->addRoleAssignment(array(ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_MANAGER),
$this->addRoleAssignment(array(ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_MANAGER, ROLE_ID_PRESS_ASSISTANT),
array('fetchGrid'));
}

Expand Down Expand Up @@ -67,7 +67,8 @@ function initialize(&$request) {
'',
null,
'controllers/grid/users/reviewerSelect/reviewerSelectRadioButton.tpl',
$cellProvider
$cellProvider,
array('width' => 5)
)
);
$this->addColumn(
Expand All @@ -76,7 +77,10 @@ function initialize(&$request) {
'author.users.contributor.name',
null,
'controllers/grid/gridCell.tpl',
$cellProvider
$cellProvider,
array('alignment' => COLUMN_ALIGNMENT_LEFT,
'width' => 30
)
)
);
$this->addColumn(
Expand Down Expand Up @@ -121,7 +125,8 @@ function initialize(&$request) {
'user.interests',
null,
'controllers/grid/gridCell.tpl',
$cellProvider
$cellProvider,
array('width' => 20)
)
);
}
Expand Down Expand Up @@ -195,8 +200,9 @@ function getFilterSelectionData($request) {
*/
function getFilterForm() {
$monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
$stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
import('controllers.grid.users.reviewerSelect.form.AdvancedSearchReviewerFilterForm');
$filterForm = new AdvancedSearchReviewerFilterForm($monograph);
$filterForm = new AdvancedSearchReviewerFilterForm($monograph, $stageId);
return $filterForm;
}

Expand All @@ -205,8 +211,6 @@ function getFilterForm() {
* @return array
*/
function _getFilterData() {
// Get the monograph
$monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
$filterData = array();

$interestDao =& DAORegistry::getDAO('InterestDAO');
Expand Down
Expand Up @@ -18,12 +18,16 @@ class AdvancedSearchReviewerFilterForm extends Form {
/** @var The monograph associated with the review assignment **/
var $_monograph;

/** @var int */
var $_stageId;

/**
* Constructor.
*/
function AdvancedSearchReviewerFilterForm($monograph) {
function AdvancedSearchReviewerFilterForm($monograph, $stageId) {
parent::Form();
$this->_monograph = $monograph;
$this->_stageId = $stageId;
$this->setTemplate('controllers/grid/users/reviewer/form/advancedSearchReviewerFilterForm.tpl');
}

Expand All @@ -35,6 +39,13 @@ function getMonograph() {
return $this->_monograph;
}

/**
* Get the stage id
*/
function getStageId() {
return $this->_stageId;
}

/*
* Initialize the filter form inputs
* @param $filterData array
Expand All @@ -45,6 +56,7 @@ function initData($filterData, &$request) {

$monograph = $this->getMonograph();
$this->setData('monographId', $monograph->getId());
$this->setData('stageId', $this->getStageId());

return parent::initData($filterData, $request);
}
Expand Down
Expand Up @@ -28,6 +28,8 @@

$('#selectReviewerButton').click(
this.callbackWrapper(this.reviewerSelected));

$('#regularReviewerForm').hide();
};
$.pkp.classes.Helper.inherits(
$.pkp.controllers.AdvancedReviewerSearchHandler, $.pkp.classes.Handler);
Expand All @@ -50,13 +52,17 @@
var reviewerId = $selectedInput.val();

if (reviewerId) {
var reviewerName = $selectedInput.parent().next().children('span').html();
var reviewerName = $selectedInput.parent().next().children('span').html().trim();

// Update the hidden review id input
$('#reviewerId').val(reviewerId);

// Update the selected reviewer name container
$('#selectedReviewerName').hide().html(reviewerName).show(300);
$('#selectedReviewerName').val(reviewerName);

// Hide the grid now
$('#searchGridAndButton').hide();
$('#regularReviewerForm').show();
}
};

Expand Down
27 changes: 0 additions & 27 deletions templates/controllers/grid/users/reviewer/form/addReviewerForm.tpl

This file was deleted.

Expand Up @@ -16,29 +16,27 @@
</script>

{** This form contains the inputs that will be used to filter the list of reviewers in the grid below **}
<form class="pkp_form" id="reviewerFilterForm" action="{url router=$smarty.const.ROUTE_COMPONENT component="grid.users.reviewerSelect.ReviewerSelectGridHandler" op="fetchGrid" monographId=$monographId}" method="post" class="pkp_controllers_reviewerSelector">

<form class="pkp_form" id="reviewerFilterForm" action="{url router=$smarty.const.ROUTE_COMPONENT component="grid.users.reviewerSelect.ReviewerSelectGridHandler" op="fetchGrid"}" method="post" class="pkp_controllers_reviewerSelector">
{include file="common/formErrors.tpl"}

<input type="hidden" id="monographId" name="monographId" value="{$monographId}" />
{fbvFormArea id="reviewerSearchForm"}
<input type="hidden" id="monographId" name="monographId" value="{$monographId|escape}" />
<input type="hidden" id="stageId" name="stageId" value="{$stageId|escape}" />
<input type="hidden" name="done_min" value="0" />
<input type="hidden" name="avg_min" value="0" />
<input type="hidden" name="last_min" value="0" />
<input type="hidden" name="active_min" value="0" />
{fbvFormSection}
{fbvElement type="rangeSlider" id="done" label="manager.reviewerSearch.doneAmount" min=$reviewerValues.done_min max=$reviewerValues.done_max}
{/fbvFormSection}
{fbvFormSection}
{fbvElement type="rangeSlider" id="avg" label="manager.reviewerSearch.avgAmount" min=$reviewerValues.avg_min max=$reviewerValues.avg_max}
{/fbvFormSection}
{fbvFormSection}
{fbvElement type="rangeSlider" id="last" label="manager.reviewerSearch.lastAmount" min=$reviewerValues.last_min max=$reviewerValues.last_max}
{/fbvFormSection}
{fbvFormSection}
{fbvElement type="rangeSlider" id="active" label="manager.reviewerSearch.activeAmount" min=$reviewerValues.active_min max=$reviewerValues.active_max}
{fbvElement type="text" id="done_max" name="done_max" value=$reviewerValues.done_max|escape label="manager.reviewerSearch.doneAmount" inline=true size=$fbvStyles.size.MEDIUM}
{fbvElement type="text" id="avg_max" name="avg_max" value=$reviewerValues.done_max|escape label="manager.reviewerSearch.avgAmount" inline=true size=$fbvStyles.size.MEDIUM}
{fbvElement type="text" id="last_max" name="last_max" value=$reviewerValues.last_max|escape label="manager.reviewerSearch.lastAmount" inline=true size=$fbvStyles.size.MEDIUM}
{fbvElement type="text" id="active_max" name="active_max" value=$reviewerValues.done_max|escape label="manager.reviewerSearch.activeAmount" inline=true size=$fbvStyles.size.MEDIUM}
{/fbvFormSection}
<br /><br /><br /><br /><br /><br />
{fbvFormSection}
{fbvElement type="keyword" id="interestSearch" available=$interestSearchKeywords label="manager.reviewerSearch.interests"}
{/fbvFormSection}
{fbvFormSection class="center"}
{fbvElement type="submit" id="submitFilter" label="common.refresh"}
{fbvElement type="submit" id="submitFilter" label="common.search"}
{/fbvFormSection}
{/fbvFormArea}
</form>
Expand Down

0 comments on commit d51ba6f

Please sign in to comment.