Skip to content

Commit

Permalink
Merge pull request #489 from Vitaliy-1/i10480_submission_schema
Browse files Browse the repository at this point in the history
pkp/pkp-lib#10480 submission schema
  • Loading branch information
Vitaliy-1 authored Jan 24, 2025
2 parents 5d35187 + 70190a3 commit 40a27ec
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 149 deletions.
13 changes: 2 additions & 11 deletions src/composables/useSubmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,10 @@ export function useSubmission() {
return ['OpenReview', 'OpenReview'];
}

function getRecommendOnlyUserIdsForStage(submission, stageId) {
const stage = getStageById(submission, stageId);

return stage.stageAssignments
.filter((assignment) => assignment.recommendOnly)
.map((assignment) => assignment.userId);
}

function isDecisionAvailable(submission, decisionId) {
const stage = getActiveStage(submission);
return stage?.availableEditorialDecisions?.some(
(decision) => decision.id === decisionId,
return submission?.availableEditorialDecisions?.some(
(decision) => decision.id === decisionId && decision.stageId === stage.id,
);
}

Expand All @@ -268,7 +260,6 @@ export function useSubmission() {
getOpenReviewAssignmentsForRound,
getReviewMethodIcons,
InProgressReviewAssignmentStatuses,
getRecommendOnlyUserIdsForStage,
isDecisionAvailable,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class="flex flex-col border-t border-light p-4"
>
<p class="text-lg-normal text-default">
{{ currentRecommendation.label }}
{{ currentRecommendation }}
</p>
<span v-if="!showRecommendationActions" class="-ms-4 mt-2">
<PkpButton class="" is-link @click="showActions">
Expand All @@ -40,11 +40,10 @@
</template>
<script setup>
import PkpButton from '@/components/Button/Button.vue';
import {computed, ref, watch} from 'vue';
import {computed, ref} from 'vue';
import {useLocalize} from '@/composables/useLocalize';
import {useWorkflowStore} from '@/pages/workflow/workflowStore';
import {useUrl} from '@/composables/useUrl';
import {useFetch} from '@/composables/useFetch';
import {useSubmission} from '@/composables/useSubmission';
import {Actions as DecisionActions} from '../../composables/useWorkflowDecisions';
import {Actions as WorkflowActions} from '../../composables/useWorkflowActions';
Expand All @@ -58,21 +57,6 @@ const props = defineProps({
userId: {type: Number, required: true},
});
const RecommendOnlyDecisions = [
// EXTERNAL REVIEW
pkp.const.DECISION_RECOMMEND_ACCEPT,
pkp.const.DECISION_RECOMMEND_DECLINE,
pkp.const.DECISION_RECOMMEND_PENDING_REVISIONS,
pkp.const.DECISION_RECOMMEND_RESUBMIT,
// INTERNAL REVIEW
pkp.const.DECISION_RECOMMEND_ACCEPT_INTERNAL,
pkp.const.DECISION_RECOMMEND_PENDING_REVISIONS_INTERNAL,
pkp.const.RECOMMEND_RESUBMIT_INTERNAL,
pkp.const.RECOMMEND_DECLINE_INTERNAL,
pkp.const.RECOMMEND_EXTERNAL_REVIEW,
];
const explicitelyShowRecommendationActions = ref(false);
const isDecidingEditorAssigned = computed(() => {
Expand All @@ -88,7 +72,7 @@ const showRecommendationActions = computed(() => {
return true;
}
if (!isLoading.value && !currentRecommendation.value) {
if (!currentRecommendation.value) {
return true;
}
Expand Down Expand Up @@ -145,42 +129,16 @@ const actionItems = computed(() => {
return getRecommendationActions();
});
const {apiUrl: recommendationApiUrl} = useUrl(
// TODO improve url when the query params are available
`submissions/${props.submission?.id}/decisions`,
);
const {
data: recommendations,
fetch: fetchRecommendations,
isLoading,
} = useFetch(recommendationApiUrl);
fetchRecommendations();
watch(props, () => fetchRecommendations());
const {getStageById} = useSubmission();
const currentRecommendation = computed(() => {
if (!recommendations) {
return null;
}
const selectedStage = getStageById(props.submission, props.stageId);
let recommendationsFromLatest = [...recommendations.value].reverse();
const myLastRecommendation = recommendationsFromLatest.find(
(recommendation) => {
return (
recommendation.editorId === props.userId &&
recommendation.reviewRoundId === props.reviewRoundId &&
RecommendOnlyDecisions.includes(recommendation.decision)
);
},
);
if (myLastRecommendation) {
return {label: myLastRecommendation.label};
} else {
if (!selectedStage?.currentUserRecommendation) {
return null;
}
return selectedStage.currentUserRecommendation.label;
});
const workflowStore = useWorkflowStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
aria-hidden="true"
/>
<span class="ms-1 text-base-normal">{{ statusProps.label }}</span>
<span class="ms-4 text-lg-bold">
<span class="ms-6 text-lg-bold">
{{ t('semicolon', {label: t('admin.version')}) }}
</span>
<span class="text-base-normal">
<span class="ms-2 text-base-normal">
{{ selectedPublication.version }}
</span>
<span class="ms-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<template>
<div
v-if="!isLoading && currentRecommendations"
class="w-full border border-light"
>
<div v-if="currentRecommendations" class="w-full border border-light">
<div class="p-4">
<h2 class="uppercase text-heading">
{{ t('editor.submission.recommendation') }}
Expand All @@ -16,10 +13,8 @@
</div>
</template>
<script setup>
import {computed, watch} from 'vue';
import {computed} from 'vue';
import {useLocalize} from '@/composables/useLocalize';
import {useUrl} from '@/composables/useUrl';
import {useFetch} from '@/composables/useFetch';
import {useSubmission} from '@/composables/useSubmission';
const {t} = useLocalize();
Expand All @@ -30,67 +25,17 @@ const props = defineProps({
stageId: {type: Number, required: true},
});
const RecommendOnlyDecisions = [
// EXTERNAL REVIEW
pkp.const.DECISION_RECOMMEND_ACCEPT,
pkp.const.DECISION_RECOMMEND_DECLINE,
pkp.const.DECISION_RECOMMEND_PENDING_REVISIONS,
pkp.const.DECISION_RECOMMEND_RESUBMIT,
// INTERNAL REVIEW
pkp.const.DECISION_RECOMMEND_ACCEPT_INTERNAL,
pkp.const.DECISION_RECOMMEND_PENDING_REVISIONS_INTERNAL,
pkp.const.RECOMMEND_RESUBMIT_INTERNAL,
pkp.const.RECOMMEND_DECLINE_INTERNAL,
pkp.const.RECOMMEND_EXTERNAL_REVIEW,
];
const {apiUrl: recommendationApiUrl} = useUrl(
// TODO improve url when the query params are available
`submissions/${props.submission.id}/decisions`,
);
const {
data: recommendations,
fetch: fetchRecommendations,
isLoading,
} = useFetch(recommendationApiUrl);
fetchRecommendations();
watch(props, () => fetchRecommendations());
const {getStageById} = useSubmission();
const currentRecommendations = computed(() => {
if (!recommendations.value) {
return '';
}
const selectedStage = getStageById(props.submission, props.stageId);
let recommendationsFromLatest = [...recommendations.value].reverse();
const {getRecommendOnlyUserIdsForStage} = useSubmission(
props.submission,
props.stageId,
);
const recommendOnlyEditorIds = getRecommendOnlyUserIdsForStage(
props.submission,
props.stageId,
);
const recommendationLabels = recommendOnlyEditorIds
.map((editorId) => {
return recommendationsFromLatest.find(
(recommendation) =>
recommendation.editorId === editorId &&
recommendation.reviewRoundId === props.reviewRoundId &&
RecommendOnlyDecisions.includes(recommendation.decision),
);
})
.filter((recommendation) => !!recommendation)
.map((recommendation) => recommendation.label);
if (recommendationLabels.length === 0) {
if (!selectedStage?.recommendations?.length) {
return '';
}
return recommendationLabels.join(t('common.commaListSeparator'));
return selectedStage.recommendations
.map((recommendation) => recommendation.label)
.join(t('common.commaListSeparator'));
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,8 @@ export const WorkflowConfig = {
return [];
}

// TODO add isDecidingEditor boolean to api to make it more accurate
const selectedStage = getStageById(submission, selectedStageId);
const isRecommendOnlyEditor = selectedStage.currentUserCanRecommendOnly;
if (!isRecommendOnlyEditor) {
if (selectedStage?.isCurrentUserDecidingEditor) {
items.push({
component: 'WorkflowRecommendOnlyListingRecommendations',
props: {
Expand All @@ -312,6 +310,7 @@ export const WorkflowConfig = {
},
});
}

items.push({
component: 'ParticipantManager',
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,8 @@ export const WorkflowConfig = {
return [];
}

// TODO add isDecidingEditor boolean to api to make it more accurate
const selectedStage = getStageById(submission, selectedStageId);
const isRecommendOnlyEditor = selectedStage.currentUserCanRecommendOnly;
if (!isRecommendOnlyEditor) {
if (selectedStage?.isCurrentUserDecidingEditor) {
items.push({
component: 'WorkflowRecommendOnlyListingRecommendations',
props: {
Expand All @@ -236,6 +234,7 @@ export const WorkflowConfig = {
},
});
}

items.push({
component: 'ParticipantManager',
props: {
Expand Down
17 changes: 2 additions & 15 deletions src/pages/workflow/composables/useWorkflowPermissions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {computed} from 'vue';
import {useSubmission} from '@/composables/useSubmission';
import {EditorialRoles, useCurrentUser} from '@/composables/useCurrentUser';
import {EditorialRoles} from '@/composables/useCurrentUser';

function hasIntersection(arr1, arr2) {
const set = new Set(arr1);
Expand All @@ -9,7 +9,6 @@ function hasIntersection(arr1, arr2) {

export function useWorkflowPermissions({submission, selectedPublication}) {
const {getActiveStage, getStageById} = useSubmission();
const {hasCurrentUserAtLeastOneRole} = useCurrentUser();

const permissions = computed(() => {
// View title, metadata, etc.
Expand Down Expand Up @@ -49,19 +48,7 @@ export function useWorkflowPermissions({submission, selectedPublication}) {
}
});

// TODO this will be replaced by with one flag from backend
productionStage.stageAssignments
.filter(
(stageAssignment) => stageAssignment.userId === pkp.currentUser.id,
)
.forEach((stageAssignment) => {
if (stageAssignment.canChangeMetadata) {
canEditPublication = true;
}
});
if (hasCurrentUserAtLeastOneRole([pkp.const.ROLE_ID_MANAGER])) {
canEditPublication = true;
}
canEditPublication = submission.value.canCurrentUserChangeMetadata;

if (
selectedPublication.value &&
Expand Down

0 comments on commit 40a27ec

Please sign in to comment.