Bugzilla – Attachment 173112 Details for
Bug 35287
Add additional fields support to ERM licenses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35287: (QA follow-up): Squash
Bug-35287-QA-follow-up-Squash.patch (text/plain), 9.49 KB, created by
Victor Grousset/tuxayo
on 2024-10-22 01:47:26 UTC
(
hide
)
Description:
Bug 35287: (QA follow-up): Squash
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-10-22 01:47:26 UTC
Size:
9.49 KB
patch
obsolete
>From 1344752517abbdac936b392745d292361ac74476 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Fri, 16 Aug 2024 11:01:31 +0000 >Subject: [PATCH] Bug 35287: (QA follow-up): Squash > >Remove leftover unused code >Add missing pod >Tidy >Removed redundant commented in AdditionalFields_spec.ts > >Run: >qa -c 11 -v 2 > >Verify everything is green > >Sponsored-by: UKHSA - UK Health Security Agency >Sponsored-by: PTFS Europe Ltd >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> >--- > Koha/Object/Mixin/AdditionalFields.pm | 4 +-- > Koha/Objects/Mixin/AdditionalFields.pm | 16 ++++++---- > Koha/REST/V1/ERM/Licenses.pm | 14 +++++---- > .../integration/AdditionalFields_spec.ts | 2 -- > .../Koha/Object/Mixin/AdditionalFields.t | 30 +++++++++---------- > 5 files changed, 36 insertions(+), 30 deletions(-) > >diff --git a/Koha/Object/Mixin/AdditionalFields.pm b/Koha/Object/Mixin/AdditionalFields.pm >index 18e5c5efc7..a27f6f89ea 100644 >--- a/Koha/Object/Mixin/AdditionalFields.pm >+++ b/Koha/Object/Mixin/AdditionalFields.pm >@@ -232,7 +232,7 @@ REST API embed of additional_field_values > =cut > > sub extended_attributes { >- my ($self, $extended_attributes) = @_; >+ my ( $self, $extended_attributes ) = @_; > > if ($extended_attributes) { > $self->set_additional_fields($extended_attributes); >@@ -297,7 +297,7 @@ sub strings_map { > ); > } > >- my @sorted = sort { $a->{field_id} <=> $b->{field_id} } @{ $strings->{additional_field_values} }; >+ my @sorted = sort { $a->{field_id} <=> $b->{field_id} } @{ $strings->{additional_field_values} }; > my @non_empty = grep { $_->{value_str} ne "" } @sorted; > $strings->{additional_field_values} = \@non_empty; > >diff --git a/Koha/Objects/Mixin/AdditionalFields.pm b/Koha/Objects/Mixin/AdditionalFields.pm >index 8351aba549..1fe79af4a5 100644 >--- a/Koha/Objects/Mixin/AdditionalFields.pm >+++ b/Koha/Objects/Mixin/AdditionalFields.pm >@@ -60,20 +60,26 @@ sub filter_by_additional_fields { > > =head3 extended_attributes_config > >+ Returns a hash containing the configuration for extended attributes >+ > =cut > > sub extended_attributes_config { > my ($self) = @_; > >- my $tablename_query = $self->extended_attributes_tablename_query; >- > return { >- 'id_field' => { 'foreign' => 'record_id', 'self' => $self->_resultset->result_source->primary_columns }, >- 'key_field' => 'field_id', >- 'schema_class' => 'Koha::Schema::Result::AdditionalFieldValue', >+ 'id_field' => { 'foreign' => 'record_id', 'self' => $self->_resultset->result_source->primary_columns }, >+ 'key_field' => 'field_id', >+ 'schema_class' => 'Koha::Schema::Result::AdditionalFieldValue', > }; > } > >+=head3 extended_attributes_tablename_query >+ >+ Returns a hash containing the tablename and operator for extended attributes. >+ >+=cut >+ > sub extended_attributes_tablename_query { > my ($self) = @_; > >diff --git a/Koha/REST/V1/ERM/Licenses.pm b/Koha/REST/V1/ERM/Licenses.pm >index 1a233761ee..ccee789686 100644 >--- a/Koha/REST/V1/ERM/Licenses.pm >+++ b/Koha/REST/V1/ERM/Licenses.pm >@@ -85,15 +85,16 @@ sub add { > > my $body = $c->req->json; > >- my $user_roles = delete $body->{user_roles} // []; >- my $documents = delete $body->{documents} // []; >+ my $user_roles = delete $body->{user_roles} // []; >+ my $documents = delete $body->{documents} // []; > my $extended_attributes = delete $body->{extended_attributes} // []; > > my $license = Koha::ERM::License->new_from_api($body)->store; > $license->user_roles($user_roles); > $license->documents($documents); > >- my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; >+ my @extended_attributes = >+ map { { 'id' => $_->{field_id}, 'value' => $_->{value} } } @{$extended_attributes}; > $license->extended_attributes( \@extended_attributes ); > > $c->res->headers->location($c->req->url->to_string . '/' . $license->license_id); >@@ -167,15 +168,16 @@ sub update { > > my $body = $c->req->json; > >- my $user_roles = delete $body->{user_roles} // []; >- my $documents = delete $body->{documents} // []; >+ my $user_roles = delete $body->{user_roles} // []; >+ my $documents = delete $body->{documents} // []; > my $extended_attributes = delete $body->{extended_attributes} // []; > > $license->set_from_api($body)->store; > $license->user_roles($user_roles); > $license->documents($documents); > >- my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; >+ my @extended_attributes = >+ map { { 'id' => $_->{field_id}, 'value' => $_->{value} } } @{$extended_attributes}; > $license->extended_attributes( \@extended_attributes ); > > $c->res->headers->location($c->req->url->to_string . '/' . $license->license_id); >diff --git a/t/cypress/integration/AdditionalFields_spec.ts b/t/cypress/integration/AdditionalFields_spec.ts >index 28ec967afb..9a7885aa5d 100644 >--- a/t/cypress/integration/AdditionalFields_spec.ts >+++ b/t/cypress/integration/AdditionalFields_spec.ts >@@ -348,7 +348,6 @@ describe("Additional Fields operations", () => { > statusCode: 200, > } > ).as("avcategories"); >- // cy.wait("@avcategories"); > > cy.intercept("GET", "/api/v1/erm/licenses/*", license).as( > "get-license" >@@ -453,7 +452,6 @@ describe("Additional Fields operations", () => { > statusCode: 200, > } > ).as("avcategories"); >- // cy.wait("@avcategories"); > // There are additional fields, fieldset should exist > cy.visit("/cgi-bin/koha/erm/licenses/add"); > cy.get("#licenses_add form #additional_fields").should("exist"); >diff --git a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >index a9dae708d3..2b801e19c1 100755 >--- a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >+++ b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t >@@ -285,9 +285,9 @@ subtest 'prepare_cgi_additional_field_values' => sub { > > subtest 'strings_map() tests' => sub { > plan tests => 1; >- $schema->txn_begin; >- Koha::AdditionalFields->search->delete; >- my $license = Koha::ERM::License->new( >+ $schema->txn_begin; >+ Koha::AdditionalFields->search->delete; >+ my $license = Koha::ERM::License->new( > { > name => "license name", > type => "national", >@@ -296,7 +296,7 @@ subtest 'strings_map() tests' => sub { > } > ); > $license->store()->discard_changes(); >- my $field = Koha::AdditionalField->new( >+ my $field = Koha::AdditionalField->new( > { > tablename => 'erm_licenses', > name => 'af_1', >@@ -304,7 +304,7 @@ subtest 'strings_map() tests' => sub { > } > ); > $field->store()->discard_changes(); >- my $field2 = Koha::AdditionalField->new( >+ my $field2 = Koha::AdditionalField->new( > { > tablename => 'erm_licenses', > name => 'af_2', >@@ -312,7 +312,7 @@ subtest 'strings_map() tests' => sub { > } > ); > $field2->store()->discard_changes(); >- my $value = 'some license value'; >+ my $value = 'some license value'; > $license->set_additional_fields( > [ > { >@@ -327,23 +327,23 @@ subtest 'strings_map() tests' => sub { > } > ] > ); >- $license->add_additional_fields( >+ $license->add_additional_fields( > { > $field2->id => ['second field'], > > }, > 'erm_licenses' > ); >- my $av_category = Koha::AuthorisedValueCategory->new( { category_name => "AV_CAT_NAME" } ); >+ my $av_category = Koha::AuthorisedValueCategory->new( { category_name => "AV_CAT_NAME" } ); > $av_category->store()->discard_changes(); >- my $av_value = Koha::AuthorisedValue->new( >+ my $av_value = Koha::AuthorisedValue->new( > { > category => $av_category->category_name, > authorised_value => 'BOB', > lib => "Robert" > } > ); >- my $av_field = Koha::AdditionalField->new( >+ my $av_field = Koha::AdditionalField->new( > { > tablename => "erm_licenses", > name => "av_field", >@@ -352,15 +352,15 @@ subtest 'strings_map() tests' => sub { > } > ); > $av_field->store()->discard_changes(); >- $license->add_additional_fields( >+ $license->add_additional_fields( > { > $av_field->id => [ $av_value->authorised_value ], > > }, > 'erm_licenses' > ); >- my $values = $license->get_additional_field_values_for_template; >- my $strings_map = $license->strings_map; >+ my $values = $license->get_additional_field_values_for_template; >+ my $strings_map = $license->strings_map; > is_deeply( > $strings_map, > { >@@ -387,6 +387,6 @@ subtest 'strings_map() tests' => sub { > }, > 'strings_map looks good' > ); >- $schema->txn_rollback; >- ; >+ $schema->txn_rollback; >+ > }; >-- >2.47.0
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 35287
:
158725
|
158726
|
158727
|
158728
|
158729
|
158730
|
158731
|
158732
|
158733
|
158734
|
159634
|
159635
|
159636
|
159637
|
159638
|
159639
|
159640
|
159641
|
159642
|
159643
|
165451
|
165637
|
165638
|
165639
|
165640
|
165641
|
165642
|
165643
|
165644
|
165645
|
165646
|
165647
|
167681
|
169728
|
169729
|
169730
|
169731
|
169732
|
169733
|
169734
|
169735
|
169736
|
169737
|
170448
|
170753
|
172850
|
172851
|
172852
|
172853
|
172854
|
172855
|
172856
|
172857
|
172858
|
172860
|
172861
|
173022
|
173102
|
173103
|
173104
|
173105
|
173106
|
173107
|
173108
|
173109
|
173110
|
173111
| 173112 |
173113
|
173290