Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3193 Added user email templates to the discussion and grouped…
… user templates in the assign participant.
- Loading branch information
1 parent
2e9f5e0
commit 68a2a6e
Showing
6 changed files
with
217 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/** | ||
* @defgroup js_controllers_grid_queries | ||
*/ | ||
/** | ||
* @file js/controllers/grid/queries/QueryFormHandler.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 ReadQueryHandler | ||
* @ingroup js_controllers_grid_queries | ||
* | ||
* @brief Handler for a query form modal | ||
* | ||
*/ | ||
(function($) { | ||
|
||
/** @type {Object} */ | ||
$.pkp.controllers.grid.queries = | ||
$.pkp.controllers.grid.queries || {}; | ||
|
||
|
||
|
||
/** | ||
* @constructor | ||
* | ||
* @extends $.pkp.controllers.form.CancelActionAjaxFormHandler | ||
* | ||
* @param {jQueryObject} $form The query form element | ||
* @param {Object} options non-default Dialog options | ||
* to be passed into the dialog widget. | ||
* | ||
* Options are: | ||
* - all options documented for the CancelActionAjaxFormHandler. | ||
* - templateUrl: The URL to retrieve templates from. | ||
*/ | ||
$.pkp.controllers.grid.queries.QueryFormHandler = | ||
function($form, options) { | ||
this.parent($form, options); | ||
|
||
// Set the URL to retrieve templates from. | ||
if (options.templateUrl) { | ||
this.templateUrl_ = options.templateUrl; | ||
} | ||
|
||
this.textSubject_ = null; | ||
|
||
// Attach form elements events. | ||
$form.find('#template').change( | ||
this.callbackWrapper(this.selectTemplateHandler_)); | ||
}; | ||
$.pkp.classes.Helper.inherits($.pkp.controllers.grid.queries. | ||
QueryFormHandler, $.pkp.controllers.form.CancelActionAjaxFormHandler); | ||
|
||
|
||
// | ||
// Private properties | ||
// | ||
/** | ||
* The URL to use to retrieve template bodies | ||
* @private | ||
* @type {string?} | ||
*/ | ||
$.pkp.controllers.grid.queries. | ||
QueryFormHandler.prototype.templateUrl_ = 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.queries. | ||
QueryFormHandler.prototype.selectTemplateHandler_ = | ||
function(sourceElement, event) { | ||
var $form = this.getHtmlElement(); | ||
var template = $form.find('[name="template"]'); | ||
$form.find('[name="subject"]').val(template.find('option:selected').text()); | ||
this.textSubject_ | ||
$.post(this.templateUrl_, template.serialize(), | ||
this.callbackWrapper(this.updateTemplate), 'json'); | ||
}; | ||
|
||
|
||
// | ||
// Private methods | ||
// | ||
/** | ||
* 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.queries. | ||
QueryFormHandler.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="comment"]'), | ||
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; | ||
}; | ||
|
||
}(jQuery)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters