Bugzilla – Attachment 174138 Details for
Bug 38010
Migrate vendors to Vue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38010: Add basket page
Bug-38010-Add-basket-page.patch (text/plain), 17.02 KB, created by
Matt Blenkinsop
on 2024-11-07 11:49:12 UTC
(
hide
)
Description:
Bug 38010: Add basket page
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-11-07 11:49:12 UTC
Size:
17.02 KB
patch
obsolete
>From b6e5ae4796aaf0e6671d1e4689c597e5145bc54c Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Tue, 15 Oct 2024 13:48:44 +0000 >Subject: [PATCH] Bug 38010: Add basket page > >--- > .../prog/en/includes/vendor-menu.inc | 2 +- > .../vue/components/Vendors/VendorBaskets.vue | 218 ++++++++++++++++++ > .../js/vue/components/Vendors/VendorList.vue | 6 +- > .../js/vue/components/Vendors/VendorShow.vue | 72 ++++-- > .../js/vue/fetch/acquisition-api-client.js | 17 +- > .../prog/js/vue/routes/acquisitions.js | 6 + > 6 files changed, 295 insertions(+), 26 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorBaskets.vue > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc >index f9fb59502bd..5dfb9a75083 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc >@@ -1,7 +1,7 @@ > [% IF ( booksellerid ) %] > <div id="menu"> > <ul> >- [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/vendors/[% booksellerid | uri %]">Baskets</a></li>[% END %] >+ [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/vendors/[% booksellerid | uri %]/baskets">Baskets</a></li>[% END %] > [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %] > [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %] > [% IF ( CAN_user_acquisition_issue_manage ) %]<li><a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% booksellerid | uri %]">Vendor issues</a></li>[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorBaskets.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorBaskets.vue >new file mode 100644 >index 00000000000..b8dd70752f2 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorBaskets.vue >@@ -0,0 +1,218 @@ >+<template> >+ <div id="vendor_baskets"> >+ <div v-if="parseInt(basketCount) > 0" class="page-section"> >+ <KohaTable >+ ref="table" >+ v-bind="tableOptions" >+ @show="doShow" >+ @edit="doEdit" >+ @delete="doDelete" >+ @select="doSelect" >+ ></KohaTable> >+ </div> >+ <div v-else class="alert alert-info"> >+ {{ $__("There are no baskets defined") }} >+ </div> >+ </div> >+</template> >+ >+<script> >+import { inject, ref } from "vue" >+import { storeToRefs } from "pinia" >+import KohaTable from "../KohaTable.vue" >+ >+export default { >+ setup() { >+ const vendorStore = inject("vendorStore") >+ const { vendors } = storeToRefs(vendorStore) >+ >+ const { setConfirmationDialog, setMessage } = inject("mainStore") >+ >+ const table = ref() >+ >+ return { >+ vendors, >+ table, >+ setConfirmationDialog, >+ setMessage, >+ escape_str, >+ } >+ }, >+ data() { >+ return { >+ fp_config: flatpickr_defaults, >+ initialized: false, >+ tableOptions: { >+ columns: this.getTableColumns(), >+ url: () => this.tableURL(), >+ add_filters: true, >+ // filters_options: { >+ // 1: [ >+ // { _id: 0, _str: this.$__("Inactive") }, >+ // { _id: 1, _str: this.$__("Active") }, >+ // ], >+ // ...(this.map_av_dt_filter("vendor_types").length && { >+ // 2: () => this.map_av_dt_filter("vendor_types"), >+ // }), >+ // }, >+ actions: { >+ "-1": ["edit", "delete"], >+ }, >+ }, >+ before_route_entered: false, >+ building_table: false, >+ } >+ }, >+ methods: { >+ doShow({ id }, dt, event) { >+ event.preventDefault() >+ this.$router.push({ >+ name: "VendorShow", >+ params: { vendor_id: id }, >+ }) >+ }, >+ doEdit({ id }, dt, event) { >+ this.$router.push({ >+ name: "VendorFormAddEdit", >+ params: { vendor_id: id }, >+ }) >+ }, >+ doDelete(vendor, dt, event) { >+ this.setConfirmationDialog( >+ { >+ title: this.$__( >+ "Are you sure you want to remove this vendor?" >+ ), >+ message: vendor.name, >+ accept_label: this.$__("Yes, delete"), >+ cancel_label: this.$__("No, do not delete"), >+ }, >+ () => { >+ const client = APIClient.acquisition >+ client.vendors.delete(vendor.id).then( >+ success => { >+ this.setMessage( >+ this.$__("Vendor %s deleted").format( >+ vendor.name >+ ), >+ true >+ ) >+ dt.draw() >+ }, >+ error => {} >+ ) >+ } >+ ) >+ }, >+ doSelect(vendor, dt, event) { >+ this.$emit("select-vendor", vendor.id) >+ this.$emit("close") >+ }, >+ tableURL() { >+ let url = >+ "/api/v1/acquisitions/baskets?q=" + >+ JSON.stringify({ vendor_id: this.vendorId }) >+ return url >+ }, >+ getTableColumns() { >+ const escape_str = this.escape_str >+ const get_lib_from_av = this.get_lib_from_av >+ >+ return [ >+ { >+ title: __("Name"), >+ data: "me.name:me.basket_id", >+ searchable: true, >+ orderable: true, >+ render(data, type, row, meta) { >+ return ( >+ '<a href="/cgi-bin/koha/acqui/basket.pl?basket_id=' + >+ row.basket_id + >+ '" class="show">' + >+ escape_str(`${row.name} (#${row.basket_id})`) + >+ "</a>" >+ ) >+ }, >+ }, >+ { >+ title: __("Item count"), >+ data: "name", >+ searchable: true, >+ orderable: true, >+ render(data, type, row, meta) { >+ return escape_str(row.name) >+ }, >+ }, >+ { >+ title: __("Bibliographic record count"), >+ data: "name", >+ searchable: true, >+ orderable: true, >+ render(data, type, row, meta) { >+ return escape_str(row.name) >+ }, >+ }, >+ { >+ title: __("Items expected"), >+ data: "name", >+ searchable: true, >+ orderable: true, >+ render(data, type, row, meta) { >+ return escape_str(row.name) >+ }, >+ }, >+ { >+ title: __("Created by"), >+ data: "creator_id", >+ searchable: true, >+ orderable: true, >+ }, >+ { >+ title: __("Date"), >+ data: "creation_date", >+ searchable: true, >+ orderable: true, >+ }, >+ { >+ title: __("Basket group"), >+ data: "basket_group_id", >+ searchable: true, >+ orderable: true, >+ }, >+ { >+ title: __("Internal note"), >+ data: "note", >+ searchable: true, >+ orderable: true, >+ }, >+ { >+ title: __("Close"), >+ data: "close_date", >+ searchable: true, >+ orderable: true, >+ }, >+ ] >+ }, >+ }, >+ components: { KohaTable }, >+ props: { >+ basketCount: { >+ type: String, >+ default: "0", >+ }, >+ vendorId: { >+ type: Number, >+ }, >+ }, >+ name: "VendorBaskets", >+ emits: ["select-vendor", "close"], >+} >+</script> >+ >+<style scoped> >+.filters > label[for="by_mine_filter"], >+.filters > input[type="checkbox"], >+.filters > input[type="button"] { >+ margin-left: 1rem; >+} >+</style> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue >index 586732479d7..7965f223c4b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue >@@ -214,12 +214,12 @@ export default { > title: __("Baskets"), > data: "baskets", > searchable: false, >- orderable: true, >+ orderable: false, > render(data, type, row, meta) { > return row.baskets.length > ? '<a href="/cgi-bin/koha/vendors/' + > row.id + >- '" class="show">' + >+ '/baskets" class="show">' + > escape_str( > `${row.baskets.length} basket(s)` > ) + >@@ -231,7 +231,7 @@ export default { > title: __("Subscriptions"), > data: "subscriptions", > searchable: false, >- orderable: true, >+ orderable: false, > render(data, type, row, meta) { > return row.subscriptions.length > ? '<a href="/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=' + >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue >index 0e3e39c5095..9055ec32aa8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue >@@ -28,27 +28,36 @@ > <h1> > {{ vendor.name }} > </h1> >- <div class="row"> >- <div class="col-sm-6"> >- <VendorDetails :vendor="vendor" :display="true" /> >- <VendorOrderingInformation :vendor="vendor" :display="true" /> >- <VendorInterfaces >- :vendor="vendor" >- v-if="vendor.interfaces.length > 0" >- :display="true" >- /> >+ <template v-if="!basketView"> >+ <div class="row"> >+ <div class="col-sm-6"> >+ <VendorDetails :vendor="vendor" :display="true" /> >+ <VendorOrderingInformation >+ :vendor="vendor" >+ :display="true" >+ /> >+ <VendorInterfaces >+ :vendor="vendor" >+ v-if="vendor.interfaces.length > 0" >+ :display="true" >+ /> >+ </div> >+ <div class="col-sm-6"> >+ <VendorContacts :vendor="vendor" :display="true" /> >+ <VendorSubscriptions :vendor="vendor" /> >+ </div> > </div> >- <div class="col-sm-6"> >- <VendorContacts :vendor="vendor" :display="true" /> >- <VendorSubscriptions :vendor="vendor" /> >+ <div >+ class="page-section rows" >+ v-if="vendor.contracts && vendor.contracts.length > 0" >+ > >+ <VendorContracts :vendor="vendor" /> > </div> >- </div> >- <div >- class="page-section rows" >- v-if="vendor.contracts && vendor.contracts.length > 0" >- > >- <VendorContracts :vendor="vendor" /> >- </div> >+ </template> >+ <template v-if="basketView"> >+ <h2>{{ $__("Baskets") }}</h2> >+ <VendorBaskets :basketCount="basketCount" :vendorId="vendor.id" /> >+ </template> > </div> > </template> > >@@ -64,6 +73,7 @@ import VendorInterfaces from "./VendorInterfaces.vue" > import VendorContacts from "./VendorContacts.vue" > import VendorSubscriptions from "./VendorSubscriptions.vue" > import VendorContracts from "./VendorContracts.vue" >+import VendorBaskets from "./VendorBaskets.vue" > > export default { > setup() { >@@ -83,17 +93,26 @@ export default { > return { > vendor: null, > initialized: false, >+ basketView: false, >+ basketCount: null, > } > }, > beforeRouteEnter(to, from, next) { > next(vm => { >- vm.getVendor(to.params.vendor_id) >+ if (to.path.includes("basket")) { >+ vm.basketView = true >+ vm.getVendor(to.params.vendor_id).then(() => >+ vm.getBasketCount(to.params.vendor_id) >+ ) >+ } else { >+ vm.getVendor(to.params.vendor_id) >+ } > }) > }, > methods: { > async getVendor(vendor_id) { > const client = APIClient.acquisition >- client.vendors.get(vendor_id).then( >+ await client.vendors.get(vendor_id).then( > vendor => { > this.vendor = vendor > this.initialized = true >@@ -101,6 +120,16 @@ export default { > error => {} > ) > }, >+ async getBasketCount(booksellerid) { >+ const client = APIClient.acquisition >+ await client.baskets.count({ booksellerid }).then( >+ count => { >+ this.basketCount = count >+ this.initialized = true >+ }, >+ error => {} >+ ) >+ }, > }, > components: { > Toolbar, >@@ -111,6 +140,7 @@ export default { > VendorContacts, > VendorSubscriptions, > VendorContracts, >+ VendorBaskets, > }, > name: "VendorShow", > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js >index ecc532630a9..930ec22320f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js >@@ -14,7 +14,7 @@ export class AcquisitionAPIClient extends HttpClient { > endpoint: "vendors/" + id, > headers: { > "x-koha-embed": >- "baskets,aliases,subscriptions,interfaces,contacts,contracts", >+ "aliases,subscriptions,interfaces,contacts,contracts", > }, > }), > getAll: (query, params) => >@@ -52,6 +52,21 @@ export class AcquisitionAPIClient extends HttpClient { > }), > }; > } >+ >+ get baskets() { >+ return { >+ count: (query = {}) => >+ this.count({ >+ endpoint: >+ "baskets?" + >+ new URLSearchParams({ >+ _page: 1, >+ _per_page: 1, >+ ...(query && { q: JSON.stringify(query) }), >+ }), >+ }), >+ }; >+ } > } > > export default AcquisitionAPIClient; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/acquisitions.js b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/acquisitions.js >index f21f6381356..bed6eb2c485 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/acquisitions.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/acquisitions.js >@@ -50,6 +50,12 @@ export const routes = [ > component: markRaw(VendorFormAdd), > title: $__("Edit vendor"), > }, >+ { >+ path: ":vendor_id/baskets", >+ name: "VendorShowBaskets", >+ component: markRaw(VendorShow), >+ title: $__("Baskets"), >+ }, > ], > }, > ], >-- >2.39.3 (Apple Git-146)
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 38010
:
174119
|
174120
|
174121
|
174122
|
174123
|
174124
|
174125
|
174126
|
174128
|
174129
|
174130
|
174131
|
174132
|
174133
|
174134
|
174135
|
174136
|
174137
|
174138
|
174139
|
174140
|
174141
|
174142
|
174143
|
174144
|
174145
|
174146
|
174147
|
174148
|
174151
|
174152
|
174153
|
174154
|
174155
|
174156
|
174157
|
174158
|
174159
|
174160
|
174161
|
174162
|
174163
|
174164
|
174165
|
174166
|
174167
|
174168
|
174169
|
174170
|
174171
|
174172
|
174173
|
174174
|
174175
|
174176
|
174177
|
174178
|
174179
|
174194
|
174196
|
174197
|
174198
|
174199
|
174200
|
174201
|
174202
|
174203
|
174204
|
174205
|
174206
|
174207
|
174208
|
174209
|
174210
|
174211
|
174212
|
174213
|
174214
|
174215
|
174216
|
174217
|
174218
|
174220
|
174221
|
174222
|
174223
|
174224
|
174225
|
174226
|
174248
|
174266
|
174267
|
174269
|
174270
|
174273
|
174327
|
174328
|
174329
|
174330
|
174331
|
174332
|
174333
|
174334
|
174335
|
174336
|
174337
|
174338
|
174339
|
174340
|
174341
|
174342
|
174343
|
174344
|
174345
|
174346
|
174347
|
174348
|
174349
|
174350
|
174351
|
174352
|
174353
|
174354
|
174355
|
174356
|
174357
|
174358
|
174359
|
174360
|
174603