diff --git a/src/components/Container/Page.vue b/src/components/Container/Page.vue index d00f9a05..eb857f93 100644 --- a/src/components/Container/Page.vue +++ b/src/components/Container/Page.vue @@ -7,6 +7,7 @@ import ReviewerSubmissionPage from '@/pages/reviewerSubmission/ReviewerSubmissio import JobsPage from '@/pages/jobs/JobsPage.vue'; import FailedJobsPage from '@/pages/jobs/FailedJobsPage.vue'; import FailedJobDetailsPage from '@/pages/jobs/FailedJobDetailsPage.vue'; +import CounterReportsPage from '@/pages/counter/CounterReportsPage.vue'; export default { name: 'Page', @@ -17,6 +18,7 @@ export default { JobsPage, FailedJobsPage, FailedJobDetailsPage, + CounterReportsPage, }, extends: Container, data() { diff --git a/src/components/Form/Form.vue b/src/components/Form/Form.vue index 8946a24f..b46c24ee 100644 --- a/src/components/Form/Form.vue +++ b/src/components/Form/Form.vue @@ -17,7 +17,7 @@ :primary-locale-key="primaryLocale" :locales="availableLocales" :visible="visibleLocales" - @updateLocales="setVisibleLocales" + @update-locales="setVisibleLocales" />
    @@ -59,10 +59,10 @@ :available-locales="availableLocales" :is-saving="isSaving" @change="fieldChanged" - @pageSubmitted="nextPage" - @previousPage="setCurrentPage(false)" - @showField="showField" - @showLocale="showLocale" + @page-submitted="nextPage" + @previous-page="setCurrentPage(false)" + @show-field="showField" + @show-locale="showLocale" @cancel="cancel" @set-errors="setErrors" /> @@ -128,6 +128,10 @@ export default { visibleLocales: Array, /** The locale(s) supported by this form. If a form has multilingual fields, it will display a separate input control for each of these locales. */ supportedFormLocales: Array, + /** For custom AJAX call, while still keep the error handling within Form + * Async function, receiving data from form and returning {validationError, data} from useFetch + */ + customSubmit: Function, }, emits: [ /** When the form props need to be updated. The payload is an object with any keys that need to be modified. */ @@ -285,7 +289,7 @@ export default { /** * Submit the form */ - submit() { + async submit() { if (!this.canSubmit) { return false; } @@ -304,7 +308,17 @@ export default { return; } - if (this.action === 'emit') { + if (this.customSubmit) { + const {data, validationError} = await this.customSubmit( + this.submitValues, + ); + if (validationError) { + this.error({status: 400, responseJSON: validationError}); + } else if (data) { + this.success(data); + } + this.complete(); + } else if (this.action === 'emit') { this.$emit('success', this.submitValues); } else { $.ajax({ diff --git a/src/composables/useForm.js b/src/composables/useForm.js index 0656d076..843ee8fd 100644 --- a/src/composables/useForm.js +++ b/src/composables/useForm.js @@ -30,9 +30,13 @@ function mapFromSelectedToValue(selected) { return selected.map((iv) => iv.value); } -export function useForm(_form) { +export function useForm(_form, {customSubmit} = {}) { const form = ref(_form); + if (customSubmit) { + form.value.customSubmit = customSubmit; + } + function connectWithPayload(payload) { watch( payload, diff --git a/src/pages/counter/CounterReportsPage.vue b/src/pages/counter/CounterReportsPage.vue new file mode 100644 index 00000000..50dd0228 --- /dev/null +++ b/src/pages/counter/CounterReportsPage.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/pages/counter/components/CounterReportsEditModal.vue b/src/pages/counter/components/CounterReportsEditModal.vue new file mode 100644 index 00000000..a8f3b674 --- /dev/null +++ b/src/pages/counter/components/CounterReportsEditModal.vue @@ -0,0 +1,112 @@ + + + diff --git a/src/pages/counter/components/CounterReportsListPanel.vue b/src/pages/counter/components/CounterReportsListPanel.vue new file mode 100644 index 00000000..da0e2e17 --- /dev/null +++ b/src/pages/counter/components/CounterReportsListPanel.vue @@ -0,0 +1,84 @@ + + +