Skip to content

Commit

Permalink
Merge pull request #2710 from NateWr/i2708_js_constants
Browse files Browse the repository at this point in the history
#2708 Pass constants with JS handler configuration
  • Loading branch information
NateWr authored Aug 28, 2017
2 parents 8e15ed1 + b4bd85b commit 38e5135
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 22 deletions.
4 changes: 3 additions & 1 deletion classes/services/PKPSubmissionService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import('lib.pkp.classes.db.DBResultRange');

define('STAGE_STATUS_SUBMISSION_UNASSIGNED', 1);

abstract class PKPSubmissionService {

/**
Expand Down Expand Up @@ -497,7 +499,7 @@ public function toArrayStageDetails($submission, $stageIds = null) {
$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
$assignedEditors = $stageAssignmentDao->editorAssignedToStage($submission->getId(), $stageId);
if (!$assignedEditors) {
$stage['statusId'] = 1; // @todo this should be abstracted to a documented constant
$stage['statusId'] = STAGE_STATUS_SUBMISSION_UNASSIGNED;
$stage['status'] = __('submissions.queuedUnassigned');
}

Expand Down
25 changes: 25 additions & 0 deletions controllers/list/submissions/PKPSubmissionsListHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,31 @@ public function getConfig() {
// Attach a CSRF token for post requests
$config['csrfToken'] = $request->getSession()->getCSRFToken();

// Provide required constants
import('lib.pkp.classes.submission.reviewRound.ReviewRound');
import('lib.pkp.classes.submission.reviewAssignment.ReviewAssignment');
$config['_constants'] = array(
'WORKFLOW_STAGE_ID_SUBMISSION' => WORKFLOW_STAGE_ID_SUBMISSION,
'WORKFLOW_STAGE_ID_INTERNAL_REVIEW' => WORKFLOW_STAGE_ID_INTERNAL_REVIEW,
'WORKFLOW_STAGE_ID_EXTERNAL_REVIEW' => WORKFLOW_STAGE_ID_EXTERNAL_REVIEW,
'WORKFLOW_STAGE_ID_EDITING' => WORKFLOW_STAGE_ID_EDITING,
'WORKFLOW_STAGE_ID_PRODUCTION' => WORKFLOW_STAGE_ID_PRODUCTION,
'STAGE_STATUS_SUBMISSION_UNASSIGNED' => STAGE_STATUS_SUBMISSION_UNASSIGNED,
'REVIEW_ROUND_STATUS_PENDING_REVIEWERS' => REVIEW_ROUND_STATUS_PENDING_REVIEWERS,
'REVIEW_ROUND_STATUS_REVIEWS_READY' => REVIEW_ROUND_STATUS_REVIEWS_READY,
'REVIEW_ROUND_STATUS_REVIEWS_COMPLETED' => REVIEW_ROUND_STATUS_REVIEWS_COMPLETED,
'REVIEW_ROUND_STATUS_REVIEWS_OVERDUE' => REVIEW_ROUND_STATUS_REVIEWS_OVERDUE,
'REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED' => REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED,
'REVIEW_ROUND_STATUS_REVISIONS_REQUESTED' => REVIEW_ROUND_STATUS_REVISIONS_REQUESTED,
'REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE' => REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE,
'REVIEW_ASSIGNMENT_STATUS_RESPONSE_OVERDUE' => REVIEW_ASSIGNMENT_STATUS_RESPONSE_OVERDUE,
'REVIEW_ASSIGNMENT_STATUS_REVIEW_OVERDUE' => REVIEW_ASSIGNMENT_STATUS_REVIEW_OVERDUE,
'REVIEW_ASSIGNMENT_STATUS_ACCEPTED' => REVIEW_ASSIGNMENT_STATUS_ACCEPTED,
'REVIEW_ASSIGNMENT_STATUS_RECEIVED' => REVIEW_ASSIGNMENT_STATUS_RECEIVED,
'REVIEW_ASSIGNMENT_STATUS_COMPLETE' => REVIEW_ASSIGNMENT_STATUS_COMPLETE,
'REVIEW_ASSIGNMENT_STATUS_THANKED' => REVIEW_ASSIGNMENT_STATUS_THANKED,
);

return $config;
}

Expand Down
7 changes: 6 additions & 1 deletion js/classes/VueRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ var VueRegistry = {
*/
init: function(id, type, data) {

if (typeof pkp.controllers[type] === 'undefined' ) {
if (pkp.controllers[type] === undefined ) {
console.log('No Vue of the type ' + type + ' could be found.');
return;
}

if (data._constants !== undefined) {
Object.assign(pkp.const, data._constants);
delete data._constants;
}

var args = _.extend({}, pkp.controllers[type],
{
el: '#' + id,
Expand Down
40 changes: 20 additions & 20 deletions js/controllers/list/submissions/SubmissionsListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ export default {
// Notices for journal managers
if (pkp.userHasRole('manager')) {
if (this.activeStage.id === 1) {
if (this.activeStage.id === pkp.const.WORKFLOW_STAGE_ID_SUBMISSION) {
switch (this.activeStage.statusId) {
case 1: // @todo this should be a global
case pkp.const.STAGE_STATUS_SUBMISSION_UNASSIGNED:
// Only display unassigned notice for completed submissions
if (this.item.submissionProgress === 0) {
notice = this.activeStage.status;
Expand All @@ -204,11 +204,11 @@ export default {
if (pkp.userHasRole(['manager', 'subeditor'])) {
if (this.isReviewStage) {
switch (this.activeStage.statusId) {
case 6: // REVIEW_ROUND_STATUS_PENDING_REVIEWERS
case 8: // REVIEW_ROUND_STATUS_REVIEWS_READY
case 9: // REVIEW_ROUND_STATUS_REVIEWS_COMPLETED
case 10: // REVIEW_ROUND_STATUS_REVIEWS_OVERDUE
case 11: // REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED
case pkp.const.REVIEW_ROUND_STATUS_PENDING_REVIEWERS:
case pkp.const.REVIEW_ROUND_STATUS_REVIEWS_READY:
case pkp.const.REVIEW_ROUND_STATUS_REVIEWS_COMPLETED:
case pkp.const.REVIEW_ROUND_STATUS_REVIEWS_OVERDUE:
case pkp.const.REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED:
notice = this.activeStage.status;
break;
}
Expand All @@ -219,7 +219,7 @@ export default {
if (pkp.userHasRole(['author'])) {
if (this.isReviewStage) {
switch (this.activeStage.statusId) {
case 1: // REVIEW_ROUND_STATUS_REVISIONS_REQUESTED
case pkp.const.REVIEW_ROUND_STATUS_REVISIONS_REQUESTED:
notice = this.activeStage.status;
break;
}
Expand All @@ -229,9 +229,9 @@ export default {
// Notices for reviewers
if (this.currentUserIsReviewer) {
switch (this.currentUserLatestReviewAssignment.statusId) {
case 0: // REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE
case 4: // REVIEW_ASSIGNMENT_STATUS_RESPONSE_OVERDUE
case 6: // REVIEW_ASSIGNMENT_STATUS_REVIEW_OVERDUE
case pkp.const.REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE:
case pkp.const.REVIEW_ASSIGNMENT_STATUS_RESPONSE_OVERDUE:
case pkp.const.REVIEW_ASSIGNMENT_STATUS_REVIEW_OVERDUE:
notice = this.currentUserLatestReviewAssignment.status;
break;
}
Expand Down Expand Up @@ -260,7 +260,7 @@ export default {
* @return bool
*/
isReviewStage: function() {
return this.activeStage.id === 2 || this.activeStage.id === 3;
return this.activeStage.id === pkp.const.WORKFLOW_STAGE_ID_INTERNAL_REVIEW || this.activeStage.id === pkp.const.WORKFLOW_STAGE_ID_EXTERNAL_REVIEW;
},
/**
Expand Down Expand Up @@ -303,20 +303,20 @@ export default {
switch (latest.statusId) {
case 0: // REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE
case 4: // REVIEW_ASSIGNMENT_STATUS_RESPONSE_OVERDUE
case pkp.const.REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE:
case pkp.const.REVIEW_ASSIGNMENT_STATUS_RESPONSE_OVERDUE:
latest.responsePending = true;
latest.reviewPending = true;
break;
case 5: // REVIEW_ASSIGNMENT_STATUS_ACCEPTED
case 6: // REVIEW_ASSIGNMENT_STATUS_REVIEW_OVERDUE
case pkp.const.REVIEW_ASSIGNMENT_STATUS_ACCEPTED:
case pkp.const.REVIEW_ASSIGNMENT_STATUS_REVIEW_OVERDUE:
latest.reviewPending = true;
break;
case 7: // REVIEW_ASSIGNMENT_STATUS_RECEIVED
case 8: // REVIEW_ASSIGNMENT_STATUS_COMPLETE
case 9: // REVIEW_ASSIGNMENT_STATUS_THANKED
case pkp.const.REVIEW_ASSIGNMENT_STATUS_RECEIVED:
case pkp.const.REVIEW_ASSIGNMENT_STATUS_COMPLETE:
case pkp.const.REVIEW_ASSIGNMENT_STATUS_THANKED:
latest.reviewComplete = true;
break;
}
Expand All @@ -334,7 +334,7 @@ export default {
return 0;
}
return _.filter(this.currentReviewAssignments, function(review) {
return review.statusId >= 7; // REVIEW_ASSIGNMENT_STATUS_RECEIVED and above
return review.statusId >= pkp.const.REVIEW_ASSIGNMENT_STATUS_RECEIVED;
}).length;
},
Expand Down

0 comments on commit 38e5135

Please sign in to comment.