From 77ee1b78c52cf00d5f5017eea47a78913d8755c3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 May 2019 09:50:04 -0500 Subject: [PATCH] Bug 22844: POC - Add patron attributes to the list TODO: - Handle 'checked' flag - Update code in memberentry.tt --- admin/preferences.pl | 16 ++++++++++++++++ .../intranet-tmpl/prog/en/modules/admin/preferences.tt | 2 ++ koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/admin/preferences.pl b/admin/preferences.pl index 2862e69ee1..21e98ac5e9 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -29,6 +29,7 @@ use C4::Log; use C4::Output; use C4::Templates; use Koha::Acquisition::Currencies; +use Koha::Patron::Attribute::Types; use File::Spec; use IO::File; use YAML::Syck qw(); @@ -375,6 +376,21 @@ if ( $tab ) { ); } +$template->param( + additional_db_columns => { + borrowers => { + map { + ( + key => $_->{code}, + val => $_->{code}, + description => $_->{description}, + checked => 0, + ) + } @{ Koha::Patron::Attribute::Types->search->unblessed } + } + } +); + $template->param( TABS => \@TABS ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt index c9ef8e7290..3ae20c2297 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -1,4 +1,5 @@ [% USE raw %] +[% USE To %] [% USE Asset %] [% USE Koha %] [% SET footerjs = 1 %] @@ -239,6 +240,7 @@ var MSG_ALL_VALUE_WARN = _("Note: _ALL_ value will override all other values"); var MSG_UPD_LOC_FORMAT_WARN = _("The following values are not formatted correctly:"); var MSG_INVALID = _( "Error: presence of invalid data prevent saving. Please make the corrections and try again." ); + var additional_db_columns = [% To.json( additional_db_columns ) %]; [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] [% Asset.js("js/ajax.js") | $raw %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js index 9d9599a4d8..bfcf052100 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js @@ -213,6 +213,10 @@ $( document ).ready( function () { var pref_value = this.value; var prefs = pref_value.split("|"); + var additional_items = []; + if ( additional_db_columns.hasOwnProperty(datasource) ) { + additional_items = additional_db_columns[datasource]; + } $.getJSON( themelang + "/modules/admin/preferences/" + datasource + ".json", function( data ){ var items = []; var checked = ""; @@ -224,6 +228,10 @@ $( document ).ready( function () { } items.push(''); }); + + $(additional_items).each(function(){ + items.push(''); + }); $("
", { "class": "columns-2", html: items.join("") -- 2.11.0