first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-06-08 17:09:23 -04:00
commit df3a033196
17887 changed files with 8637778 additions and 0 deletions
@@ -0,0 +1,51 @@
/**
* @file js/controllers/grid/users/UserGridHandler.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 UserGridHandler
* @ingroup js_controllers_grid
*
* @brief User grid handler. Used to keep user grids in sync, such as when
* merging users.
*/
(function($) {
// Define the namespace.
$.pkp.controllers.grid.users = $.pkp.controllers.grid.users || {};
/**
* @constructor
*
* @extends $.pkp.controllers.grid.GridHandler
*
* @param {jQueryObject} $grid The grid this handler is
* attached to.
* @param {Object} options Grid handler configuration.
*/
$.pkp.controllers.grid.users.UserGridHandler =
function($grid, options) {
this.parent($grid, options);
this.bindGlobal('userMerged', function() {
// Signal to any parent modals that they can close now
this.trigger('modalFinished');
this.refreshGridHandler();
});
// Refresh the grid when a user group has been added/edited
this.bindGlobal('userGroupUpdated', function() {
this.refreshGridHandler();
});
};
$.pkp.classes.Helper.inherits($.pkp.controllers.grid.users.UserGridHandler,
$.pkp.controllers.grid.GridHandler);
}(jQuery));
@@ -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));
@@ -0,0 +1,51 @@
/**
* @file js/controllers/grid/users/stageParticipant/StageParticipantGridHandler.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 StageParticipantGridHandler
* @ingroup js_controllers_grid
*
* @brief Stage participant grid handler.
*/
/*global pkp */
(function($) {
/** @type {Object} */
$.pkp.controllers.grid.users.stageParticipant =
$.pkp.controllers.grid.users.stageParticipant || {};
/**
* @constructor
*
* @extends $.pkp.controllers.grid.CategoryGridHandler
*
* @param {jQueryObject} $grid The grid this handler is
* attached to.
* @param {Object} options Grid handler configuration.
*/
$.pkp.controllers.grid.users.stageParticipant.StageParticipantGridHandler =
function($grid, options) {
this.parent($grid, options);
// Reload any editorial actions on the page.
this.bind('dataChanged', function() {
this.refreshGridHandler();
$(['#submissionEditorDecisionsDiv',
'#copyeditingEditorDecisionsDiv',
'[id^=reviewDecisionsDiv]'].join(','))
.each(function() {
$.pkp.classes.Handler.getHandler($(this)).reload();
});
});
};
$.pkp.classes.Helper.inherits(
$.pkp.controllers.grid.users.stageParticipant.StageParticipantGridHandler,
$.pkp.controllers.grid.CategoryGridHandler);
}(jQuery));
@@ -0,0 +1,72 @@
/**
* @defgroup js_controllers_grid_users_stageParticipant_form
*/
/**
* @file js/controllers/grid/users/stageParticipant/form/AddParticipantFormHandler.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 AddParticipantFormHandler
* @ingroup js_controllers_grid_users_stageParticipant_form
*
* @brief Handle the search user filter and
* add the value to the hidden userGroupId field.
*/
(function($) {
/**
* @constructor
*
* @extends $.pkp.controllers.form.ClientFormHandler
*
* @param {jQueryObject} $form the wrapped HTML form element.
* @param {Object} options form options.
*/
$.pkp.controllers.grid.users.stageParticipant.form.AddParticipantFormHandler =
function($form, options) {
this.parent($form, options);
$('select[name^=\'filterUserGroupId\']', $form).change(
this.callbackWrapper(this.addUserGroupId));
$form.parent().click(function(e) {
var $target = $(e.target), filterUserIdVal;
if ($target.is('input[name="userId"]')) {
filterUserIdVal = $('input[name=\'userId\']:checked').val();
$('input[name=\'userIdSelected\']').val(
filterUserIdVal).trigger('change');
}
});
// initially populate the input field.
this.addUserGroupId();
};
$.pkp.classes.Helper.inherits(
$.pkp.controllers.grid.users.stageParticipant.form.
AddParticipantFormHandler,
$.pkp.controllers.form.ClientFormHandler);
//
// Public methods
//
/**
* Method to add the value to the hidden userGroupId field
*/
$.pkp.controllers.grid.users.stageParticipant.form.AddParticipantFormHandler.
prototype.addUserGroupId = function() {
var $form = this.getHtmlElement(),
$filterUserGroupId = $form.find('select[name^=\'filterUserGroupId\']'),
filterUserGroupIdVal = /** @type {string} */ ($filterUserGroupId.val());
$('input[name=\'userGroupId\']').val(filterUserGroupIdVal).trigger('change');
};
}(jQuery));
@@ -0,0 +1,374 @@
/**
* @defgroup js_controllers_grid_users_stageParticipant_form
*/
/**
* @file js/controllers/grid/users/stageParticipant/form/StageParticipantNotifyHandler.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 StageParticipantNotifyHandler
* @ingroup js_controllers_grid_users_stageParticipant_form
*
* @brief Handle Stage participant notification forms.
*/
(function($) {
/** @type {Object} */
$.pkp.controllers.grid.users.stageParticipant.form =
$.pkp.controllers.grid.users.stageParticipant.form || {};
/**
* @constructor
*
* @extends $.pkp.controllers.form.AjaxFormHandler
*
* @param {jQueryObject} $form the wrapped HTML form element.
* @param {Object} options form options.
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler = function($form, options) {
this.parent($form, options);
// Set the URL to retrieve templates from.
if (options.templateUrl) {
this.templateUrl_ = options.templateUrl;
}
// Set the user group IDs with the recommendOnly possibility
if (options.possibleRecommendOnlyUserGroupIds) {
this.possibleRecommendOnlyUserGroupIds_ =
options.possibleRecommendOnlyUserGroupIds;
}
// Set the user group IDs with the recommendOnly option set
if (options.recommendOnlyUserGroupIds) {
this.recommendOnlyUserGroupIds_ = options.recommendOnlyUserGroupIds;
}
// Set the user group IDs that are not allowed to change the default
// value of permitMetadataEdit
if (options.notChangeMetadataEditPermissionRoles) {
this.notChangeMetadataEditPermissionRoles_ =
options.notChangeMetadataEditPermissionRoles;
}
// Set the user group IDs that have the permitMetadataEdit flag set to true
if (options.permitMetadataEditUserGroupIds) {
this.permitMetadataEditUserGroupIds_ =
options.permitMetadataEditUserGroupIds;
}
if (options.anonymousReviewerIds) {
this.anonymousReviewerIds_ = options.anonymousReviewerIds;
}
if (options.anonymousReviewerWarning) {
this.anonymousReviewerWarning_ = options.anonymousReviewerWarning;
}
if (options.anonymousReviewerWarningOk) {
this.anonymousReviewerWarningOk_ = options.anonymousReviewerWarningOk;
}
// Update the recommendOnly option display when user group changes
// or user is selected
$('input[name=\'userGroupId\'], input[name=\'userIdSelected\']', $form)
.change(this.callbackWrapper(this.updateRecommendOnly));
// Update the recommendOnly option display when user group changes
// or user is selected
$('input[name=\'userGroupId\'], input[name=\'userIdSelected\']', $form)
.change(this.callbackWrapper(
this.updateSubmissionMetadataEditPermitOption));
// Trigger a warning message if an anonymous reviewer is selected
$('input[name=\'userIdSelected\']', $form)
.change(this.callbackWrapper(this.maybeTriggerReviewerWarning));
// Attach form elements events.
$form.find('#template').change(
this.callbackWrapper(this.selectTemplateHandler_));
};
$.pkp.classes.Helper.inherits(
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler,
$.pkp.controllers.form.AjaxFormHandler);
//
// Private properties
//
/**
* The URL to use to retrieve template bodies
* @private
* @type {string?}
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.templateUrl_ = null;
/**
* A list of user IDs which are already assigned anonymous reviews for this
* submission.
* @private
* @type {Array}
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.anonymousReviewerIds_ = null;
/**
* A warning message to display when an anonymous reviewer is selected to be
* added as a recipient
* @private
* @type {string?}
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.anonymousReviewerWarning_ = null;
/**
* The OK button language for the anonymous reviewer warning message
* @private
* @type {string?}
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.
anonymousReviewerWarningOk_ = null;
/**
* The list of not allowed to change submission metadata edit permissions roles
* @private
* @type {Object?}
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.
notChangeMetadataEditPermissionRoles_ = null;
/**
* The list of group ids that are allowed to edit metadata
* @private
* @type {Object?}
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.
permitMetadataEditUserGroupIds_ = null;
//
// 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.stageParticipant.form.
StageParticipantNotifyHandler.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.stageParticipant.form.
StageParticipantNotifyHandler.prototype.updateTemplate =
function(formElement, jsonData) {
var $form = this.getHtmlElement(),
processedJsonData = this.handleJson(jsonData),
jsonDataContent =
/** @type {{variables: Object, body: string}} */ (jsonData.content),
$textarea = $form.find('textarea[name="message"]'),
editor =
tinyMCE.EditorManager.get(/** @type {string} */ ($textarea.attr('id')));
if (jsonDataContent.variables) {
$textarea.attr('data-variables', JSON.stringify(jsonDataContent.variables));
}
editor.setContent(jsonDataContent.body);
return processedJsonData.status;
};
/**
* Update the enabled/disabled and checked state of the recommendOnly checkbox.
* @param {HTMLElement} sourceElement The element that
* issued the event.
* @param {Event} event The triggering event.
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.updateRecommendOnly =
function(sourceElement, event) {
var $form = this.getHtmlElement(),
$filterUserGroupId = $form.find('input[name=\'userGroupId\']'),
$checkbox = $form.find('input[id^=\'recommendOnly\']'),
$checkboxDiv = $form.find('.recommendOnlyWrapper'),
i,
found = false,
filterUserGroupIdVal = /** @type {string} */ ($filterUserGroupId.val());
// If user group changes, hide the recommendOnly option
if ($(sourceElement).prop('name') == 'userGroupId') {
$checkbox.attr('disabled', 'disabled');
$checkbox.removeAttr('checked');
$checkboxDiv.hide();
} else if ($(sourceElement).prop('name') == 'userIdSelected' &&
!$checkboxDiv.is(':visible')) {
// Display recommendOnly option if
// an user group with a possible recommendOnly option is selected
for (i = 0; i < this.possibleRecommendOnlyUserGroupIds_.length; i++) {
if (this.possibleRecommendOnlyUserGroupIds_[i] == filterUserGroupIdVal) {
$checkbox.removeAttr('disabled');
$checkboxDiv.show();
// Select the recommendOnly option if
// an user group with a recommendOnly option set is selected
for (i = 0; i < this.recommendOnlyUserGroupIds_.length; i++) {
if (this.recommendOnlyUserGroupIds_[i] == filterUserGroupIdVal) {
$checkbox.prop('checked', true);
break;
}
}
break;
} else {
$checkbox.attr('disabled', 'disabled');
$checkboxDiv.hide();
}
}
}
};
/**
* Update the enabled/disabled and checked state of the recommendOnly checkbox.
* @param {HTMLElement} sourceElement The element that
* issued the event.
* @param {Event} event The triggering event.
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.maybeTriggerReviewerWarning =
function(sourceElement, event) {
var userId = $(sourceElement).val(),
opts;
if (!userId || this.anonymousReviewerIds_.indexOf(userId) < 0) {
return;
}
opts = {
title: '',
okButton: this.anonymousReviewerWarningOk_,
cancelButton: false,
dialogText: this.anonymousReviewerWarning_
};
$('<div id="' + $.pkp.classes.Helper.uuid() + '" ' +
'class="pkp_modal pkpModalWrapper" tabindex="-1"></div>')
.pkpHandler('$.pkp.controllers.modal.ConfirmationModalHandler', opts);
};
/**
* Update the enabled/disabled and checked state of the recommendOnly checkbox.
* @param {HTMLElement} sourceElement The element that
* issued the event.
* @param {Event} event The triggering event.
*/
$.pkp.controllers.grid.users.stageParticipant.form.
StageParticipantNotifyHandler.prototype.
updateSubmissionMetadataEditPermitOption =
function(sourceElement, event) {
var $form = this.getHtmlElement(),
$filterUserGroupId = $form.find('input[name=\'userGroupId\']'),
$checkbox = $form.find('input[id^=\'canChangeMetadata\']'),
$checkboxDiv = $form.find('.submissionEditMetadataPermit'),
i,
found = false,
filterUserGroupIdVal = /** @type {string} */ ($filterUserGroupId.val());
// If user group changes, hide the canChangeMetadata option
if ($(sourceElement).prop('name') == 'userGroupId') {
$checkbox.attr('disabled', 'disabled');
$checkbox.removeAttr('checked');
$checkboxDiv.hide();
} else if ($(sourceElement).prop('name') == 'userIdSelected' &&
!$checkboxDiv.is(':visible')) {
// Display canChangeMetadata option if
// an user group with a possible canChangeMetadata option is selected
for (i = 0; i < this.notChangeMetadataEditPermissionRoles_.length; i++) {
if (this.notChangeMetadataEditPermissionRoles_[i] ==
filterUserGroupIdVal) {
found = true;
break;
}
}
if (!found) {
$checkbox.removeAttr('disabled');
$checkboxDiv.show();
// Select the recommendOnly option if
// an user group with a recommendOnly option set is selected
for (i = 0; i < this.permitMetadataEditUserGroupIds_.length; i++) {
if (this.permitMetadataEditUserGroupIds_[i] == filterUserGroupIdVal) {
$checkbox.prop('checked', true);
break;
}
}
} else {
$checkbox.attr('disabled', 'disabled');
$checkboxDiv.hide();
}
}
};
/**
* Internal callback called after form validation to handle the
* response to a form submission.
*
* You can override this handler if you want to do custom handling
* of a form response.
*
* @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.stageParticipant.form.
StageParticipantNotifyHandler.prototype.handleResponse =
function(formElement, jsonData) {
// Reload the query grid to show the newly created query.
var $queries = $('#queriesGrid .pkp_controllers_grid');
if ($.pkp.classes.Handler.hasHandler($queries)) {
$.pkp.classes.Handler.getHandler($queries).trigger('dataChanged');
}
return /** @type {boolean} */ (this.parent(
'handleResponse', formElement, jsonData));
};
}(jQuery));