Bugzilla – Attachment 168800 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: PoC (Continuation): Add BaseResource and AgreementResource
Bug-37301-PoC-Continuation-Add-BaseResource-and-Ag.patch (text/plain), 6.46 KB, created by
Pedro Amorim
on 2024-07-11 12:45:55 UTC
(
hide
)
Description:
Bug 37301: PoC (Continuation): Add BaseResource and AgreementResource
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-07-11 12:45:55 UTC
Size:
6.46 KB
patch
obsolete
>From 12ba63eb5f4da98840e273df1ff07e515efe7a23 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >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 <resourceName>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 @@ >+<script> >+import { inject } from "vue" >+ >+export default { >+ setup() { >+ //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 } >+ }, >+ methods: { >+ // goToResourceEdit: function () {}, >+ }, >+ name: "BaseResource", >+} >+</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 >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 @@ >+<script> >+import BaseResource from "../BaseResource.vue" >+ >+export default { >+ extends: BaseResource, >+ setup() { >+ return { >+ ...BaseResource.setup(), >+ //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 }, >+ }) >+ }, >+ }, >+ 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 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" > ></KohaTable> >@@ -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 @@ > <div v-if="!initialized">{{ $__("Loading") }}</div> > <div v-else id="agreements_show"> > <Toolbar> >- <ToolbarButton action="edit" @editResource="edit_agreement" /> >+ <ToolbarButton action="edit" @editResource="goToResourceEdit" /> > <ToolbarButton action="delete" @deleteResource="delete_agreement" /> > </Toolbar> > >@@ -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
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
|
175450
|
177173
|
177174
|
177175
|
177176
|
177177
|
177178
|
177179
|
177180
|
177181
|
177182
|
177183
|
177184
|
177185
|
177186
|
177187
|
177188
|
177189
|
177190
|
177191
|
177192
|
177193
|
177351