From bda0d507820e915e0efc6762f012c86faabfd06e Mon Sep 17 00:00:00 2001
From: Julian Maurice <julian.maurice@biblibre.com>
Date: Wed, 13 Mar 2019 14:19:44 +0100
Subject: [PATCH] Bug 22505: Add column configuration to patron list table

Test plan:
1. Create a list of patrons
2. Add some patrons to this list
3. Go to this patron list
   (/cgi-bin/koha/patron_lists/list.pl?patron_list_id=XXX)
4. Verify that you can show/hide all columns except the one containing
   the checkbox
5. Verify that you can export the table data using the Export menu
6. Go to admin/columns_settings.pl, and verify that the configuration
   works for table 'patron-list-table'
---
 admin/columns_settings.yml                    | 22 +++++++++++++++++++
 .../prog/en/modules/patron_lists/list.tt      |  7 ++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml
index 6bc5c5502c..b49b747290 100644
--- a/admin/columns_settings.yml
+++ b/admin/columns_settings.yml
@@ -505,6 +505,28 @@ modules:
           columnname: itemtype
         -
           columnname: status
+    patron-lists:
+      patron-list-table:
+        -
+          columnname: checkbox
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
+        -
+          columnname: card
+        -
+          columnname: firstname
+        -
+          columnname: surname
+        -
+          columnname: address
+        -
+          columnname: category
+        -
+          columnname: library
+        -
+          columnname: expires_on
+        -
+          columnname: circ_notes
 
   reports:
     lostitems:
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt
index 64bbe6434e..0c184eed4a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt
@@ -1,8 +1,10 @@
 [% USE raw %]
 [% USE Asset %]
 [% USE KohaDates %]
+[% USE ColumnsSettings %]
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
+[% INCLUDE 'columns_settings.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Patron lists &rsaquo; [% list.name | html %] &rsaquo; Add patrons</title>
 [% INCLUDE 'doc-head-close.inc' %]
 
@@ -184,7 +186,8 @@
         $(document).ready(function() {
             $('#patrons_to_add_fieldset').hide();
 
-                $('#patron-list-table').dataTable($.extend(true, {}, dataTablesDefaults, {
+                var columns_settings_table = [% ColumnsSettings.GetColumns('members', 'patron-lists', 'patron-list-table', 'json') | $raw %]
+                KohaTable('patron-list-table', {
                     "order": [[ 3, "asc" ]],
                     "aoColumns": [
                         null,null,null,null,null,null,null,{ "sType": "title-string" },null
@@ -193,7 +196,7 @@
                         { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
                     ],
                     "sPaginationType": "four_button"
-                } ));
+                }, columns_settings_table);
 
             patron_autocomplete({
                 patron_container: $("#patrons_to_add"),
-- 
2.20.1