|
2 | 2 | <FieldOptions
|
3 | 3 | :is-required="false"
|
4 | 4 | component="field-options"
|
5 |
| - :all-errors="{}" |
6 | 5 | name="reviewTypes"
|
7 | 6 | :label="t('reviewer.reviewTypes')"
|
8 | 7 | type="radio"
|
9 | 8 | :options="options"
|
| 9 | + :all-errors="sectionErrors" |
10 | 10 | @change="
|
11 | 11 | (fieldName, propName, newValue, localeKey) =>
|
12 | 12 | updateReviewDetails(index, fieldName, newValue)
|
|
19 | 19 | input-type="date"
|
20 | 20 | :is-required="true"
|
21 | 21 | value=""
|
22 |
| - :all-errors="{}" |
| 22 | + :all-errors="sectionErrors" |
23 | 23 | @change="
|
24 | 24 | (fieldName, propName, newValue, localeKey) =>
|
25 | 25 | updateReviewDetails(index, fieldName, newValue)
|
|
31 | 31 | input-type="date"
|
32 | 32 | :is-required="true"
|
33 | 33 | value=""
|
34 |
| - :all-errors="{}" |
| 34 | + :all-errors="sectionErrors" |
35 | 35 | @change="
|
36 | 36 | (fieldName, propName, newValue, localeKey) =>
|
37 | 37 | updateReviewDetails(index, fieldName, newValue)
|
|
40 | 40 | </div>
|
41 | 41 | </template>
|
42 | 42 | <script setup>
|
43 |
| -import {defineProps} from 'vue'; |
| 43 | +import {defineProps, computed} from 'vue'; |
44 | 44 | import FieldOptions from '@/components/Form/fields/FieldOptions.vue';
|
45 | 45 | import FieldText from '@/components/Form/fields/FieldText.vue';
|
46 | 46 | import {useLocalize} from '@/composables/useLocalize';
|
47 | 47 | import {useUserInvitationPageStore} from './UserInvitationPageStore';
|
48 | 48 |
|
49 |
| -defineProps({ |
50 |
| - validateFields: { |
51 |
| - type: Array, |
52 |
| - default() { |
53 |
| - return null; |
54 |
| - }, |
55 |
| - }, |
| 49 | +const props = defineProps({ |
| 50 | + validateFields: {type: Array, required: true}, |
56 | 51 | });
|
57 | 52 |
|
58 | 53 | const store = useUserInvitationPageStore();
|
59 | 54 | const {t} = useLocalize();
|
60 | 55 | const options = [
|
61 |
| - {value: 'anonymus', label: 'Anonymus Reviewer / Anonymus Author'}, |
62 |
| - {value: 'disclosed', label: 'Anonymus Reviewer / Disclosed Author'}, |
63 |
| - {value: 'open', label: 'open'}, |
| 56 | + { |
| 57 | + value: 'anonymus', |
| 58 | + label: t('reviewerInvitation.reviewTypes.anonymusAuthorOrReviewer'), |
| 59 | + }, |
| 60 | + { |
| 61 | + value: 'disclosed', |
| 62 | + label: t('reviewerInvitation.reviewTypes.disclosedAuthor'), |
| 63 | + }, |
| 64 | + {value: 'open', label: t('reviewerInvitation.reviewTypes.open')}, |
64 | 65 | ];
|
65 | 66 |
|
| 67 | +props.validateFields.forEach((field) => { |
| 68 | + store.updatePayload(field, '', false); |
| 69 | +}); |
| 70 | +
|
66 | 71 | function updateReviewDetails(index, fieldName, newValue) {
|
| 72 | + delete store.errors[fieldName]; |
67 | 73 | store.updatePayload(fieldName, newValue, false);
|
68 | 74 | }
|
| 75 | +
|
| 76 | +const sectionErrors = computed(() => { |
| 77 | + return props.validateFields.reduce((obj, key) => { |
| 78 | + if (store.errors[key]) { |
| 79 | + obj[key] = store.errors[key]; |
| 80 | + } |
| 81 | + return obj; |
| 82 | + }, {}); |
| 83 | +}); |
69 | 84 | </script>
|
0 commit comments