From 2adcd3b828c3bb6518933290efe0c0de1d8f61f9 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. Signed-off-by: Pedro Amorim Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Tomas Cohen Arazi --- 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 643f6189c1..b2b97e4f3e 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 9bf3ee0080..e356e85dd8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt @@ -42,6 +42,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/erm.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 9394f1c08d..487266a32a 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"] @@ -174,11 +186,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 }, @@ -422,7 +440,8 @@ export default { }, }, agreement_table_settings, - 1 + 1, + additional_filters ) }, }, -- 2.39.5