forked from pkp/ui-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp/pkp-lib#4787 reviewer adding from suggestion working
- Loading branch information
1 parent
566e22c
commit de574ac
Showing
8 changed files
with
262 additions
and
28 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
66 changes: 66 additions & 0 deletions
66
src/managers/ReviewerSuggestionManager/ReviewerSuggestionManager.vue
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,66 @@ | ||
<template v-if="reviewerSuggestionManagerStore.reviewerSuggestionsList?.length"> | ||
<div class="border border-light" data-cy="reviewer-sguuestion-manager"> | ||
<div class="flex items-center justify-between bg-default p-5"> | ||
<h3 class="text-2xl-bold uppercase text-heading"> | ||
{{ t('editor.submission.reviewerSuggestions') }} | ||
</h3> | ||
</div> | ||
<ul class="flex flex-col" role="list"> | ||
<li | ||
v-for="reviewerSuggestion in reviewerSuggestionManagerStore.reviewerSuggestionsList" | ||
:key="reviewerSuggestion.id" | ||
class="border-t border-light p-4 text-base-normal even:bg-tertiary" | ||
> | ||
<div class="flex items-center justify-between"> | ||
<div class="flex"> | ||
<div> | ||
<UserAvatar | ||
:user-id="reviewerSuggestion.id" | ||
:user-full-name="reviewerSuggestion.fullName" | ||
></UserAvatar> | ||
</div> | ||
<div class="ms-2 flex flex-col justify-center"> | ||
<div class="text-base-bold"> | ||
{{ reviewerSuggestion.fullName }} | ||
</div> | ||
<div class="text-sm-normal text-secondary"> | ||
{{ reviewerSuggestion.suggestionReason }} | ||
</div> | ||
</div> | ||
</div> | ||
<div> | ||
<DropdownActions | ||
:actions="reviewerSuggestionManagerStore.itemActions" | ||
:label="`${reviewerSuggestion.fullName} ${t('common.moreActions')}`" | ||
:display-as-ellipsis="true" | ||
@action=" | ||
(actionName) => | ||
reviewerSuggestionManagerStore[actionName]({ | ||
reviewerSuggestion: reviewerSuggestion, | ||
stageAssignmen, | ||
}) | ||
" | ||
/> | ||
</div> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import UserAvatar from '@/components/UserAvatar/UserAvatar.vue'; | ||
import {useLocalize} from '@/composables/useLocalize'; | ||
import {useReviewerSuggestionManagerStore} from './reviewerSuggestionManagerStore'; | ||
import DropdownActions from '@/components/DropdownActions/DropdownActions.vue'; | ||
const props = defineProps({ | ||
submission: {type: Object, required: true}, | ||
submissionStageId: {type: String, required: true}, | ||
reviewRoundId: {type: Number, required: true}, | ||
}); | ||
const reviewerSuggestionManagerStore = useReviewerSuggestionManagerStore(props); | ||
const {t} = useLocalize(); | ||
</script> |
91 changes: 91 additions & 0 deletions
91
src/managers/ReviewerSuggestionManager/reviewerSuggestionManagerStore.js
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,91 @@ | ||
import {defineComponentStore} from '@/utils/defineComponentStore'; | ||
|
||
import {ref, computed, watch} from 'vue'; | ||
|
||
import {useFetch} from '@/composables/useFetch'; | ||
import {useUrl} from '@/composables/useUrl'; | ||
|
||
import {useLocalize} from '@/composables/useLocalize'; | ||
import {useReviewerSuggestionManagerActions} from './useReviewerSuggestionManagerActions'; | ||
import {useDataChanged} from '@/composables/useDataChanged'; | ||
|
||
export const useReviewerSuggestionManagerStore = defineComponentStore( | ||
'reviewerSuggestionManager', | ||
(props) => { | ||
const {localize} = useLocalize(); | ||
|
||
const submissionId = ref(props.submission.id); | ||
|
||
const relativeUrl = computed(() => { | ||
return `submissions/${encodeURIComponent(submissionId.value)}/reviewers/suggestions?approved=false`; | ||
}); | ||
|
||
const {apiUrl: reviewerSuggestionApiUrl} = useUrl(relativeUrl); | ||
|
||
const {data: reviewerSuggestions, fetch: fetchreviewerSuggestion} = | ||
useFetch(reviewerSuggestionApiUrl); | ||
|
||
watch(relativeUrl, () => { | ||
reviewerSuggestions.value = null; | ||
fetchreviewerSuggestion(); | ||
}); | ||
|
||
fetchreviewerSuggestion(); | ||
|
||
const {triggerDataChange} = useDataChanged(() => fetchreviewerSuggestion()); | ||
|
||
function triggerDataChangeCallback() { | ||
triggerDataChange(); | ||
} | ||
|
||
const reviewerSuggestionsList = computed(() => { | ||
if (!reviewerSuggestions.value) { | ||
return []; | ||
} | ||
|
||
const list = []; | ||
|
||
reviewerSuggestions.value.items.forEach((reviewerSuggestion) => { | ||
list.push({ | ||
id: reviewerSuggestion.id, | ||
fullName: localize(reviewerSuggestion.fullName), | ||
affiliation: localize(reviewerSuggestion.affiliation), | ||
suggestionReason: localize(reviewerSuggestion.suggestionReason), | ||
}); | ||
}); | ||
|
||
return list; | ||
}); | ||
|
||
/** | ||
* Handling actions | ||
*/ | ||
|
||
const _actionFns = useReviewerSuggestionManagerActions(); | ||
|
||
const itemActions = computed(() => _actionFns.getItemActions({})); | ||
|
||
function enrichActionArg(args) { | ||
return { | ||
submissionStageId: props.submissionStageId, | ||
submission: props.submission, | ||
reviewRoundId: props.reviewRoundId, | ||
...args, | ||
}; | ||
} | ||
|
||
function reviewerSuggestionApprove({reviewerSuggestion}) { | ||
_actionFns.reviewerSuggestionApprove( | ||
enrichActionArg({reviewerSuggestion}), | ||
triggerDataChangeCallback, | ||
); | ||
} | ||
|
||
return { | ||
reviewerSuggestionsList, | ||
_actionFns, | ||
itemActions, | ||
reviewerSuggestionApprove, | ||
}; | ||
}, | ||
); |
50 changes: 50 additions & 0 deletions
50
src/managers/ReviewerSuggestionManager/useReviewerSuggestionManagerActions.js
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,50 @@ | ||
import {useLegacyGridUrl} from '@/composables/useLegacyGridUrl'; | ||
import {useLocalize} from '@/composables/useLocalize'; | ||
|
||
export const Actions = { | ||
REVIEWER_SUGGESTION_APPROVE: 'reviewerSuggestionApprove', | ||
}; | ||
|
||
export function useReviewerSuggestionManagerActions() { | ||
const {t} = useLocalize(); | ||
|
||
function reviewerSuggestionApprove( | ||
{submissionStageId, submission, reviewRoundId, reviewerSuggestion}, | ||
finishedCallback, | ||
) { | ||
const {openLegacyModal} = useLegacyGridUrl({ | ||
component: 'grid.users.reviewer.ReviewerGridHandler', | ||
op: 'showReviewerForm', | ||
params: { | ||
submissionId: submission.id, | ||
stageId: submissionStageId, | ||
reviewRoundId: reviewRoundId, | ||
selectionType: pkp.const.REVIEWER_SELECT_CREATE, | ||
reviewerSuggestionId: reviewerSuggestion.id, | ||
}, | ||
}); | ||
|
||
openLegacyModal( | ||
{title: t('editor.submission.addReviewer')}, | ||
finishedCallback, | ||
); | ||
} | ||
|
||
function getItemActions() { | ||
const {t} = useLocalize(); | ||
const actions = []; | ||
|
||
actions.push({ | ||
label: t('editor.submission.addReviewer'), | ||
name: Actions.REVIEWER_SUGGESTION_APPROVE, | ||
icon: 'Add', | ||
}); | ||
|
||
return actions; | ||
} | ||
|
||
return { | ||
getItemActions, | ||
reviewerSuggestionApprove, | ||
}; | ||
} |
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