Skip to content

Commit 236bf61

Browse files
Merge branch 'main' into feat/forms-1331-event-stream
2 parents dce7251 + 5b8bd97 commit 236bf61

File tree

18 files changed

+3958
-1274
lines changed

18 files changed

+3958
-1274
lines changed

app/frontend/src/components/forms/ExportSubmissions.vue

Lines changed: 246 additions & 242 deletions
Large diffs are not rendered by default.

app/frontend/src/components/forms/FormSubmission.vue

Lines changed: 71 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
<script>
2-
import { mapActions, mapState } from 'pinia';
1+
<script setup>
2+
import { storeToRefs } from 'pinia';
33
import { useI18n } from 'vue-i18n';
4+
import { useRouter } from 'vue-router';
5+
import { computed, inject, onMounted, ref } from 'vue';
46
57
import AuditHistory from '~/components/forms/submission/AuditHistory.vue';
68
import DeleteSubmission from '~/components/forms/submission/DeleteSubmission.vue';
@@ -13,87 +15,77 @@ import { checkSubmissionUpdate } from '~/utils/permissionUtils';
1315
import { useFormStore } from '~/store/form';
1416
import { NotificationTypes } from '~/utils/constants';
1517
16-
export default {
17-
components: {
18-
AuditHistory,
19-
DeleteSubmission,
20-
FormViewer,
21-
NotesPanel,
22-
StatusPanel,
23-
PrintOptions,
24-
},
25-
inject: ['setWideLayout'],
26-
props: {
27-
submissionId: {
28-
type: String,
29-
required: true,
30-
},
31-
},
32-
setup() {
33-
const { locale } = useI18n({ useScope: 'global' });
18+
const { locale } = useI18n({ useScope: 'global' });
19+
const router = useRouter();
3420
35-
return { locale };
36-
},
37-
data() {
38-
return {
39-
isDraft: true,
40-
loading: true,
41-
reRenderSubmission: 0,
42-
submissionReadOnly: true,
43-
isWideLayout: false,
44-
};
45-
},
46-
computed: {
47-
...mapState(useFormStore, [
48-
'form',
49-
'formSubmission',
50-
'permissions',
51-
'isRTL',
52-
]),
53-
NOTIFICATIONS_TYPES() {
54-
return NotificationTypes;
55-
},
56-
},
57-
async mounted() {
58-
await this.fetchSubmission({ submissionId: this.submissionId });
59-
// get current user's permissions on associated form
60-
await this.getFormPermissionsForUser(this.form.id);
61-
this.loading = false;
62-
// set wide layout
63-
this.setWideLayout(this.isWideLayout);
21+
const setWideLayout = inject('setWideLayout');
22+
23+
const properties = defineProps({
24+
submissionId: {
25+
type: String,
26+
required: true,
6427
},
65-
methods: {
66-
...mapActions(useFormStore, [
67-
'fetchSubmission',
68-
'getFormPermissionsForUser',
69-
]),
70-
checkSubmissionUpdate: checkSubmissionUpdate,
71-
onDelete() {
72-
this.$router.push({
73-
name: 'FormSubmissions',
74-
query: {
75-
f: this.form.id,
76-
},
77-
});
78-
},
79-
refreshNotes() {
80-
this.$refs.notesPanel.getNotes();
81-
},
28+
});
8229
83-
setDraft(status) {
84-
this.isDraft = status === 'REVISING';
85-
},
86-
async toggleWideLayout() {
87-
this.isWideLayout = !this.isWideLayout;
88-
this.setWideLayout(this.isWideLayout);
89-
},
90-
async toggleSubmissionEdit(editing) {
91-
this.submissionReadOnly = !editing;
92-
this.reRenderSubmission += 1;
93-
await this.fetchSubmission({ submissionId: this.submissionId });
30+
const isDraft = ref(true);
31+
const loading = ref(true);
32+
const notesPanel = ref(null);
33+
const reRenderSubmission = ref(0);
34+
const submissionReadOnly = ref(true);
35+
const isWideLayout = ref(false);
36+
37+
const formStore = useFormStore();
38+
39+
const { form, formSubmission, permissions, isRTL } = storeToRefs(formStore);
40+
41+
const NOTIFICATIONS_TYPES = computed(() => NotificationTypes);
42+
43+
onMounted(async () => {
44+
await formStore.fetchSubmission({ submissionId: properties.submissionId });
45+
// get current user's permissions on associated form
46+
await formStore.getFormPermissionsForUser(form.value.id);
47+
loading.value = false;
48+
// set wide layout
49+
setWideLayout(isWideLayout.value);
50+
});
51+
52+
function onDelete() {
53+
router.push({
54+
name: 'FormSubmissions',
55+
query: {
56+
f: form.value.id,
9457
},
95-
},
96-
};
58+
});
59+
}
60+
61+
// TODO: This should be updated to an emit so we can test it
62+
function refreshNotes() {
63+
notesPanel.value.getNotes();
64+
}
65+
66+
function setDraft(status) {
67+
isDraft.value = status === 'REVISING';
68+
}
69+
70+
function toggleWideLayout() {
71+
isWideLayout.value = !isWideLayout.value;
72+
setWideLayout(isWideLayout.value);
73+
}
74+
75+
async function toggleSubmissionEdit(editing) {
76+
submissionReadOnly.value = !editing;
77+
reRenderSubmission.value += 1;
78+
await formStore.fetchSubmission({ submissionId: properties.submissionId });
79+
}
80+
81+
defineExpose({
82+
isDraft,
83+
onDelete,
84+
refreshNotes,
85+
setDraft,
86+
submissionReadOnly,
87+
toggleSubmissionEdit,
88+
});
9789
</script>
9890

9991
<template>

0 commit comments

Comments
 (0)