Bugzilla – Attachment 181813 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: Embed baskets+count and subscriptions+count
Bug-38010-Embed-basketscount-and-subscriptionscoun.patch (text/plain), 11.53 KB, created by
Jonathan Druart
on 2025-04-30 21:05:59 UTC
(
hide
)
Description:
Bug 38010: Embed baskets+count and subscriptions+count
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-04-30 21:05:59 UTC
Size:
11.53 KB
patch
obsolete
>From 64eb97a84eeef411e01b0a1a1209bb8e6ccfa442 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 30 Apr 2025 15:55:23 +0200 >Subject: [PATCH] Bug 38010: Embed baskets+count and subscriptions+count > >We don't need to whole list of baskets and subscriptions > >(cherry picked from commit 391b4d3b32b57c97bfb7e66ab394020ae7eed0e5) > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > api/v1/swagger/definitions/vendor.yaml | 12 ++++++- > .../swagger/paths/acquisitions_vendors.yaml | 8 ++--- > .../prog/js/fetch/acquisition-api-client.js | 4 +-- > .../vue/components/Vendors/VendorFormAdd.vue | 1 + > .../js/vue/components/Vendors/VendorList.vue | 17 ++++------ > .../js/vue/components/Vendors/VendorShow.vue | 9 +++-- > t/db_dependent/api/v1/acquisitions_vendors.t | 33 ++++++++++++------- > 7 files changed, 50 insertions(+), 34 deletions(-) > >diff --git a/api/v1/swagger/definitions/vendor.yaml b/api/v1/swagger/definitions/vendor.yaml >index 163276fdbbf..717d958bf78 100644 >--- a/api/v1/swagger/definitions/vendor.yaml >+++ b/api/v1/swagger/definitions/vendor.yaml >@@ -122,6 +122,11 @@ properties: > baskets: > type: array > description: List of baskets >+ baskets_count: >+ type: >+ - integer >+ - "null" >+ description: Number of linked baskets > subscriptions_count: > type: > - integer >@@ -139,6 +144,11 @@ properties: > invoices: > type: array > description: List of invoices >+ invoices_count: >+ type: >+ - integer >+ - "null" >+ description: Number of linked invoices > additionalProperties: false > required: >- - name >\ No newline at end of file >+ - name >diff --git a/api/v1/swagger/paths/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml >index 1cefcf82dee..bae07ec8aab 100644 >--- a/api/v1/swagger/paths/acquisitions_vendors.yaml >+++ b/api/v1/swagger/paths/acquisitions_vendors.yaml >@@ -35,9 +35,9 @@ > type: string > enum: > - aliases >- - baskets >+ - baskets+count > - subscriptions+count >- - invoices >+ - invoices+count > collectionFormat: csv > responses: > "200": >@@ -149,7 +149,7 @@ > type: string > enum: > - aliases >- - baskets >+ - baskets+count > - subscriptions+count > - interfaces > - contacts >@@ -285,4 +285,4 @@ > $ref: "../swagger.yaml#/definitions/error" > x-koha-authorization: > permissions: >- acquisition: vendors_manage >\ No newline at end of file >+ acquisition: vendors_manage >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js >index 165d93948e2..fad44c00a75 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js >@@ -21,7 +21,7 @@ export class AcquisitionAPIClient { > endpoint: "vendors/" + id, > headers: { > "x-koha-embed": >- "aliases,subscriptions+count,interfaces,contacts,contracts,baskets", >+ "aliases,subscriptions+count,interfaces,contacts,contracts,baskets+count", > }, > }), > getAll: (query, params) => >@@ -30,7 +30,7 @@ export class AcquisitionAPIClient { > query, > params: { _order_by: "name", ...params }, > headers: { >- "x-koha-embed": "aliases,baskets", >+ "x-koha-embed": "aliases,baskets+count", > }, > }), > delete: id => >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue >index d0fe88f87fe..3c042ca82d6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue >@@ -128,6 +128,7 @@ export default { > delete vendor.physical; > delete vendor.subscriptions_count; > delete vendor.baskets; >+ delete vendor.baskets_count; > delete vendor.subscriptions; > delete vendor.contracts; > >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 b59ff1c556c..1441e21c5c2 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 >@@ -67,7 +67,7 @@ export default { > tableOptions: { > columns: this.getTableColumns(), > options: { >- embed: "aliases,baskets,subscriptions+count,invoices", >+ embed: "aliases,baskets+count,subscriptions+count,invoices+count", > }, > url: () => this.tableURL(), > add_filters: true, >@@ -89,12 +89,9 @@ export default { > text: this.$__("Delete"), > icon: "fa fa-trash", > should_display: row => >- (!row.baskets || >- row.baskets.length === 0) && >- (!row.subscriptions_count || >- row.subscriptions_count === 0) && >- (!row.invoices || >- row.invoices.length === 0), >+ row.baskets_count === 0 && >+ row.subscriptions_count === 0 && >+ row.invoices_count === 0, > }, > }, > { >@@ -103,7 +100,7 @@ export default { > icon: "fa fa-inbox", > should_display: row => > row.active && >- row.baskets?.length > 0 && >+ row.baskets_count > 0 && > this.isUserPermitted( > "CAN_user_acquisition_order_receive" > ), >@@ -241,13 +238,13 @@ export default { > searchable: false, > orderable: false, > render(data, type, row, meta) { >- return row.baskets.length >+ return row.baskets_count > ? '<a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=' + > row.id + > '" class="show">' + > escape_str( > __("%s basket(s)").format( >- row.baskets.length >+ row.baskets_count > ) > ) + > "</a>" >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 77fdcbb3853..456250ad2eb 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 >@@ -48,7 +48,7 @@ > <ToolbarButton > v-if=" > vendor.active && >- vendor.baskets?.length > 0 && >+ vendor.baskets_count > 0 && > isUserPermitted('CAN_user_acquisition_order_receive') > " > :to="{ >@@ -61,10 +61,9 @@ > /> > <a > v-if=" >- (!vendor.baskets || vendor.baskets.length === 0) && >- (!vendor.subscriptions_count || >- vendor.subscriptions_count === 0) && >- (!vendor.invoices || vendor.invoices.length === 0) >+ vendor.baskets_count === 0 && >+ vendor.subscriptions_count === 0 && >+ vendor.invoices_count === 0 > " > @click="doDelete(vendor.id, vendor.name)" > class="btn btn-default" >diff --git a/t/db_dependent/api/v1/acquisitions_vendors.t b/t/db_dependent/api/v1/acquisitions_vendors.t >index 5e259ce2b90..749ace26b71 100755 >--- a/t/db_dependent/api/v1/acquisitions_vendors.t >+++ b/t/db_dependent/api/v1/acquisitions_vendors.t >@@ -37,7 +37,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); > > subtest 'list() and delete() tests | authorized user' => sub { > >- plan tests => 44; >+ plan tests => 39; > > $schema->storage->txn_begin; > >@@ -92,23 +92,32 @@ subtest 'list() and delete() tests | authorized user' => sub { > ->json_is( '/0/aliases/0/alias' => 'alias 1', 'alias 1 is embedded' ) > ->json_is( '/0/aliases/1/alias' => 'alias 2', 'alias 2 is embedded' ); > >+ my @cleanup; > for ( 0 .. 1 ) { >- $builder->build_object( { class => 'Koha::Subscriptions', value => { aqbooksellerid => $vendor->id } } ); >+ push @cleanup, >+ $builder->build_object( { class => 'Koha::Subscriptions', value => { aqbooksellerid => $vendor->id } } ); >+ push @cleanup, >+ $builder->build_object( >+ { class => 'Koha::Acquisition::Baskets', value => { booksellerid => $vendor->id } } ); >+ push @cleanup, >+ $builder->build_object( >+ { class => 'Koha::Acquisition::Invoices', value => { booksellerid => $vendor->id } } ); > } >- $t->get_ok( "//$userid:$password@/api/v1/acquisitions/vendors" => { 'x-koha-embed' => 'subscriptions+count' } ) >- ->status_is(200)->json_has( '/0/subscriptions_count', 'subscriptions_count is embedded' ) >- ->json_is( '/0/subscriptions_count' => '2', 'subscription count is 2' ); >+ $t->get_ok( "//$userid:$password@/api/v1/acquisitions/vendors" => >+ { 'x-koha-embed' => 'subscriptions+count,baskets+count,invoices+count' } )->status_is(200) >+ ->json_is( '/0/subscriptions_count', 2, 'subscriptions_count is 2' ) >+ ->json_is( '/0/baskets_count', 2, 'baskets_count is 2' ) >+ ->json_is( '/0/invoices_count', 2, 'invoices_count is 2' ); >+ >+ # FIXME We need to add more tests/code here >+ # A vendor deletion should be rejected if it has baskets or subscriptions (or invoices?) linked to it >+ $_->delete for @cleanup; > > $t->delete_ok( "//$userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id )->status_is( 204, 'REST3.2.4' ) > ->content_is( '', 'REST3.3.4' ); > >- $t->get_ok("//$userid:$password@/api/v1/acquisitions/vendors")->status_is(200) >- ->json_like( '/0/name' => qr/$other_vendor_name/ )->json_hasnt( '/1', 'Only one vendor' ); >- >- $t->delete_ok( "//$userid:$password@/api/v1/acquisitions/vendors/" . $other_vendor->id ) >- ->status_is( 204, 'REST3.2.4' )->content_is( '', 'REST3.3.4' ); >- >- $t->get_ok("//$userid:$password@/api/v1/acquisitions/vendors")->status_is(200)->json_is( [] ); >+ $t->get_ok( "//$userid:$password@/api/v1/acquisitions/vendors/" . $other_vendor->id )->status_is(200); >+ $t->get_ok( "//$userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id )->status_is(404); > > $schema->storage->txn_rollback; > }; >-- >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 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
|
175098
|
175099
|
175100
|
175101
|
175102
|
175103
|
175104
|
175105
|
175106
|
175107
|
175108
|
175109
|
175110
|
175111
|
175112
|
175113
|
175114
|
175115
|
175116
|
175117
|
175118
|
175119
|
175120
|
175121
|
175122
|
175123
|
175124
|
175125
|
175126
|
175127
|
175128
|
175129
|
175130
|
175131
|
175133
|
175134
|
175135
|
175136
|
175137
|
175167
|
175168
|
175170
|
175240
|
175241
|
175242
|
175243
|
175248
|
175249
|
175266
|
175791
|
175799
|
176547
|
178182
|
178183
|
178184
|
178185
|
178186
|
178187
|
178188
|
178189
|
178190
|
178191
|
178192
|
178193
|
178194
|
178195
|
178196
|
178197
|
178198
|
178199
|
178200
|
178201
|
178202
|
178203
|
178204
|
178205
|
178206
|
178207
|
178208
|
178209
|
178210
|
178211
|
178212
|
178213
|
178214
|
178215
|
178216
|
178217
|
178218
|
178219
|
178220
|
178221
|
178222
|
178223
|
178224
|
178225
|
178226
|
178227
|
178228
|
178229
|
178230
|
178231
|
178232
|
178233
|
178234
|
178235
|
178236
|
178237
|
178238
|
178239
|
178240
|
178241
|
178242
|
181579
|
181585
|
181727
|
181728
|
181729
|
181730
|
181731
|
181732
|
181733
|
181734
|
181735
|
181736
|
181737
|
181738
|
181739
|
181740
|
181741
|
181742
|
181743
|
181744
|
181745
|
181746
|
181747
|
181748
|
181749
|
181750
|
181751
|
181752
|
181753
|
181754
|
181755
|
181756
|
181757
|
181758
|
181759
|
181760
|
181761
|
181762
|
181763
|
181764
|
181765
|
181766
|
181767
|
181768
|
181769
|
181770
|
181771
|
181772
|
181773
|
181774
|
181775
|
181776
|
181777
|
181778
|
181779
|
181780
|
181781
|
181782
|
181783
|
181784
|
181785
|
181786
|
181787
|
181788
|
181789
|
181790
|
181791
|
181792
|
181793
|
181794
|
181795
|
181796
|
181797
|
181798
|
181799
|
181800
|
181801
|
181802
|
181803
|
181804
|
181805
|
181806
|
181807
|
181808
|
181809
|
181810
|
181811
|
181812
| 181813 |
181814
|
181815
|
181816
|
181817
|
181818
|
181819
|
181820
|
181821
|
181891
|
181898
|
181901
|
181963
|
181964
|
182053
|
182351
|
182438