Bug 32030: Display the list of packages on the 'show agreement' view

Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-07-13 17:29:10 +02:00 committed by Tomas Cohen Arazi
parent a596acc28e
commit 3fdc503ca7
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
8 changed files with 95 additions and 43 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -197,6 +197,7 @@
- agreement_relationships.agreement
- agreement_relationships.related_agreement
- documents
- packages
put:
x-mojo-to: ERM::Agreements#update
operationId: updateErmAgreements

View file

@ -36,6 +36,7 @@ function get_agreement() {
user_roles: [],
agreement_licenses: [],
agreement_relationships: [],
agreement_packages: [],
documents: [],
};
}

View file

@ -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),

View file

@ -78,7 +78,7 @@
<span>{{ agreement.license_info }}</span>
</li>
<li>
<li v-if="agreement.periods.length">
<label>{{ $t("Periods") }}</label>
<table>
<thead>
@ -111,7 +111,7 @@
</table>
</li>
<li>
<li v-if="agreement.user_roles.length">
<label>{{ $t("Users") }}</label>
<table>
<thead>
@ -139,7 +139,7 @@
</table>
</li>
<li>
<li v-if="agreement.agreement_licenses.length">
<label>{{ $t("Licenses") }}</label>
<table>
<thead>
@ -186,27 +186,64 @@
</table>
</li>
<li>
<li v-if="agreement.agreement_relationships.length">
<label>{{ $t("Related agreements") }}</label>
<div
v-for="relationship in agreement.agreement_relationships"
v-bind:key="relationship.related_agreement_id"
>
<span
><router-link
:to="`/cgi-bin/koha/erm/agreements/${relationship.related_agreement.agreement_id}`"
>{{
relationship.related_agreement.name
}}</router-link
></span
<div id="agreement_relationships">
<div
v-for="relationship in agreement.agreement_relationships"
v-bind:key="relationship.related_agreement_id"
>
{{
get_lib_from_av(
"av_agreement_relationships",
relationship.relationship
)
}}
{{ agreement.name }}
<span
><router-link
:to="`/cgi-bin/koha/erm/agreements/${relationship.related_agreement.agreement_id}`"
>{{
relationship.related_agreement.name
}}</router-link
></span
>
{{
get_lib_from_av(
"av_agreement_relationships",
relationship.relationship
)
}}
{{ agreement.name }}
</div>
</div>
</li>
<li v-if="agreement.agreement_packages.length">
<label>{{ $t("Packages") }}</label>
<div id="agreement_packages">
<div
v-for="agreement_package in agreement.agreement_packages"
v-bind:key="agreement_package.package_id"
>
<span
v-if="
agreement_package.package.external_id &&
agreement_package.package.provider ==
'ebsco'
"
>
<router-link
:to="`/cgi-bin/koha/erm/eholdings/ebsco/packages/${agreement_package.package.external_id}`"
>{{
agreement_package.package.name
}}</router-link
>
(EBSCO)</span
>
<span v-else
><router-link
:to="`/cgi-bin/koha/erm/eholdings/local/packages/${agreement_package.package.package_id}`"
>{{
agreement_package.package.name
}}</router-link
>
(local)</span
>
</div>
</div>
</li>
</ol>
@ -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;
}
</style>

View file

@ -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)