From a6974ff60a88a876c7243f85d25841e778c87840 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 11 Jul 2024 12:42:21 +0000 Subject: [PATCH] Bug 37301: PoC (Continuation): Add BaseResource and AgreementResource This is the building blocks for a much consistent approach, for example: AgreementsShow -> delete_agreement && AgreementsList -> doDelete should be DRY into AgreementResource Any WET code currently in setup for list+show of a resource can (and should) be moved into Resource Any WET code currently in setup for all 'resources' can (and should) be moved into BaseResource and others --- .../prog/js/vue/components/BaseResource.vue | 16 ++++++++++ .../vue/components/ERM/AgreementResource.vue | 30 +++++++++++++++++++ .../js/vue/components/ERM/AgreementsList.vue | 11 +++---- .../js/vue/components/ERM/AgreementsShow.vue | 11 +++---- 4 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue new file mode 100644 index 0000000000..701b1056cf --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue @@ -0,0 +1,16 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue new file mode 100644 index 0000000000..5442eee1ef --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue @@ -0,0 +1,30 @@ + 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 046d1c7f94..b47078d888 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 @@ -46,7 +46,7 @@ :searchable_additional_fields="searchable_additional_fields" :searchable_av_options="searchable_av_options" @show="doShow" - @edit="doEdit" + @edit="goToResourceEdit" @delete="doDelete" @select="doSelect" > @@ -66,8 +66,10 @@ import { APIClient } from "../../fetch/api-client.js" import { storeToRefs } from "pinia" import { build_url } from "../../composables/datatables" import KohaTable from "../KohaTable.vue" +import AgreementResource from "./AgreementResource.vue" export default { + extends: AgreementResource, setup() { const vendorStore = inject("vendorStore") const { vendors } = storeToRefs(vendorStore) @@ -85,6 +87,7 @@ export default { by_mine: false, }) return { + ...AgreementResource.setup(), vendors, get_lib_from_av, map_av_dt_filter, @@ -235,12 +238,6 @@ export default { params: { agreement_id }, }) }, - doEdit: function ({ agreement_id }, dt, event) { - this.$router.push({ - name: "AgreementsFormAddEdit", - params: { agreement_id }, - }) - }, doDelete: function (agreement, dt, event) { this.setConfirmationDialog( { 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 e31bd6e2eb..05ef5f252d 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 @@ -2,7 +2,7 @@
{{ $__("Loading") }}
- + @@ -332,8 +332,10 @@ import { APIClient } from "../../fetch/api-client.js" import Toolbar from "../Toolbar.vue" import ToolbarButton from "../ToolbarButton.vue" import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue" +import AgreementResource from "./AgreementResource.vue" export default { + extends: AgreementResource, setup() { const format_date = $date const patron_to_html = $patron_to_html @@ -344,6 +346,7 @@ export default { const { get_lib_from_av } = AVStore return { + ...AgreementResource.setup(), format_date, patron_to_html, get_lib_from_av, @@ -392,12 +395,6 @@ export default { error => {} ) }, - edit_agreement: function () { - this.$router.push({ - name: "AgreementsFormAddEdit", - params: { agreement_id: this.agreement.agreement_id }, - }) - }, delete_agreement: function () { let agreement_id = this.agreement.agreement_id let agreement_name = this.agreement.name -- 2.39.5