Bugzilla – Attachment 168828 Details for
Bug 37301
Further improve how we build Vue components
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37301: Remove toToResource* methods to BaseResource
Bug-37301-Remove-toToResource-methods-to-BaseResou.patch (text/plain), 7.10 KB, created by
Jonathan Druart
on 2024-07-11 14:13:19 UTC
(
hide
)
Description:
Bug 37301: Remove toToResource* methods to BaseResource
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-07-11 14:13:19 UTC
Size:
7.10 KB
patch
obsolete
>From febaedb7a2af6a46b69e7a5ea4651ac7c6201cbf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 11 Jul 2024 15:55:38 +0200 >Subject: [PATCH] Bug 37301: Remove toToResource* methods to BaseResource > >--- > .../prog/js/vue/components/BaseResource.vue | 37 +++++++++++++++++-- > .../vue/components/ERM/AgreementResource.vue | 26 ++++--------- > .../js/vue/components/ERM/AgreementsList.vue | 7 +--- > .../js/vue/components/ERM/AgreementsShow.vue | 10 ++++- > .../prog/js/vue/components/ToolbarButton.vue | 11 ++++-- > 5 files changed, 58 insertions(+), 33 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 701b1056cf1..1c782bc44ab 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue >@@ -2,15 +2,46 @@ > import { inject } from "vue" > > export default { >- setup() { >+ setup(props) { > //global setup for all resource (list and show for now, but maybe others?) components here > const { setConfirmationDialog, setMessage, setError } = > inject("mainStore") >- return { setConfirmationDialog, setMessage, setError } >+ return { ...props, setConfirmationDialog, setMessage, setError } > }, > methods: { >- // goToResourceEdit: function () {}, >+ /** >+ * Navigates to the edit page of the given resource. >+ * >+ * @param {Object} resource - The resource to navigate to (optional) >+ * @return {void} >+ */ >+ goToResourceEdit: function (resource) { >+ this.$router.push({ >+ name: this.edit_component, >+ params: { >+ [this.id_attr]: resource >+ ? resource[this.id_attr] >+ : this[this.resource_name][this.id_attr], >+ }, >+ }) >+ }, >+ /** >+ * Navigates to the creation page of the given resource. >+ * >+ * @return {void} >+ */ >+ goToResourceAdd: function () { >+ this.$router.push({ >+ name: this.add_component, >+ }) >+ }, > }, > name: "BaseResource", >+ props: { >+ resource_name: String, >+ id_attr: String, >+ add_component: String, >+ edit_component: String, >+ }, > } > </script> >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 5442eee1efb..a05a0f028f8 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 >@@ -3,28 +3,18 @@ import BaseResource from "../BaseResource.vue" > > export default { > extends: BaseResource, >- setup() { >+ setup(props) { > return { >- ...BaseResource.setup(), >+ ...BaseResource.setup({ >+ resource_name: "agreement", >+ id_attr: "agreement_id", >+ add_component: "AgreementsFormAdd", >+ edit_component: "AgreementsFormAddEdit", >+ }), > //AgreementResource specific setup here > } > }, >- methods: { >- /** >- * Navigates to the edit page of the given agreement. >- * >- * @param {Object} agreement - The agreement to navigate to (optional) >- * @return {void} >- */ >- goToResourceEdit: function (agreement) { >- let agreement_id = >- agreement?.agreement_id || this.agreement.agreement_id >- this.$router.push({ >- name: "AgreementsFormAddEdit", >- params: { agreement_id: agreement_id }, >- }) >- }, >- }, >+ methods: {}, > name: "AgreementResource", > } > </script> >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 c14bf3eb210..d80577111f3 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 >@@ -4,7 +4,7 @@ > <Toolbar v-if="!embedded"> > <ToolbarButton > action="add" >- @addResource="add_agreement" >+ @go-to-add-resource="goToResourceAdd" > :title="$__('New agreement')" > /> > </Toolbar> >@@ -173,11 +173,6 @@ export default { > error => {} > ) > }, >- add_agreement: function () { >- this.$router.push({ >- name: "AgreementsFormAdd", >- }) >- }, > doShow: function ({ agreement_id }, dt, event) { > event.preventDefault() > this.$router.push({ >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 766269a99a9..ff415663023 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,8 +2,14 @@ > <div v-if="!initialized">{{ $__("Loading") }}</div> > <div v-else id="agreements_show"> > <Toolbar> >- <ToolbarButton action="edit" @editResource="goToResourceEdit" /> >- <ToolbarButton action="delete" @deleteResource="delete_agreement" /> >+ <ToolbarButton >+ action="edit" >+ @go-to-edit-resource="goToResourceEdit" >+ /> >+ <ToolbarButton >+ action="delete" >+ @delete_resource="delete_agreement" >+ /> > </Toolbar> > > <h2> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue >index d6c535284fc..c6b28d2712a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue >@@ -1,16 +1,19 @@ > <template> >- <a v-if="action === 'add'" @click="$emit('addResource')" :class="class" >+ <a >+ v-if="action === 'add'" >+ @click="$emit('go-to-add-resource')" >+ :class="class" > ><font-awesome-icon icon="plus" /> {{ title }}</a > > > <a > v-else-if="action === 'delete'" >- @click="$emit('deleteResource')" >+ @click="$emit('delete-resource')" > :class="class" > ><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a > > > <a > v-else-if="action === 'edit'" >- @click="$emit('editResource')" >+ @click="$emit('go-to-edit-resource')" > :class="class" > ><font-awesome-icon icon="pencil" /> {{ $__("Edit") }}</a > > >@@ -39,7 +42,7 @@ export default { > type: String, > }, > }, >- emits: ["addResource", "deleteResource", "editResource"], >+ emits: ["go-to-add-resource", "go-to-edit-resource", "delete-resource"], > name: "Toolbar", > } > </script> >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37301
:
168709
|
168739
|
168740
|
168741
|
168800
|
168827
|
168828
|
168829
|
168836
|
172713
|
172911
|
172912
|
172913
|
172914
|
172915
|
172916
|
172917
|
172918
|
172919
|
172920
|
172921
|
174612
|
174613
|
174614
|
174615
|
174616
|
174617
|
174618
|
174619
|
174620
|
174621
|
174622
|
174623
|
174624
|
174625
|
174626
|
174627
|
174628
|
174629
|
174630
|
174631