Bugzilla – Attachment 173779 Details for
Bug 37577
Add additional fields support to ERM packages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37577: Add additional fields for ERM packages
Bug-37577-Add-additional-fields-for-ERM-packages.patch (text/plain), 39.74 KB, created by
Jake Deery
on 2024-10-31 11:47:20 UTC
(
hide
)
Description:
Bug 37577: Add additional fields for ERM packages
Filename:
MIME Type:
Creator:
Jake Deery
Created:
2024-10-31 11:47:20 UTC
Size:
39.74 KB
patch
obsolete
>From 1cad849992d10307a38732a16e934e40a07bfcd1 Mon Sep 17 00:00:00 2001 >From: Jake Deery <jake.deery@ptfs-europe.com> >Date: Mon, 9 Sep 2024 11:42:36 +0000 >Subject: [PATCH] Bug 37577: Add additional fields for ERM packages >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This bug adds support for additional fields in the ERM module's >packages, similar to how Bug 35287 added support for additional fields >in the ERM module's licences, and Bug 37576 added support for additional >fields in the ERM module's agreements. > >To test (k.t.d): >a) APPLY PATCH >b) Run cypress --spec t/cypress/integration/AdditionalFields_spec.ts > 1) Note how the tests pass >c) Add new additional fields for 'erm_packages' > 1) Go to /cgi-bin/koha/admin/additional-fields.pl?tablename=erm_packages > 2) Create field one called 'text non-repeatable' > 3) Create field two called 'text repeatable', check 'repeatable' > 4) Create field three called 'av non-repeatable', pick LANG authorised > value > 5) Create field four called 'av repeatable', pick LOC authorised value, > check repeatable >d) Create new local package > 1) Go to /cgi-bin/koha/erm/eholdings/local/packages/add, notice the new > additional fields section > 2) Complete all mandatory fields for a new package > 3) Experiment with the four different additional field types รข it > may be useful to watch the Cypress-generated test video for > guidance > 4) Select some AV options from the AV fields, deselect them, notice > the repeatable one allows for multiple selection, the non-repeatable > one does not >e) Save the package, then view it > 1) To view the package, click its name in the table list on > /cgi-bin/koha/erm/eholdings/local/packages > 2) notice the additional fields on display > 3) also notice that the authorised values are in their human-readable > form, and not their coded form >f) Edit the package, then view it again > 1) Go to /cgi-bin/koha/erm/eholdings/local/packages/edit/1 > 2) Play around again with the fields. Save. > 3) Repeat step e, have the edits shown up? >g) Test searchability > 1) Go to /cgi-bin/koha/admin/additional-fields.pl?tablename=erm_packages > 2) Edit one of the fields and make sure searchable is checked (ensure > you choose a field that has some data in it) > 3) Go to /cgi-bin/koha/erm/eholdings/local/packages > 4) Notice that the searchable field(s) are now columns in the table > 5) Notice that searchable AV fields contain a drop-down > 6) Notice that searchable text fields have an input field > 7) Perform a search on the additional field > 8) Notice that the searching is working as expected >h) SIGN OFF > >Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> >--- > Koha/AdditionalField.pm | 1 + > Koha/ERM/EHoldings/Package.pm | 2 +- > Koha/ERM/EHoldings/Packages.pm | 2 +- > Koha/REST/V1/ERM/EHoldings/Packages/Local.pm | 8 + > Koha/REST/V1/ExtendedAttributeTypes.pm | 1 + > Koha/Schema/Result/ErmEholdingsPackage.pm | 32 ++ > .../definitions/erm_eholdings_package.yaml | 10 + > .../swagger/paths/erm_eholdings_packages.yaml | 6 + > .../paths/extended_attribute_types.yaml | 1 + > .../en/modules/admin/additional-fields.tt | 3 +- > .../ERM/EHoldingsLocalPackagesFormAdd.vue | 12 + > .../ERM/EHoldingsLocalPackagesList.vue | 51 +- > .../ERM/EHoldingsLocalPackagesShow.vue | 10 + > .../prog/js/vue/fetch/erm-api-client.js | 2 +- > .../integration/AdditionalFields_spec.ts | 535 ++++++++++++++++++ > 15 files changed, 670 insertions(+), 6 deletions(-) > >diff --git a/Koha/AdditionalField.pm b/Koha/AdditionalField.pm >index fd9621d681..ec0263697f 100644 >--- a/Koha/AdditionalField.pm >+++ b/Koha/AdditionalField.pm >@@ -61,6 +61,7 @@ sub to_api { > 'aqinvoices' => 'invoice', > 'erm_licenses' => 'license', > 'erm_agreements' => 'agreement', >+ 'erm_packages' => 'package', > 'aqorders' => 'order', > }; > >diff --git a/Koha/ERM/EHoldings/Package.pm b/Koha/ERM/EHoldings/Package.pm >index 6ee7975277..06c3c3a2a6 100644 >--- a/Koha/ERM/EHoldings/Package.pm >+++ b/Koha/ERM/EHoldings/Package.pm >@@ -19,7 +19,7 @@ use Modern::Perl; > > use Koha::Database; > >-use base qw(Koha::Object); >+use base qw(Koha::Object::Mixin::AdditionalFields Koha::Object); > > use Koha::Acquisition::Booksellers; > use Koha::ERM::EHoldings::Package::Agreements; >diff --git a/Koha/ERM/EHoldings/Packages.pm b/Koha/ERM/EHoldings/Packages.pm >index fe063770c6..021f1b1aec 100644 >--- a/Koha/ERM/EHoldings/Packages.pm >+++ b/Koha/ERM/EHoldings/Packages.pm >@@ -22,7 +22,7 @@ use Koha::Database; > > use Koha::ERM::EHoldings::Package; > >-use base qw(Koha::Objects); >+use base qw(Koha::Objects::Mixin::AdditionalFields Koha::Objects); > > =head1 NAME > >diff --git a/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm b/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm >index 63ca976540..2985477421 100644 >--- a/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm >+++ b/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm >@@ -88,11 +88,15 @@ sub add { > my $body = $c->req->json; > > my $package_agreements = delete $body->{package_agreements} // []; >+ my $extended_attributes = delete $body->{extended_attributes} // []; > delete $body->{external_id} unless $body->{external_id}; > > my $package = Koha::ERM::EHoldings::Package->new_from_api($body)->store; > $package->package_agreements($package_agreements); > >+ my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; >+ $package->extended_attributes( \@extended_attributes ); >+ > $c->res->headers->location($c->req->url->to_string . '/' . $package->package_id); > return $c->render( > status => 201, >@@ -160,6 +164,7 @@ sub update { > my $body = $c->req->json; > > my $package_agreements = delete $body->{package_agreements} // []; >+ my $extended_attributes = delete $body->{extended_attributes} // []; > delete $body->{external_id} unless $body->{external_id}; > > $package->set_from_api($body)->store; >@@ -168,6 +173,9 @@ sub update { > # ie. It's coming from EBSCO and we don't have local data linked to it > $package->package_agreements($package_agreements); > >+ my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; >+ $package->extended_attributes( \@extended_attributes ); >+ > $c->res->headers->location($c->req->url->to_string . '/' . $package->package_id); > return $c->render( > status => 200, >diff --git a/Koha/REST/V1/ExtendedAttributeTypes.pm b/Koha/REST/V1/ExtendedAttributeTypes.pm >index f891c41dd1..844582c5a4 100644 >--- a/Koha/REST/V1/ExtendedAttributeTypes.pm >+++ b/Koha/REST/V1/ExtendedAttributeTypes.pm >@@ -52,6 +52,7 @@ sub list { > invoice => 'aqinvoices', > license => 'erm_licenses', > agreement => 'erm_agreements', >+ package => 'erm_packages', > order => 'aqorders', > }; > >diff --git a/Koha/Schema/Result/ErmEholdingsPackage.pm b/Koha/Schema/Result/ErmEholdingsPackage.pm >index 847f2685bb..27d2e4938a 100644 >--- a/Koha/Schema/Result/ErmEholdingsPackage.pm >+++ b/Koha/Schema/Result/ErmEholdingsPackage.pm >@@ -201,6 +201,38 @@ __PACKAGE__->many_to_many("agreements", "erm_eholdings_packages_agreements", "ag > # Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-11-11 11:52:09 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3YA6xOwdLHDLoZnQJNk8eQ > >+__PACKAGE__->has_many( >+ "additional_field_values", >+ "Koha::Schema::Result::AdditionalFieldValue", >+ sub { >+ my ($args) = @_; >+ >+ return { >+ "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.package_id" }, >+ >+ "$args->{foreign_alias}.field_id" => >+ { -in => \'(SELECT id FROM additional_fields WHERE tablename="erm_packages")' }, >+ }; >+ }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+__PACKAGE__->has_many( >+ "extended_attributes", >+ "Koha::Schema::Result::AdditionalFieldValue", >+ sub { >+ my ($args) = @_; >+ >+ return { >+ "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.package_id" }, >+ >+ "$args->{foreign_alias}.field_id" => >+ { -in => \'(SELECT id FROM additional_fields WHERE tablename="erm_packages")' }, >+ }; >+ }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > sub koha_object_class { > 'Koha::ERM::EHoldings::Package'; > } >diff --git a/api/v1/swagger/definitions/erm_eholdings_package.yaml b/api/v1/swagger/definitions/erm_eholdings_package.yaml >index 328971897c..377d445d2f 100644 >--- a/api/v1/swagger/definitions/erm_eholdings_package.yaml >+++ b/api/v1/swagger/definitions/erm_eholdings_package.yaml >@@ -70,6 +70,16 @@ properties: > type: > - integer > - "null" >+ extended_attributes: >+ description: Related additional field values >+ type: >+ - array >+ items: >+ $ref: extended_attribute_value.yaml >+ _strings: >+ type: >+ - object >+ - "null" > > additionalProperties: false > required: >diff --git a/api/v1/swagger/paths/erm_eholdings_packages.yaml b/api/v1/swagger/paths/erm_eholdings_packages.yaml >index 895c1acf05..d3ae91f205 100644 >--- a/api/v1/swagger/paths/erm_eholdings_packages.yaml >+++ b/api/v1/swagger/paths/erm_eholdings_packages.yaml >@@ -72,6 +72,8 @@ > - vendor.name > - resources+count > - resources >+ - extended_attributes >+ - +strings > collectionFormat: csv > responses: > 200: >@@ -193,6 +195,8 @@ > - package_agreements.agreement > - resources+count > - vendor >+ - extended_attributes >+ - +strings > collectionFormat: csv > responses: > 200: >@@ -262,6 +266,8 @@ > enum: > - agreements > - resources >+ - extended_attributes >+ - +strings > collectionFormat: csv > responses: > 200: >diff --git a/api/v1/swagger/paths/extended_attribute_types.yaml b/api/v1/swagger/paths/extended_attribute_types.yaml >index 08f8141873..eba7aec901 100644 >--- a/api/v1/swagger/paths/extended_attribute_types.yaml >+++ b/api/v1/swagger/paths/extended_attribute_types.yaml >@@ -20,6 +20,7 @@ > - invoice > - license > - agreement >+ - package > - order > - subscription > - $ref: "../swagger.yaml#/parameters/match" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >index d9a12a82fd..250f5587aa 100755 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >@@ -23,7 +23,7 @@ > </head> > > [% marcfield_tables = ['subscription', 'aqorders'] %] >-[% searchable_tables = ['subscription', 'aqbasket', 'aqinvoices', 'erm_licenses', 'erm_agreements'] %] >+[% searchable_tables = ['subscription', 'aqbasket', 'aqinvoices', 'erm_licenses', 'erm_agreements', 'erm_packages'] %] > [% show_marcfield = marcfield_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %] > [% show_searchable = searchable_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %] > >@@ -138,6 +138,7 @@ > [% IF CAN_user_erm %] > [% WRAPPER table_option value="erm_licenses" %]ERM Licenses[% END %] > [% WRAPPER table_option value="erm_agreements" %]ERM Agreements[% END %] >+ [% WRAPPER table_option value="erm_packages" %]ERM Packages[% END %] > [% END %] > </ul> > [% ELSE %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesFormAdd.vue >index 8a382c5cf6..79c2b2952a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesFormAdd.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesFormAdd.vue >@@ -63,6 +63,11 @@ > </li> > </ol> > </fieldset> >+ <AdditionalFieldsEntry >+ resource_type="package" >+ :additional_field_values="erm_package.extended_attributes" >+ @additional-fields-changed="additionalFieldsChanged" >+ /> > <EHoldingsPackageAgreements > :package_agreements="erm_package.package_agreements" > /> >@@ -87,6 +92,7 @@ > <script> > import { inject } from "vue" > import EHoldingsPackageAgreements from "./EHoldingsLocalPackageAgreements.vue" >+import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue" > import FormSelectVendors from "../FormSelectVendors.vue" > import { setMessage, setError, setWarning } from "../../messages" > import { APIClient } from "../../fetch/api-client.js" >@@ -116,6 +122,7 @@ export default { > created_on: null, > resources: null, > package_agreements: [], >+ extended_attributes: [], > }, > initialized: false, > } >@@ -172,6 +179,7 @@ export default { > delete erm_package.vendor > delete erm_package.resources_count > delete erm_package.is_selected >+ delete erm_package._strings > > erm_package.package_agreements = erm_package.package_agreements.map( > ({ package_id, agreement, ...keepAttrs }) => keepAttrs >@@ -200,10 +208,14 @@ export default { > ) > } > }, >+ additionalFieldsChanged(additionalFieldValues) { >+ this.erm_package.extended_attributes = additionalFieldValues >+ }, > }, > components: { > EHoldingsPackageAgreements, > FormSelectVendors, >+ AdditionalFieldsEntry, > }, > name: "EHoldingsEBSCOPackagesFormAdd", > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue >index 29f446bb49..279755d20a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue >@@ -17,6 +17,8 @@ > <KohaTable > ref="table" > v-bind="tableOptions" >+ :searchable_additional_fields="searchable_additional_fields" >+ :searchable_av_options="searchable_av_options" > @show="doShow" > @edit="doEdit" > @delete="doDelete" >@@ -74,11 +76,13 @@ export default { > return { > package_count: 0, > initialized: false, >+ searchable_additional_fields: [], >+ searchable_av_options: [], > tableOptions: { > columns: this.getTableColumns(), > url: "/api/v1/erm/eholdings/local/packages", > options: { >- embed: "resources+count,vendor.name", >+ embed: "resources+count,vendor.name,extended_attributes,+strings", > searchCols: [ > { search: filters.package_name }, > null, >@@ -109,7 +113,15 @@ export default { > }, > beforeRouteEnter(to, from, next) { > next(vm => { >- vm.getPackageCount().then(() => (vm.initialized = true)) >+ vm.getPackageCount().then(() => >+ vm >+ .getSearchableAdditionalFields() >+ .then(() => >+ vm >+ .getSearchableAVOptions() >+ .then(() => (vm.initialized = true)) >+ ) >+ ) > }) > }, > methods: { >@@ -121,6 +133,41 @@ export default { > }, > error => {} > ) >+ }, >+ async getSearchableAdditionalFields() { >+ const client = APIClient.additional_fields >+ await client.additional_fields.getAll("package").then( >+ searchable_additional_fields => { >+ this.searchable_additional_fields = >+ searchable_additional_fields.filter( >+ field => field.searchable >+ ) >+ }, >+ error => {} >+ ) >+ }, >+ async getSearchableAVOptions() { >+ const client_av = APIClient.authorised_values >+ let av_cat_array = this.searchable_additional_fields >+ .filter(field => field.authorised_value_category_name) >+ .map(field => field.authorised_value_category_name) >+ >+ await client_av.values >+ .getCategoriesWithValues([ >+ ...new Set(av_cat_array.map(av_cat => '"' + av_cat + '"')), >+ ]) // unique >+ .then(av_categories => { >+ av_cat_array.forEach(av_cat => { >+ let av_match = av_categories.find( >+ element => element.category_name == av_cat >+ ) >+ this.searchable_av_options[av_cat] = >+ av_match.authorised_values.map(av => ({ >+ value: av.value, >+ label: av.description, >+ })) >+ }) >+ }) > }, > doShow: function ({ package_id }, dt, event) { > event.preventDefault() >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue >index b864affc4e..5f73b9d80d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue >@@ -102,6 +102,12 @@ > /> > </div> > </fieldset> >+ <AdditionalFieldsDisplay >+ resource_type="package" >+ :additional_field_values=" >+ erm_package._strings.additional_field_values >+ " >+ /> > <fieldset class="action"> > <router-link > :to="{ name: 'EHoldingsLocalPackagesList' }" >@@ -120,6 +126,7 @@ import EHoldingsPackageTitlesList from "./EHoldingsLocalPackageTitlesList.vue" > import { APIClient } from "../../fetch/api-client.js" > import Toolbar from "../Toolbar.vue" > import ToolbarButton from "../ToolbarButton.vue" >+import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue" > > export default { > setup() { >@@ -149,6 +156,8 @@ export default { > created_on: null, > resources: null, > package_agreements: [], >+ extended_attributes: [], >+ _strings: [], > }, > initialized: false, > } >@@ -206,6 +215,7 @@ export default { > EHoldingsPackageTitlesList, > Toolbar, > ToolbarButton, >+ AdditionalFieldsDisplay, > }, > name: "EHoldingsLocalPackagesShow", > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >index 7bd2318898..a5ff355cb1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >@@ -112,7 +112,7 @@ export class ERMAPIClient extends HttpClient { > endpoint: "eholdings/local/packages/" + id, > headers: { > "x-koha-embed": >- "package_agreements,package_agreements.agreement,resources+count,vendor", >+ "package_agreements,package_agreements.agreement,resources+count,vendor,extended_attributes,+strings", > }, > }), > getAll: (query, params) => >diff --git a/t/cypress/integration/AdditionalFields_spec.ts b/t/cypress/integration/AdditionalFields_spec.ts >index babea8a31a..582775979d 100644 >--- a/t/cypress/integration/AdditionalFields_spec.ts >+++ b/t/cypress/integration/AdditionalFields_spec.ts >@@ -253,6 +253,148 @@ function get_agreements_additional_fields() { > ]; > } > >+function get_no_additional_fields_package() { >+ return { >+ package_id: 1, >+ name: "package 1", >+ notes: "my first package", >+ content_type: "", >+ created_on: "2024-09-12T10:26:40+00:00", >+ external_id: null, >+ package_agreements: [], >+ package_type: "", >+ provider: null, >+ resources_count: 0, >+ vendor_id: 1, >+ vendor: [cy.get_vendors_to_relate()[0]], >+ extended_attributes: [], >+ _strings: { >+ "additional_field_values": [] >+ }, >+ }; >+} >+function get_package() { >+ return { >+ package_id: 1, >+ name: "package 1", >+ notes: "my first package", >+ content_type: "", >+ created_on: "2024-09-12T10:26:40+00:00", >+ external_id: null, >+ package_agreements: [], >+ package_type: "", >+ provider: null, >+ resources_count: 0, >+ vendor_id: 1, >+ vendor: [cy.get_vendors_to_relate()[0]], >+ extended_attributes: [ >+ { >+ field_id: 1, >+ id: "1", >+ record_id: "1", >+ value: "REF", >+ }, >+ { >+ field_id: 1, >+ id: "2", >+ record_id: "1", >+ value: "NFIC", >+ }, >+ { >+ field_id: 2, >+ id: "3", >+ record_id: "1", >+ value: "some text", >+ }, >+ { >+ field_id: 3, >+ id: "4", >+ record_id: "1", >+ value: "some repeatable text", >+ }, >+ { >+ field_id: 4, >+ id: "5", >+ record_id: "1", >+ value: "AF", >+ }, >+ ], >+ _strings: { >+ additional_field_values: [ >+ { >+ field_id: 1, >+ field_label: "AV Repeatable", >+ type: "av", >+ value_str: "Reference, Non-fiction", >+ }, >+ { >+ field_id: 2, >+ field_label: "Text non-repeatable", >+ type: "text", >+ value_str: "some text", >+ }, >+ { >+ field_id: 3, >+ field_label: "Text repeatable", >+ type: "text", >+ value_str: "some repeatable text", >+ }, >+ { >+ field_id: 4, >+ field_label: "AV Searchable", >+ type: "av", >+ value_str: "Afghanistan", >+ }, >+ ], >+ }, >+ }; >+} >+ >+function get_packages_additional_fields() { >+ return [ >+ { >+ authorised_value_category_name: "CCODE", >+ extended_attribute_type_id: 1, >+ marcfield: "", >+ marcfield_mode: "get", >+ name: "AV Repeatable", >+ repeatable: true, >+ searchable: true, >+ resource_type: "package", >+ }, >+ { >+ authorised_value_category_name: null, >+ extended_attribute_type_id: 2, >+ marcfield: "", >+ marcfield_mode: "get", >+ name: "Text non-repeatable", >+ repeatable: false, >+ searchable: false, >+ resource_type: "package", >+ }, >+ { >+ authorised_value_category_name: null, >+ extended_attribute_type_id: 3, >+ marcfield: "", >+ marcfield_mode: "get", >+ name: "Text repeatable", >+ repeatable: true, >+ searchable: false, >+ resource_type: "package", >+ }, >+ { >+ authorised_value_category_name: "COUNTRY", >+ extended_attribute_type_id: 4, >+ marcfield: "", >+ marcfield_mode: "get", >+ name: "AV Searchable", >+ repeatable: false, >+ searchable: true, >+ resource_type: "package", >+ }, >+ ]; >+} >+ > function get_av_cats() { > return [ > { >@@ -1123,4 +1265,397 @@ describe("Additional Fields operations", () => { > ).should("have.length", 2); > }); > >+ // >+ // for packages >+ // >+ >+ it("Additional Fields display - Table (eHoldings packages)", () => { >+ let eholdings_package = get_package(); >+ let eholdings_packages = [eholdings_package]; >+ let eholdings_package_additional_fields = get_packages_additional_fields(); >+ let av_cats = get_av_cats(); >+ >+ cy.intercept("GET", "/api/v1/extended_attribute_types*", { >+ body: eholdings_package_additional_fields, >+ statusCode: 200, >+ }); >+ >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { >+ statusCode: 200, >+ body: eholdings_packages, >+ headers: { >+ "X-Base-Total-Count": "1", >+ "X-Total-Count": "1", >+ }, >+ }); >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages/*", eholdings_package); >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.get("#packages_list").contains("Showing 1 to 1 of 1 entries"); >+ >+ cy.get("#packages_list table tbody tr:first").contains( >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[0] >+ ) >+ ); >+ cy.get("#packages_list table tbody tr:first").contains( >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[0] >+ ) + >+ ", " + >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[1] >+ ) >+ ); >+ }); >+ >+ it("Additional Fields display - Show (eHoldings packages)", () => { >+ let empty_eholdings_package = get_no_additional_fields_package(); >+ let eholdings_package = get_package(); >+ let eholdings_packages = [eholdings_package]; >+ let vendors = cy.get_vendors_to_relate(); >+ let eholdings_package_additional_fields = get_packages_additional_fields(); >+ let av_cats = get_av_cats(); >+ >+ // Click the 'Edit' button from the list >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { >+ statusCode: 200, >+ body: eholdings_packages, >+ headers: { >+ "X-Base-Total-Count": "1", >+ "X-Total-Count": "1", >+ }, >+ }); >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages/*", empty_eholdings_package).as( >+ "get-empty-eholdings-package" >+ ); >+ >+ //Intercept vendors request >+ cy.intercept("GET", "/api/v1/acquisitions/vendors*", { >+ statusCode: 200, >+ body: vendors, >+ }); >+ cy.intercept("GET", "/api/v1/extended_attribute_types*", { >+ body: [], >+ statusCode: 200, >+ }).as("empty-additional-fields"); >+ >+ //Empty additional fields, should not display >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.get("#packages_list table tbody tr:first td:first a").click(); >+ cy.wait("@get-empty-eholdings-package"); >+ cy.get("#packages_list #additional_fields").should("not.exist"); >+ >+ cy.intercept("GET", "/api/v1/extended_attribute_types*", { >+ body: eholdings_package_additional_fields, >+ statusCode: 200, >+ }).as("existing-additional-fields"); >+ >+ cy.intercept( >+ { >+ pathname: "/api/v1/authorised_value_categories", >+ query: { >+ q: '{"me.category_name":["CCODE", "COUNTRY"]}', >+ }, >+ }, >+ { >+ body: av_cats, >+ statusCode: 200, >+ } >+ ).as("avcategories"); >+ >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages/*", eholdings_package).as( >+ "get-eholdings-package" >+ ); >+ >+ // There are additional fields, fieldset should exist >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.get("#packages_list table tbody tr:first td:first a").click(); >+ cy.wait("@get-eholdings-package"); >+ cy.get("#packages_show #additional_fields").should("exist"); >+ >+ // All fields are presented correctly >+ cy.get( >+ "#packages_show #additional_fields label[for='additional_field_1']" >+ ).contains(eholdings_package_additional_fields[0].name); >+ cy.get( >+ "#packages_show #additional_fields label[for='additional_field_1']" >+ ) >+ .parent() >+ .children("span") >+ .contains( >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[0] >+ ) + >+ ", " + >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[1] >+ ) >+ ); >+ >+ cy.get( >+ "#packages_show #additional_fields label[for='additional_field_2']" >+ ).contains(eholdings_package_additional_fields[1].name); >+ cy.get( >+ "#packages_show #additional_fields label[for='additional_field_2']" >+ ) >+ .parent() >+ .children("span") >+ .contains(eholdings_package.extended_attributes[2].value); >+ >+ cy.get( >+ "#packages_show #additional_fields label[for='additional_field_3']" >+ ).contains(eholdings_package_additional_fields[2].name); >+ cy.get( >+ "#packages_show #additional_fields label[for='additional_field_3']" >+ ) >+ .parent() >+ .children("span") >+ .contains(eholdings_package.extended_attributes[3].value); >+ >+ cy.get( >+ "#packages_show #additional_fields label[for='additional_field_4']" >+ ).contains(eholdings_package_additional_fields[3].name); >+ cy.get( >+ "#packages_show #additional_fields label[for='additional_field_4']" >+ ) >+ .parent() >+ .children("span") >+ .contains( >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[4] >+ ) >+ ); >+ }); >+ >+ it("Additional Fields entry - Add (eHoldings packages)", () => { >+ let vendors = cy.get_vendors_to_relate(); >+ let eholdings_package_additional_fields = get_packages_additional_fields(); >+ let av_cats = get_av_cats(); >+ >+ //Intercept vendors request >+ cy.intercept("GET", "/api/v1/acquisitions/vendors*", { >+ statusCode: 200, >+ body: vendors, >+ }); >+ cy.intercept("GET", "/api/v1/extended_attribute_types*", { >+ body: [], >+ statusCode: 200, >+ }).as("empty-additional-fields"); >+ >+ // No additional fields, fieldset should not exist >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/packages/add"); >+ cy.get("#packages_add form #additional_fields").should("not.exist"); >+ >+ cy.intercept("GET", "/api/v1/extended_attribute_types*", { >+ body: eholdings_package_additional_fields, >+ statusCode: 200, >+ }).as("existing-additional-fields"); >+ >+ cy.intercept( >+ { >+ pathname: "/api/v1/authorised_value_categories", >+ query: { >+ q: '{"me.category_name":["CCODE", "COUNTRY"]}', >+ }, >+ }, >+ { >+ body: av_cats, >+ statusCode: 200, >+ } >+ ).as("avcategories"); >+ // There are additional fields, fieldset should exist >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/packages/add"); >+ cy.get("#packages_add form #additional_fields").should("exist"); >+ >+ // All additional fields should be listed >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_1']" >+ ).contains(eholdings_package_additional_fields[0].name); >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_2']" >+ ).contains(eholdings_package_additional_fields[1].name); >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_3']" >+ ).contains(eholdings_package_additional_fields[2].name); >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_4']" >+ ).contains(eholdings_package_additional_fields[3].name); >+ >+ cy.get("#additional_fields #additional_field_1 .vs__selected").should( >+ "not.exist" >+ ); //new package, no pre-selected value >+ >+ // Pick one value >+ cy.get("#additional_fields #additional_field_1 .vs__search").click(); >+ cy.get( >+ "#additional_fields #additional_field_1 #vs4__option-0" >+ ).contains(av_cats[0].authorised_values[0].description); >+ cy.get("#additional_fields #additional_field_1 #vs4__option-0").click(); >+ cy.get("#additional_fields #additional_field_1 .vs__selected").contains( >+ av_cats[0].authorised_values[0].description >+ ); >+ cy.get("#additional_fields #additional_field_1 .vs__selected").should( >+ "have.length", >+ 1 >+ ); >+ >+ // Pick a second value for the same repeatable AV field >+ cy.get("#additional_fields #additional_field_1 .vs__search").click(); >+ cy.get( >+ "#additional_fields #additional_field_1 #vs4__option-1" >+ ).contains(av_cats[0].authorised_values[1].description); >+ cy.get("#additional_fields #additional_field_1 #vs4__option-1").click(); >+ cy.get("#additional_fields #additional_field_1 .vs__selected").contains( >+ av_cats[0].authorised_values[1].description >+ ); >+ cy.get("#additional_fields #additional_field_1 .vs__selected").should( >+ "have.length", >+ 2 >+ ); >+ >+ // Attempt to pick the same value again - should not be possible >+ cy.get("#additional_fields #additional_field_1 .vs__search").click(); >+ cy.get( >+ "#additional_fields #additional_field_1 #vs4__option-1" >+ ).contains(av_cats[0].authorised_values[1].description); >+ cy.get("#additional_fields #additional_field_1 #vs4__option-1").click(); >+ cy.get("#additional_fields #additional_field_1 .vs__selected").should( >+ "have.length", >+ 2 >+ ); >+ >+ // Remove the second selected value >+ cy.get( >+ "#additional_fields #additional_field_1 .vs__selected button[title='Deselect " + >+ av_cats[0].authorised_values[1].description + >+ "'" >+ ).click(); >+ cy.get("#additional_fields #additional_field_1 .vs__selected").should( >+ "have.length", >+ 1 >+ ); >+ cy.get("#additional_fields #additional_field_1 .vs__selected").contains( >+ av_cats[0].authorised_values[0].description >+ ); >+ }); >+ >+ it("Additional Fields entry - Edit (eHoldings packages)", () => { >+ let eholdings_package = get_package(); >+ let eholdings_packages = [eholdings_package]; >+ let vendors = cy.get_vendors_to_relate(); >+ let eholdings_package_additional_fields = get_packages_additional_fields(); >+ let av_cats = get_av_cats(); >+ >+ // Click the 'Edit' button from the list >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { >+ statusCode: 200, >+ body: eholdings_packages, >+ headers: { >+ "X-Base-Total-Count": "1", >+ "X-Total-Count": "1", >+ }, >+ }); >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages/*", eholdings_package).as( >+ "get-eholdings-package" >+ ); >+ >+ //Intercept vendors request >+ cy.intercept("GET", "/api/v1/acquisitions/vendors*", { >+ statusCode: 200, >+ body: vendors, >+ }); >+ >+ cy.intercept("GET", "/api/v1/extended_attribute_types*", { >+ body: eholdings_package_additional_fields, >+ statusCode: 200, >+ }).as("existing-additional-fields"); >+ >+ cy.intercept( >+ { >+ pathname: "/api/v1/authorised_value_categories", >+ query: { >+ q: '{"me.category_name":["CCODE", "COUNTRY"]}', >+ }, >+ }, >+ { >+ body: av_cats, >+ statusCode: 200, >+ } >+ ).as("avcategories"); >+ >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.get("#packages_list table tbody tr:first").contains("Edit").click(); >+ cy.wait("@get-eholdings-package"); >+ cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! >+ >+ // All additional fields should be pre-populated >+ cy.get("#additional_fields #additional_field_1 .vs__selected").contains( >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[0] >+ ) >+ ); >+ cy.get("#additional_fields #additional_field_1 .vs__selected").contains( >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[1] >+ ) >+ ); >+ >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_2']" >+ ) >+ .parent() >+ .children("input") >+ .should("have.value", eholdings_package.extended_attributes[2].value); >+ >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_3']" >+ ) >+ .parent() >+ .children("input") >+ .should("have.value", eholdings_package.extended_attributes[3].value); >+ >+ cy.get("#additional_fields #additional_field_4 .vs__selected").contains( >+ get_description_from_av_value( >+ av_cats, >+ eholdings_package.extended_attributes[4] >+ ) >+ ); >+ >+ // Clear text field works >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_2']" >+ ) >+ .parent() >+ .children(".clear_attribute") >+ .click(); >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_2']" >+ ) >+ .parent() >+ .children("input") >+ .should("have.value", ""); >+ >+ // "+New" text field works >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_3']" >+ ).should("have.length", 1); >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_3']" >+ ) >+ .parent() >+ .children(".clone_attribute") >+ .click(); >+ cy.get( >+ "#packages_add form #additional_fields label[for='additional_field_3']" >+ ).should("have.length", 2); >+ }); >+ > }); >-- >2.39.5 (Apple Git-154)
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 37577
:
171398
|
172693
|
173779
|
173784
|
173788
|
173789