From 6feaeaba9930c619e5dd625c89bf880641d3032a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 16 Nov 2021 16:46:48 -0300 Subject: [PATCH] Bug 29275: (follow-up) Split columns settings and handle upgrade This patch splits the table settings as we now have two tables. The atomic update takes care of setting the right values (if present) on the new tables entries. To test: 1. Do not apply this patch 2. Set some values you will remember for the checkoutshistory-table table 3. Run: $ koha-mysql kohadev > SELECT * FROM columns_settings WHERE tablename='checkoutshistory-table'; => SUCCESS: Koha currently works :-D 4. Apply this patch 5. Run: $ updatedatabase 6. Repeat 3 => SUCCESS: Things have been deleted 7. Run: $ koha-mysql kohadev > SELECT * FROM columns_settings WHERE tablename LIKE '%_checkouts-table'; => SUCCESS: old_checkouts-table and current_checkouts-table have the right setting 8. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- admin/columns_settings.yml | 23 ++++++++++++++- .../data/mysql/atomicupdate/bug_29275.pl | 28 +++++++++++++++++++ .../prog/en/modules/catalogue/issuehistory.tt | 11 +++++--- 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29275.pl diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 394b5d346e..02fc55c2a9 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -441,7 +441,28 @@ modules: - columnname: subscription_callnumber - checkoutshistory-table: + current_checkouts-table: + columns: + - + columnname: patron + cannot_be_toggled: 1 + cannot_be_modified: 1 + - + columnname: barcode + cannot_be_toggled: 1 + cannot_be_modified: 1 + - + columnname: checked_out_from + - + columnname: checked_out_by + - + columnname: renewed + - + columnname: checkout_on + - + columnname: due_date + + old_checkouts-table: columns: - columnname: patron diff --git a/installer/data/mysql/atomicupdate/bug_29275.pl b/installer/data/mysql/atomicupdate/bug_29275.pl new file mode 100755 index 0000000000..f029fe1f3d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_29275.pl @@ -0,0 +1,28 @@ +use Modern::Perl; + +return { + bug_number => "29275", + description => "Use the API to render checkout history for a biblio", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + # Migrate checkoutshistory-table => current_checkouts-table ('checkin_on' excluded) + $dbh->do(q{ + INSERT INTO columns_settings + SELECT 'catalogue', 'detail', 'current_checkouts-table', columnname, cannot_be_toggled, is_hidden + FROM columns_settings WHERE tablename='checkoutshistory-table' AND columnname<>'checkin_on'; + }); + # Migrate checkoutshistory-table => old_checkouts-table ('checkin_on' included) + $dbh->do(q{ + INSERT INTO columns_settings + SELECT 'catalogue', 'detail', 'old_checkouts-table', columnname, cannot_be_toggled, is_hidden + FROM columns_settings WHERE tablename='checkoutshistory-table'; + }); + # Clean the old table settings + $dbh->do(q{ + DELETE FROM columns_settings + WHERE tablename='checkoutshistory-table'; + }); + }, +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt index d427bbf30f..32bb6a39e2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt @@ -220,17 +220,20 @@ }, columns_settings); } - var columns_settings = [% TablesSettings.GetColumns('catalogue', 'detail', 'checkoutshistory-table', 'json') %]; + var old_checkouts_columns_settings = [% TablesSettings.GetColumns('catalogue', 'detail', 'old_checkouts-table', 'json') %]; + var current_checkouts_columns_settings = [% TablesSettings.GetColumns('catalogue', 'detail', 'current_checkouts-table', 'json') %]; + [% UNLESS show_patron_column %] // Remove the patron column definition - columns_settings.splice(0,1); + old_checkouts_columns_settings.splice(0,1); + current_checkouts_columns_settings.splice(0,1); [% END %] var show_patron_column = [% IF show_patron_column %]1[% ELSE %]0[% END %]; var default_sort_column = 3 + show_patron_column; - var old_checkouts = initialize_checkouts_table( '#old_checkouts', default_sort_column, true, columns_settings ); - var current_checkouts = initialize_checkouts_table( '#current_checkouts', default_sort_column, false, columns_settings.slice(0,-1) ); + var old_checkouts = initialize_checkouts_table( '#old_checkouts', default_sort_column, true, old_checkouts_columns_settings ); + var current_checkouts = initialize_checkouts_table( '#current_checkouts', default_sort_column, false, current_checkouts_columns_settings ); }); [% END %] -- 2.20.1