-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Submit Submission from Preview Page (#2118)
* Refactors status changing template logic to a new component `StatusChangeDropdown` * uses data-driven logic for improved reusability * Simplifies submission acceptance process * Accepting for review is no longer necessary; only opening for review * Adds the `StatusChangeDropdown` component to the preview, view, and review pages * Adds a check for status changes to draft and initially submitted submissions so that the interface changes accordingly * Draft submissions are redirected from the preview page to the view page * Initially Submitted submissions are redirected from the view page to the review page * Bonus: Adds scope attributes to `i18n` tags to prevent warnings about global scope Closes #2078
- Loading branch information
Showing
11 changed files
with
270 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<template> | ||
<q-btn-dropdown | ||
v-if="!statusChangingDisabledByRole && !statusChangingDisabledByState" | ||
:label="$t(`submission.toolbar.status_options`)" | ||
flat | ||
menu-anchor="bottom right" | ||
menu-self="top right" | ||
data-cy="status-dropdown" | ||
> | ||
<q-btn-group flat square class="column q-pa-sm" data-cy="decision_options"> | ||
<q-btn | ||
v-for="state in nextStates[submissionRef.status]" | ||
:key="state" | ||
v-bind="submissionStateButtons[state].attrs" | ||
:label="$t(`submission.action.${submissionStateButtons[state].action}`)" | ||
@click=" | ||
submissionStateButtons[state].action && | ||
confirmHandler(submissionStateButtons[state].action) | ||
" | ||
></q-btn> | ||
</q-btn-group> | ||
</q-btn-dropdown> | ||
</template> | ||
<script setup> | ||
import ConfirmStatusChangeDialog from "../dialogs/ConfirmStatusChangeDialog.vue" | ||
import { useQuasar } from "quasar" | ||
import { | ||
useStatusChangeControls, | ||
submissionStateButtons, | ||
} from "src/use/guiElements.js" | ||
import { toRef } from "vue" | ||
const { dialog } = useQuasar() | ||
const props = defineProps({ | ||
submission: { | ||
type: Object, | ||
default: null, | ||
}, | ||
}) | ||
const submissionRef = toRef(props, "submission") | ||
const { | ||
statusChangingDisabledByRole, | ||
statusChangingDisabledByState, | ||
nextStates, | ||
} = useStatusChangeControls(submissionRef) | ||
async function confirmHandler(action) { | ||
await new Promise((resolve) => { | ||
dirtyDialog(action) | ||
.onOk(function () { | ||
resolve(true) | ||
}) | ||
.onCancel(function () { | ||
resolve(false) | ||
}) | ||
}) | ||
{ | ||
return false | ||
} | ||
} | ||
function dirtyDialog(action) { | ||
return dialog({ | ||
component: ConfirmStatusChangeDialog, | ||
componentProps: { | ||
action: action, | ||
submissionId: props.submission.id, | ||
currentStatus: props.submission.status, | ||
}, | ||
}) | ||
} | ||
</script> |
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
Oops, something went wrong.