From 42e1e1aac3ebc11d40527e876f741dfcb58470b5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 30 May 2022 12:04:34 +0200 Subject: [PATCH] Bug 32030: Fix header searches Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../prog/en/includes/erm-search.inc | 28 ++++++++-- .../intranet-tmpl/prog/en/modules/erm/erm.tt | 51 ++----------------- .../js/vue/components/ERM/AgreementsList.vue | 11 ++-- .../components/ERM/EHoldingsPackagesList.vue | 5 +- .../components/ERM/EHoldingsTitlesList.vue | 4 +- .../js/vue/components/ERM/LicensesList.vue | 5 +- 6 files changed, 45 insertions(+), 59 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/erm-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/erm-search.inc index 9f6e62b04e..35778ba6eb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/erm-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/erm-search.inc @@ -1,18 +1,36 @@ [% USE Koha %]
-

[% LibraryName | html %]

+

[% LibraryName | html %]

- + 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 4ea0633133..fcef81f6b5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt @@ -33,62 +33,19 @@ const agreement_renewal_priorities = [% To.json(AuthorisedValues.Get('ERM_AGREEMENT_RENEWAL_PRIORITY')) | $raw %]; const agreement_user_roles = [% To.json(AuthorisedValues.Get('ERM_AGREEMENT_USER_ROLES')) | $raw %]; - var agreement_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'agreements', 'agreements', 'json' ) | $raw %]; - - var agreements_table_url = '/api/v1/erm/agreements?'; - [% IF agreement_name_filter %] - var agreement_name_filter = { - 'name': { - "like": '%[%- agreement_name_filter | html -%]%' - } - }; - agreements_table_url += 'q='+ encodeURIComponent(JSON.stringify(agreement_name_filter)); - [% END %] - const license_types = [% To.json(AuthorisedValues.Get('ERM_LICENSE_TYPE')) | $raw %]; const license_statuses = [% To.json(AuthorisedValues.Get('ERM_LICENSE_STATUS')) | $raw %]; - var license_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'licenses', 'licenses', 'json' ) | $raw %]; - - var licenses_table_url = '/api/v1/erm/licenses?'; - [% IF license_name_filter %] - var license_name_filter = { - 'name': { - "like": '%[%- license_name_filter | html -%]%' - } - }; - licenses_table_url += 'q='+ encodeURIComponent(JSON.stringify(license_name_filter)); - [% END %] - const agreement_license_statuses = [% To.json(AuthorisedValues.Get('ERM_AGREEMENT_LICENSE_STATUS')) | $raw %]; const agreement_license_location = [% To.json(AuthorisedValues.Get('ERM_AGREEMENT_LICENSE_LOCATION')) | $raw %]; const package_types = [% To.json(AuthorisedValues.Get('ERM_PACKAGE_TYPE')) | $raw %]; const package_content_types = [% To.json(AuthorisedValues.Get('ERM_PACKAGE_CONTENT_TYPE')) | $raw %]; - var eholdings_packages_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'eholdings', 'packages', 'json' ) | $raw %]; - - var eholdings_packages_table_url = '/api/v1/erm/eholdings/packages?'; - [% IF eholdings_package_name_filter %] - var eholdings_package_name_filter = { - 'name': { - "like": '%[%- eholdings_package_name_filter | html -%]%' - } - }; - eholdings_packages_table_url += 'q='+ encodeURIComponent(JSON.stringify(eholdings_package_name_filter)); - [% END %] - - var eholdings_titles_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'eholdings', 'titles', 'json' ) | $raw %]; - - var eholdings_titles_table_url = '/api/v1/erm/eholdings/titles?'; - [% IF eholdings_title_name_filter %] - var eholdings_title_name_filter = { - 'name': { - "like": '%[%- eholdings_title_name_filter | html -%]%' - } - }; - eholdings_titles_table_url += 'q='+ encodeURIComponent(JSON.stringify(eholding_title_name_filter)); - [% END %] + const agreement_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'agreements', 'agreements', 'json' ) | $raw %]; + const license_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'licenses', 'licenses', 'json' ) | $raw %]; + const eholdings_packages_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'eholdings', 'packages', 'json' ) | $raw %]; + const eholdings_titles_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'eholdings', 'titles', 'json' ) | $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 451493f3de..38fa2c8808 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 @@ -63,6 +63,8 @@ export default { let show_agreement = this.show_agreement let edit_agreement = this.edit_agreement let delete_agreement = this.delete_agreement + let default_search = this.$route.query.q + window['vendors'] = this.vendors.map(e => { e['_id'] = e['id'] e['_str'] = e['name'] @@ -101,13 +103,14 @@ export default { }, {}) window['av_agreement_is_perpetual'] = [{ _id: 0, _str: _('No') }, { _id: 1, _str: _("Yes") }] - $('#agreement_list').kohaTable({ + const table = $('#agreement_list').kohaTable({ "ajax": { - "url": agreements_table_url, + "url": "/api/v1/erm/agreements", }, "order": [[0, "asc"]], + "search": { search: default_search }, "columnDefs": [{ - "targets": [0,2], + "targets": [0, 2], "render": function (data, type, row, meta) { if (type == 'display') { return escape_str(data) @@ -123,7 +126,7 @@ export default { "orderable": true, "render": function (data, type, row, meta) { // Rendering done in drawCallback - return ""; + return "" } }, { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsPackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsPackagesList.vue index 1ec680eea1..87f5b83df2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsPackagesList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsPackagesList.vue @@ -62,6 +62,8 @@ export default { let show_package = this.show_package let edit_package = this.edit_package let delete_package = this.delete_package + let default_search = this.$route.query.q + window['vendors'] = this.vendors.map(e => { e['_id'] = e['id'] e['_str'] = e['name'] @@ -92,9 +94,10 @@ export default { $('#package_list').kohaTable({ "ajax": { - "url": eholdings_packages_table_url, + "url": "/api/v1/erm/eholdings/packages", }, "order": [[0, "asc"]], + "search": { search: default_search }, "columnDefs": [{ "targets": [0], "render": function (data, type, row, meta) { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsTitlesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsTitlesList.vue index c651d601ef..5ff6afda73 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsTitlesList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsTitlesList.vue @@ -56,6 +56,7 @@ export default { let show_title= this.show_title let edit_title= this.edit_title let delete_title= this.delete_title + let default_search = this.$route.query.q window['vendors'] = this.vendors.map(e => { e['_id'] = e['id'] @@ -69,9 +70,10 @@ export default { $('#title_list').kohaTable({ "ajax": { - "url": eholdings_titles_table_url, + "url": "/api/v1/erm/eholdings/titles", }, "order": [[0, "asc"]], + "search": { search: default_search }, "columnDefs": [{ "targets": [1], "render": function (data, type, row, meta) { 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 9aed343ee6..7bc77da64d 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 @@ -33,6 +33,8 @@ export default { let show_license = this.show_license let edit_license = this.edit_license let delete_license = this.delete_license + let default_search = this.$route.query.q + window['av_license_types'] = this.av_license_types.map(e => { e['_id'] = e['authorised_value'] e['_str'] = e['lib'] @@ -54,9 +56,10 @@ export default { $('#license_list').kohaTable({ "ajax": { - "url": licenses_table_url, + "url": "/api/v1/erm/licenses", }, "order": [[0, "asc"]], + "search": { search: default_search }, "columnDefs": [{ "targets": [0, 1], "render": function (data, type, row, meta) { -- 2.39.5