From 1c9b8ea45a52b336c65ebb59decee9966ba7d38d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 11 Jul 2024 16:12:07 +0200 Subject: [PATCH] Bug 37301: Add goToResourceShow to BaseResource --- .../prog/js/vue/components/BaseResource.vue | 15 +++++++++++++++ .../js/vue/components/ERM/AgreementResource.vue | 1 + .../prog/js/vue/components/ERM/AgreementsList.vue | 9 +-------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue index 1c782bc44ab..e5ceb80752c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue @@ -9,6 +9,20 @@ export default { return { ...props, setConfirmationDialog, setMessage, setError } }, methods: { + /** + * Navigates to the show page of the given resource. + * + * @param {Object} resource - The resource to navigate to + * @return {void} + */ + goToResourceShow: function (resource, dt, event) { + event?.preventDefault() + this.$router.push({ + name: this.show_component, + params: { [this.id_attr]: resource[this.id_attr] }, + }) + }, + /** * Navigates to the edit page of the given resource. * @@ -40,6 +54,7 @@ export default { props: { resource_name: String, id_attr: String, + show_component: String, add_component: String, edit_component: String, }, 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 index a05a0f028f8..88025188146 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue @@ -8,6 +8,7 @@ export default { ...BaseResource.setup({ resource_name: "agreement", id_attr: "agreement_id", + show_component: "AgreementsShow", add_component: "AgreementsFormAdd", edit_component: "AgreementsFormAddEdit", }), 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 a7ffea17ff7..9fc9b3643d4 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 @@ -45,7 +45,7 @@ v-bind="tableOptions" :searchable_additional_fields="searchable_additional_fields" :searchable_av_options="searchable_av_options" - @show="doShow" + @show="goToResourceShow" @edit="goToResourceEdit" @delete="doDelete" @select="doSelect" @@ -222,13 +222,6 @@ export default { }) }) }, - doShow: function ({ agreement_id }, dt, event) { - event.preventDefault() - this.$router.push({ - name: "AgreementsShow", - params: { agreement_id }, - }) - }, doDelete: function (agreement, dt, event) { this.setConfirmationDialog( { -- 2.39.5