From 97ca4db5d1d3e236274ea30df627ae3ad9bfaaf7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Feb 2023 14:00:56 +0100 Subject: [PATCH] Bug 32924: Add the ability to filter agreement by logged in user This patch adds a new filter checkbox at the top of the agreement list "Show only mine" that will display agreements linked with the logged in user. Test plan: Create several agreements, add your current logged in user to some of them On the agreement list view us the new checkbox to filter the agreements and see those where you are involved in. --- Koha/Schema/Result/ErmAgreement.pm | 7 +++++++ .../intranet-tmpl/prog/en/modules/erm/erm.tt | 2 ++ .../js/vue/components/ERM/AgreementsList.vue | 21 ++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Koha/Schema/Result/ErmAgreement.pm b/Koha/Schema/Result/ErmAgreement.pm index 643f6189c16..b2b97e4f3ee 100644 --- a/Koha/Schema/Result/ErmAgreement.pm +++ b/Koha/Schema/Result/ErmAgreement.pm @@ -270,6 +270,13 @@ __PACKAGE__->many_to_many("packages", "erm_eholdings_packages_agreements", "pack # Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-11-11 11:52:09 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:N93LnvdKirtuV6BSrTGzVg +__PACKAGE__->has_many( + "user_roles", + "Koha::Schema::Result::ErmUserRole", + { "foreign.agreement_id" => "self.agreement_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->add_columns( '+is_perpetual' => { is_boolean => 1 } ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt index 8171ea6a8a7..5d72c8ed3cb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt @@ -60,6 +60,8 @@ const logged_in_user_lists = [% To.json(logged_in_user.virtualshelves.unblessed) | $raw %]; + const logged_in_user = [% To.json(logged_in_user.unblessed) | $raw %]; + [% Asset.js("js/vue/dist/main.js") | $raw %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue index e376b3c3198..b9e0168468e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue @@ -17,6 +17,14 @@ :config="fp_config" /> + + + { e["_id"] = e["id"] @@ -169,11 +181,17 @@ export default { { _id: 1, _str: _("Yes") }, ] + let additional_filters = { + "user_roles.user_id": function () { + return filters.by_mine ? logged_in_user.borrowernumber : "" + }, + } const table = $("#" + table_id).kohaTable( { ajax: { url: datatable_url, }, + embed: ["user_roles"], order: [[0, "asc"]], autoWidth: false, search: { search: default_search }, @@ -417,7 +435,8 @@ export default { }, }, agreement_table_settings, - 1 + 1, + additional_filters ) }, }, -- 2.25.1