Bugzilla – Attachment 174617 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.09 KB, created by
Pedro Amorim
on 2024-11-15 16:45:00 UTC
(
hide
)
Description:
Bug 37301: Remove toToResource* methods to BaseResource
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-11-15 16:45:00 UTC
Size:
7.09 KB
patch
obsolete
>From e5cdcfc0cf5c85994c159f5736a5de8377aafc1e 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 701b1056cf..1c782bc44a 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 5442eee1ef..a05a0f028f 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 eabfdd3270..a7ffea17ff 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> >@@ -222,11 +222,6 @@ export default { > }) > }) > }, >- 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 d7c09ecf7e..81492dee62 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 d6c535284f..c6b28d2712 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.39.5
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