From bf8c4c05945fc5d0afb0b540b1d4609a56087efe Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 1 Mar 2023 14:55:53 +0100 Subject: [PATCH] Bug 33106: Add vendor link to ERM licenses This patch adds a "Licenses" link in the acquisition module to link to the licenses defined in the ERM module. Test plan: - Create a vendor - Create some licenses in the ERM module, add some to the vendor previously created - Go to the detail page of the vendor in the acquisition module => Notice the new "Licenses" tab on the side bar => Notice that this tab does not appear if you do not have the permission to see licenses - Click on the new tab => Notice that you are redirected to the license list view, in the ERM module, with an automatic filter on the vendor --- .../prog/en/includes/vendor-menu.inc | 5 +++++ .../prog/js/vue/components/ERM/LicensesList.vue | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc index 3fc669e840b..394bf6c6dea 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc @@ -1,3 +1,4 @@ +[% USE Koha %] [% IF ( booksellerid ) %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue index 2780385df5f..9433c98a4e2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue @@ -41,6 +41,9 @@ export default { return { licenses: [], initialized: false, + column_filters: { + vendor_id: this.$route.query.vendor_id || null, + }, } }, beforeRouteEnter(to, from, next) { @@ -91,7 +94,7 @@ export default { window[av_cat] = map_av_dt_filter(av_cat) }) - $("#" + table_id).kohaTable( + let table = $("#" + table_id).kohaTable( { ajax: { url: "/api/v1/erm/licenses", @@ -109,6 +112,7 @@ export default { }, }, ], + iDeferLoading: true, columns: [ { title: __("Name"), @@ -289,6 +293,15 @@ export default { license_table_settings, 1 ) + + let table_dt = table.DataTable() + if (this.column_filters.vendor_id) { + table + .find('thead tr:eq(1) th[data-filter="vendors"] select') + .val(this.column_filters.vendor_id) + table_dt.column(1).search(this.column_filters.vendor_id) + } + table_dt.draw() }, }, props: { -- 2.25.1