first commit
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @defgroup js_controllers_grid_users_stageParticipant_form
|
||||
*/
|
||||
/**
|
||||
* @file js/controllers/AdvancedReviewerSearchHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class AdvancedReviewerSearchHandler
|
||||
* @ingroup js_controllers
|
||||
*
|
||||
* @brief Handle the advanced reviewer search tab in the add reviewer modal.
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
/** @type {Object} */
|
||||
$.pkp.controllers.grid.users.reviewer =
|
||||
$.pkp.controllers.grid.users.reviewer || {};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.classes.Handler
|
||||
*
|
||||
* @param {jQueryObject} $container the wrapped page element.
|
||||
* @param {Object} options handler options.
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.AdvancedReviewerSearchHandler =
|
||||
function($container, options) {
|
||||
this.parent($container, options);
|
||||
|
||||
$container.find('.button').button();
|
||||
|
||||
pkp.eventBus.$on('selected:reviewer', function(reviewer) {
|
||||
$('#reviewerId').val(reviewer.id);
|
||||
$('[id^="selectedReviewerName"]').text(reviewer.fullName);
|
||||
$('#searchGridAndButton').hide();
|
||||
$('#regularReviewerForm').show();
|
||||
|
||||
// Set the email message for reviewers depending
|
||||
// on previous completed assignments
|
||||
var $textarea = $('#reviewerFormFooter [name="personalMessage"]'),
|
||||
$templateInput,
|
||||
$templateOption,
|
||||
editor,
|
||||
templateKey;
|
||||
if ($textarea.val()) {
|
||||
return; // The message is already set; shouldn't happen
|
||||
}
|
||||
// Only 1 template available
|
||||
$templateInput = $('#reviewerFormFooter input[name="template"]');
|
||||
// Multiple available templates
|
||||
$templateOption = $('#reviewerFormFooter select[name="template"]');
|
||||
editor = tinyMCE.EditorManager.get($textarea.attr('id'));
|
||||
templateKey = '';
|
||||
if (options.lastRoundReviewerIds.includes(reviewer.id)) {
|
||||
templateKey = 'REVIEW_REQUEST_SUBSEQUENT';
|
||||
editor.setContent(options.reviewerMessages[templateKey]);
|
||||
$templateInput.val(templateKey);
|
||||
$templateOption.find('[value="REVIEW_REQUEST"]').remove();
|
||||
} else {
|
||||
templateKey = 'REVIEW_REQUEST';
|
||||
editor.setContent(options.reviewerMessages[templateKey]);
|
||||
$templateInput.val(templateKey);
|
||||
$templateOption.find('[value="REVIEW_REQUEST_SUBSEQUENT"]').remove();
|
||||
}
|
||||
// Select the right template option to correspond
|
||||
// the one, which is set in TinyMCE
|
||||
$templateOption.find('[value="' + templateKey + '"]')
|
||||
.prop('selected', true);
|
||||
});
|
||||
|
||||
$('#regularReviewerForm').hide();
|
||||
|
||||
this.bind('refreshForm', this.handleRefresh_);
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.controllers.grid.users.reviewer.AdvancedReviewerSearchHandler,
|
||||
$.pkp.classes.Handler);
|
||||
|
||||
|
||||
//
|
||||
// Private helper methods.
|
||||
//
|
||||
/**
|
||||
* Handle the form refresh event.
|
||||
* @private
|
||||
* @param {HTMLElement} sourceElement The element that issued the event.
|
||||
* @param {Event} event The triggering event.
|
||||
* @param {string} content HTML contents to replace element contents.
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.AdvancedReviewerSearchHandler.prototype.
|
||||
handleRefresh_ = function(sourceElement, event, content) {
|
||||
|
||||
if (content) {
|
||||
this.replaceWith(content);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* @defgroup js_controllers_grid_users_reviewer
|
||||
*/
|
||||
/**
|
||||
* @file js/controllers/grid/users/reviewer/ReadReviewHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class ReadReviewHandler
|
||||
* @ingroup js_controllers_grid_users_reviewer
|
||||
*
|
||||
* @brief Handle the advanced reviewer search tab in the add reviewer modal.
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.controllers.form.AjaxFormHandler
|
||||
*
|
||||
* @param {jQueryObject} $form the wrapped page element.
|
||||
* @param {Object} options handler options.
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.ReadReviewHandler =
|
||||
function($form, options) {
|
||||
this.parent($form, options);
|
||||
|
||||
this.reviewCompleted_ = options.reviewCompleted;
|
||||
// bind a handler to make sure that a review file has been uploaded.
|
||||
$form.find('[id^=\'submitFormButton-\']').click(this.callbackWrapper(
|
||||
this.reviewFilesRequired_));
|
||||
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.controllers.grid.users.reviewer.ReadReviewHandler,
|
||||
$.pkp.controllers.form.AjaxFormHandler);
|
||||
|
||||
|
||||
//
|
||||
// Private methods.
|
||||
//
|
||||
/**
|
||||
* Is the review completed.
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.ReadReviewHandler.
|
||||
prototype.reviewCompleted_ = false;
|
||||
|
||||
|
||||
/**
|
||||
* Internal callback called on form submit to ensure there are
|
||||
* some review files uploaded.
|
||||
* @private
|
||||
* @param {HTMLElement} submitButton The submit button.
|
||||
* @param {Event} event The event that triggered the
|
||||
* submit button.
|
||||
* @return {boolean} true.
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.ReadReviewHandler.
|
||||
prototype.reviewFilesRequired_ = function(submitButton, event) {
|
||||
|
||||
if (!this.reviewCompleted_ && $('#readReviewAttachmentsGridContainer').
|
||||
find('tbody.empty:visible').length == 1) {
|
||||
// There's nothing in the files grid; don't submit the form
|
||||
this.showWarning_();
|
||||
return false;
|
||||
} else {
|
||||
// There's something in the files grid;
|
||||
this.hideWarning_();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Hide the "no files" warning.
|
||||
* @private
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.ReadReviewHandler.
|
||||
prototype.hideWarning_ = function() {
|
||||
this.getHtmlElement().find('#noFilesWarning').hide(250);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Show the "no files" warning.
|
||||
* @private
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.ReadReviewHandler.
|
||||
prototype.showWarning_ = function() {
|
||||
this.getHtmlElement().find('#noFilesWarning').show(250);
|
||||
};
|
||||
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* @file js/controllers/grid/users/reviewer/form/AddReviewerFormHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class AddReviewerFormHandler
|
||||
* @ingroup js_controllers_grid_users_reviewer_form
|
||||
*
|
||||
* @brief Handle the Add Reviewer form (and template for message body).
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.controllers.grid.users.reviewer.form.EditReviewFormHandler
|
||||
*
|
||||
* @param {jQueryObject} $form the wrapped HTML form element.
|
||||
* @param {Object} options form options.
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.
|
||||
AddReviewerFormHandler = function($form, options) {
|
||||
|
||||
this.parent($form, options);
|
||||
|
||||
// Set the URL to retrieve templates from.
|
||||
if (options.templateUrl) {
|
||||
this.templateUrl_ = options.templateUrl;
|
||||
}
|
||||
|
||||
// Attach form elements events.
|
||||
$form.find('#template').change(
|
||||
this.callbackWrapper(this.selectTemplateHandler_));
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.controllers.grid.users.reviewer.form.
|
||||
AddReviewerFormHandler,
|
||||
$.pkp.controllers.grid.users.reviewer.form.
|
||||
EditReviewFormHandler);
|
||||
|
||||
|
||||
//
|
||||
// Private properties
|
||||
//
|
||||
/**
|
||||
* The URL to use to retrieve template bodies
|
||||
* @private
|
||||
* @type {string?}
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.
|
||||
AddReviewerFormHandler.prototype.templateUrl_ = null;
|
||||
|
||||
|
||||
//
|
||||
// Protected methods
|
||||
//
|
||||
/**
|
||||
* Show the "no files" warning.
|
||||
* @protected
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.AddReviewerFormHandler.
|
||||
prototype.showWarning = function() {
|
||||
// Call the parent showWarning to show the warning
|
||||
this.parent('showWarning');
|
||||
|
||||
// Ask the reviewer form footer handler to expand the file
|
||||
// list extras-on-demand if it isn't already expanded.
|
||||
this.getHtmlElement().find('#reviewerFormFooter')
|
||||
.trigger('expandFileList');
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Private methods
|
||||
//
|
||||
/**
|
||||
* Respond to an "item selected" call by triggering a published event.
|
||||
*
|
||||
* @param {HTMLElement} sourceElement The element that
|
||||
* issued the event.
|
||||
* @param {Event} event The triggering event.
|
||||
* @private
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.
|
||||
AddReviewerFormHandler.prototype.selectTemplateHandler_ =
|
||||
function(sourceElement, event) {
|
||||
|
||||
var $form = this.getHtmlElement();
|
||||
$.post(this.templateUrl_, $form.find('#template').serialize(),
|
||||
this.callbackWrapper(this.updateTemplate), 'json');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Internal callback to replace the textarea with the contents of the
|
||||
* template body.
|
||||
*
|
||||
* @param {HTMLElement} formElement The wrapped HTML form.
|
||||
* @param {Object} jsonData The data returned from the server.
|
||||
* @return {boolean} The response status.
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.
|
||||
AddReviewerFormHandler.prototype.updateTemplate =
|
||||
function(formElement, jsonData) {
|
||||
|
||||
var $form = this.getHtmlElement(),
|
||||
processedJsonData = this.handleJson(jsonData),
|
||||
$textarea = $form.find('textarea[name="personalMessage"]'),
|
||||
editor =
|
||||
tinyMCE.EditorManager.get(/** @type {string} */ ($textarea.attr('id')));
|
||||
|
||||
if (processedJsonData !== false) {
|
||||
if (processedJsonData.content !== '') {
|
||||
editor.setContent(processedJsonData.content);
|
||||
}
|
||||
}
|
||||
return processedJsonData.status;
|
||||
};
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* @defgroup js_controllers_grid_users_reviewer_form
|
||||
*/
|
||||
/**
|
||||
* @file js/controllers/grid/users/reviewer/form/EditReviewFormHandler.js
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class EditReviewFormHandler
|
||||
* @ingroup js_controllers_grid_users_reviewer_form
|
||||
*
|
||||
* @brief Handle the limit reviewer files form. Also used as a base class
|
||||
* for the add reviewer form handler.
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
/** @type {Object} */
|
||||
$.pkp.controllers.grid.users.reviewer.form =
|
||||
$.pkp.controllers.grid.users.reviewer.form || {};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @extends $.pkp.controllers.form.UserFormHandler
|
||||
*
|
||||
* @param {jQueryObject} $form the wrapped HTML form element.
|
||||
* @param {Object} options form options.
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.
|
||||
EditReviewFormHandler = function($form, options) {
|
||||
|
||||
this.parent($form, options);
|
||||
|
||||
// When the form changes, check to see if a warning is necessary
|
||||
// (if all reviewer files are unchecked)
|
||||
$form.change(this.callbackWrapper(this.handleFormChange));
|
||||
|
||||
// When the reviewer files list loads, trigger the above check
|
||||
this.bind('urlInDivLoaded', this.handleFileListLoad_);
|
||||
};
|
||||
$.pkp.classes.Helper.inherits(
|
||||
$.pkp.controllers.grid.users.reviewer.form.
|
||||
EditReviewFormHandler,
|
||||
$.pkp.controllers.form.UserFormHandler);
|
||||
|
||||
|
||||
//
|
||||
// Protected methods.
|
||||
//
|
||||
/**
|
||||
* Handle a form change event.
|
||||
* @protected
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.EditReviewFormHandler.
|
||||
prototype.handleFormChange = function() {
|
||||
if (this.getHtmlElement()
|
||||
.find('input[name="selectedFiles[]"]:checked').length) {
|
||||
this.hideWarning();
|
||||
} else {
|
||||
this.showWarning();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Hide the "no files" warning.
|
||||
* @protected
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.EditReviewFormHandler.
|
||||
prototype.hideWarning = function() {
|
||||
this.getHtmlElement().find('#noFilesWarning').hide(250);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Show the "no files" warning.
|
||||
* @protected
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.EditReviewFormHandler.
|
||||
prototype.showWarning = function() {
|
||||
this.getHtmlElement().find('#noFilesWarning').show(250);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Private methods.
|
||||
//
|
||||
/**
|
||||
* Handle the loading of the reviewer files list.
|
||||
* @private
|
||||
* @param {HTMLElement} sourceElement The element that
|
||||
* issued the event.
|
||||
* @param {Event} event The triggering event.
|
||||
* @param {?string} data additional event data.
|
||||
*/
|
||||
$.pkp.controllers.grid.users.reviewer.form.EditReviewFormHandler.
|
||||
prototype.handleFileListLoad_ =
|
||||
function(sourceElement, event, data) {
|
||||
|
||||
// Trigger a form change event to display the "no files
|
||||
// selected" warning, if necessary.
|
||||
this.getHtmlElement().change();
|
||||
};
|
||||
|
||||
}(jQuery));
|
||||
Reference in New Issue
Block a user