From 3fdc503ca78fd06d0c6dc3477812acc7799351b9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 13 Jul 2022 17:29:10 +0200 Subject: [PATCH] Bug 32030: Display the list of packages on the 'show agreement' view Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- Koha/ERM/Agreement.pm | 13 +++ Koha/ERM/EHoldings/Package.pm | 20 ----- Koha/ERM/EHoldings/Package/Agreement.pm | 13 +++ api/v1/swagger/paths/erm_agreements.yaml | 1 + cypress/integration/Agreements_spec.ts | 1 + .../vue/components/ERM/AgreementsFormAdd.vue | 2 + .../js/vue/components/ERM/AgreementsShow.vue | 86 ++++++++++++++----- koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js | 2 +- 8 files changed, 95 insertions(+), 43 deletions(-) diff --git a/Koha/ERM/Agreement.pm b/Koha/ERM/Agreement.pm index 9aeaa90345..f199589759 100644 --- a/Koha/ERM/Agreement.pm +++ b/Koha/ERM/Agreement.pm @@ -27,6 +27,7 @@ use Koha::ERM::Agreement::UserRoles; use Koha::ERM::Agreement::Licenses; use Koha::ERM::Agreement::Relationships; use Koha::ERM::Agreement::Documents; +use Koha::ERM::EHoldings::Package::Agreements; =head1 NAME @@ -200,6 +201,18 @@ sub documents { return Koha::ERM::Agreement::Documents->_new_from_dbic($documents_rs); } +=head3 agreement_packages + +Return the local packages for this agreement (and the other ones that have an entry locally) + +=cut + +sub agreement_packages { + my ( $self ) = @_; + my $packages_agreements_rs = $self->_result->erm_eholdings_packages_agreements; + return Koha::ERM::EHoldings::Package::Agreements->_new_from_dbic($packages_agreements_rs); +} + =head2 Internal methods =head3 _type diff --git a/Koha/ERM/EHoldings/Package.pm b/Koha/ERM/EHoldings/Package.pm index a324887589..6ee7975277 100644 --- a/Koha/ERM/EHoldings/Package.pm +++ b/Koha/ERM/EHoldings/Package.pm @@ -84,26 +84,6 @@ sub vendor { return Koha::Acquisition::Bookseller->_new_from_dbic($rs); } -=head3 to_api_mapping - -=cut - -sub to_api_mapping { - my ( $self ) = @_; - - return { - external_id => undef, - ( # Do we really need this? - $self->external_id - ? ( - package_id => $self->external_id, - koha_internal_id => $self->package_id - ) - : () - ) - }; -} - =head2 Internal methods =head3 _type diff --git a/Koha/ERM/EHoldings/Package/Agreement.pm b/Koha/ERM/EHoldings/Package/Agreement.pm index f4ddf1a582..0df41b435a 100644 --- a/Koha/ERM/EHoldings/Package/Agreement.pm +++ b/Koha/ERM/EHoldings/Package/Agreement.pm @@ -20,6 +20,7 @@ use Modern::Perl; use Koha::Database; use Koha::ERM::Agreement; +use Koha::ERM::EHoldings::Package; use base qw(Koha::Object); @@ -45,6 +46,18 @@ sub agreement { return Koha::ERM::Agreement->_new_from_dbic($agreement_rs); } +=head3 package + +Return the package linked to this package package + +=cut + +sub package { + my ( $self ) = @_; + my $package_rs = $self->_result->package; + return Koha::ERM::EHoldings::Package->_new_from_dbic($package_rs); +} + =head2 Internal methods =head3 _type diff --git a/api/v1/swagger/paths/erm_agreements.yaml b/api/v1/swagger/paths/erm_agreements.yaml index d244dcea94..6c311d53a5 100644 --- a/api/v1/swagger/paths/erm_agreements.yaml +++ b/api/v1/swagger/paths/erm_agreements.yaml @@ -197,6 +197,7 @@ - agreement_relationships.agreement - agreement_relationships.related_agreement - documents + - packages put: x-mojo-to: ERM::Agreements#update operationId: updateErmAgreements diff --git a/cypress/integration/Agreements_spec.ts b/cypress/integration/Agreements_spec.ts index 493dcebe92..a592628e0f 100644 --- a/cypress/integration/Agreements_spec.ts +++ b/cypress/integration/Agreements_spec.ts @@ -36,6 +36,7 @@ function get_agreement() { user_roles: [], agreement_licenses: [], agreement_relationships: [], + agreement_packages: [], documents: [], }; } diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue index a3f6bed97b..c6cec90a6a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue @@ -312,6 +312,8 @@ export default { agreement.documents = agreement.documents.map(({ document_id, ...keepAttrs }) => keepAttrs) + delete agreement.agreement_packages + const options = { method: method, body: JSON.stringify(agreement), 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 0eea2a4904..4328db8459 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 @@ -78,7 +78,7 @@ {{ agreement.license_info }} -
  • +
  • @@ -111,7 +111,7 @@
  • -
  • +
  • @@ -139,7 +139,7 @@
  • -
  • +
  • @@ -186,27 +186,64 @@
  • -
  • +
  • -
    - {{ - relationship.related_agreement.name - }} +
    - {{ - get_lib_from_av( - "av_agreement_relationships", - relationship.relationship - ) - }} - {{ agreement.name }} + {{ + relationship.related_agreement.name + }} + {{ + get_lib_from_av( + "av_agreement_relationships", + relationship.relationship + ) + }} + {{ agreement.name }} +
    +
    +
  • + +
  • + +
    +
    + + {{ + agreement_package.package.name + }} + (EBSCO) + {{ + agreement_package.package.name + }} + (local) +
  • @@ -262,6 +299,7 @@ export default { license_info: '', periods: [], user_roles: [], + agreement_packages: [], }, initialized: false, } @@ -289,4 +327,8 @@ export default { padding-left: 0.2em; font-size: 11px; } +#agreement_relationships, +#agreement_packages { + padding-left: 10rem; +} \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js index f578f6f2ae..f9922dd9a0 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js @@ -7,7 +7,7 @@ export const fetchAgreement = async function (agreement_id) { await fetch(apiUrl, { headers: { "x-koha-embed": - "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents", + "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package", }, }) .then(checkError) -- 2.39.5