From 12ba63eb5f4da98840e273df1ff07e515efe7a23 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 07d3e5c7ba..f291e5dddb 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 @@ -44,7 +44,7 @@ ref="table" v-bind="tableOptions" @show="doShow" - @edit="doEdit" + @edit="goToResourceEdit" @delete="doDelete" @select="doSelect" > @@ -64,8 +64,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) @@ -83,6 +85,7 @@ export default { by_mine: false, }) return { + ...AgreementResource.setup(), vendors, get_lib_from_av, map_av_dt_filter, @@ -186,12 +189,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 75b8cd7230..ce7cdc3ad4 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") }}
- + @@ -325,8 +325,10 @@ import { inject } from "vue" import { APIClient } from "../../fetch/api-client.js" import Toolbar from "../Toolbar.vue" import ToolbarButton from "../ToolbarButton.vue" +import AgreementResource from "./AgreementResource.vue" export default { + extends: AgreementResource, setup() { const format_date = $date const patron_to_html = $patron_to_html @@ -337,6 +339,7 @@ export default { const { get_lib_from_av } = AVStore return { + ...AgreementResource.setup(), format_date, patron_to_html, get_lib_from_av, @@ -383,12 +386,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.34.1