From 08ce593bd95d00a40ca15f0d1bdcc298bde8b9e5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 11 May 2022 15:24:20 +0200 Subject: [PATCH] Bug 32030: Use fetch.js, improve messages handling, remove top level modules Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../vue/components/ERM/AgreementLicenses.vue | 17 +----- .../vue/components/ERM/AgreementPeriods.vue | 4 +- .../vue/components/ERM/AgreementUserRoles.vue | 34 ++++------- .../vue/components/ERM/AgreementsFormAdd.vue | 12 ++-- .../ERM/AgreementsFormConfirmDelete.vue | 22 ++----- .../js/vue/components/ERM/AgreementsList.vue | 54 ++++++----------- .../js/vue/components/ERM/AgreementsShow.vue | 4 -- .../prog/js/vue/components/ERM/Dialog.vue | 8 +-- .../prog/js/vue/components/ERM/ERMMain.vue | 23 ++------ .../js/vue/components/ERM/LicensesFormAdd.vue | 14 ++--- .../ERM/LicensesFormConfirmDelete.vue | 19 ++---- .../js/vue/components/ERM/LicensesList.vue | 31 +++++----- .../js/vue/components/ERM/LicensesShow.vue | 5 -- koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js | 59 +++++++++++++++++-- .../intranet-tmpl/prog/js/vue/main-erm.ts | 7 +++ .../intranet-tmpl/prog/js/vue/messages.js | 19 ++++++ koha-tmpl/intranet-tmpl/prog/js/vue/routes.js | 8 +-- .../intranet-tmpl/prog/js/vue/stores/main.js | 20 +++++-- 18 files changed, 177 insertions(+), 183 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/messages.js diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementLicenses.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementLicenses.vue index 70a7d50c06..b59838f01d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementLicenses.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementLicenses.vue @@ -102,6 +102,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue index 933ad302f5..4733576c2b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue @@ -201,7 +201,7 @@ import AgreementUserRoles from './AgreementUserRoles.vue' import AgreementLicenses from './AgreementLicenses.vue' import { useVendorStore } from "../../stores/vendors" import { useAVStore } from "../../stores/authorised_values" -import { useMainStore } from "../../stores/main" +import { setMessage, setError } from "../../messages" import { fetchAgreement } from '../../fetch' import { storeToRefs } from "pinia" @@ -219,9 +219,6 @@ export default { av_agreement_license_location, } = storeToRefs(AVStore) - const mainStore = useMainStore() - const { setMessage, setError, resetMessages } = mainStore - return { vendors, av_agreement_statuses, @@ -230,7 +227,6 @@ export default { av_agreement_user_roles, av_agreement_license_statuses, av_agreement_license_location, - setMessage, setError, resetMessages, } }, data() { @@ -306,12 +302,12 @@ export default { .then(response => { if (response.status == 200) { this.$router.push("/cgi-bin/koha/erm/agreements") - this.setMessage('Agreement updated') + setMessage('Agreement updated') } else if (response.status == 201) { this.$router.push("/cgi-bin/koha/erm/agreements") - this.setMessage('Agreement created') + setMessage('Agreement created') } else { - this.setError(response.message || response.statusText) + setError(response.message || response.statusText) } }).catch( (error) => { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue index 02346a0dc2..160683a6e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue @@ -36,17 +36,10 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue index d536255737..c195444d26 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue @@ -1,6 +1,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue index d96a29af9b..7e751a5d5f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue @@ -185,7 +185,6 @@ import AgreementPeriods from './AgreementPeriods.vue' import AgreementUserRoles from './AgreementUserRoles.vue' import { useVendorStore } from "../../stores/vendors" import { useAVStore } from "../../stores/authorised_values" -import { useMainStore } from "../../stores/main" import { fetchAgreement } from "../../fetch" import { storeToRefs } from "pinia" @@ -212,8 +211,6 @@ export default { av_agreement_license_location, } = storeToRefs(AVStore) - const mainStore = useMainStore() - const { setError } = mainStore return { format_date, patron_to_html, @@ -225,7 +222,6 @@ export default { av_agreement_user_roles, av_agreement_license_statuses, av_agreement_license_location, - setError, } }, data() { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Dialog.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Dialog.vue index ba665d5c6e..be910a4e12 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Dialog.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Dialog.vue @@ -5,17 +5,13 @@ \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue index 4a8e3cf630..f9e8f41e78 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue @@ -4,6 +4,7 @@
+
@@ -41,9 +42,10 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue index 8f3dda8f05..880e4847bd 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue @@ -118,7 +118,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue index 8908c78792..23a95b8bf3 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue @@ -55,7 +55,6 @@