Bugzilla – Attachment 170460 Details for
Bug 36594
Library hours display issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36594: Library hours display issues
Bug-36594-Library-hours-display-issues.patch (text/plain), 7.86 KB, created by
David Nind
on 2024-08-16 20:05:21 UTC
(
hide
)
Description:
Bug 36594: Library hours display issues
Filename:
MIME Type:
Creator:
David Nind
Created:
2024-08-16 20:05:21 UTC
Size:
7.86 KB
patch
obsolete
>From bb315ba57a2d8e6fafa6e2b8d01cd9d91317ce01 Mon Sep 17 00:00:00 2001 >From: CJ Lynce <cj.lynce@westlakelibrary.org> >Date: Tue, 13 Aug 2024 20:52:34 +0000 >Subject: [PATCH] Bug 36594: Library hours display issues > >The following issues existing when displays library hours in > koha/admin/branches.pl >-For newly created or edited libraries, 'null' is displayed when that > time is undefined. >-Time is displayed with seconds, which are not necessary. >-The system preference CalendarFirstDayOfWeek is not respected when > viewing a specific library with hours defined. > >This patch corrects these issues: >-Undefined values are properly handled. All open & close times are > undefined, the library is considered as not having hours set. >-If open and close times for a day are both undefined, the library > is considered closed. >-Time is now displayed in the format HH:MM >-CalendarFirstDayOfWeek is respected when viewing a library with > defined hours. > >To Test: > >1. Login to staff interface >2. Go to Koha administration > Basic parameters > Libraries >3. Edit any library or create a new library. Do not set hours. Save. >4. On the library list, in the hours column, all days are displayed > with null. >5. Edit or create a 2nd library, set some hours, leaving at least one > day without hours. Save. >6. In the library list, in the hours column, defined times are in the > format HH:MM:SS. >7. Edit the system preference CalendarFirstDayOfWeek to set a day other > than Sunday as the first day of the week. >8. Return to Go to Koha administration > Basic parameters > Libraries >9. Click on the name of a specific library with hours to view details. >10. The order of the calendar week still starts with Sunday. > >11. Apply Patch. >12. Return to Go to Koha administration > Basic parameters > Libraries >13. Check that your library with all undefined times shows "Library > hours not set". >14. Check that your library with defined hours is showing times in > HH:MM format, and days without defined hours are "Closed". >15. Click on the name of a library with hours to view details. Verify > that the calendar week starts respects CalendarFirstDayOfWeek. >16. Click on the name of another library without hours to view details. > Verify these libraries show as "No opening hours have been set" > in the branch detail view. > >Sponsored-by: Westlake Porter Public Library >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/en/modules/admin/branches.tt | 49 +++++++++++++++---- > 1 file changed, 40 insertions(+), 9 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >index d4bd388f27..bcb107297e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >@@ -556,7 +556,16 @@ > </li> > <li> > <span class="label">Opening hours: </span> >- [% IF library.library_hours.count > 0 # Existing library %] >+ [% SET CalendarFirstDayOfWeek = Koha.Preference("CalendarFirstDayOfWeek") %] >+ [% SET set_hours = 0 %] >+ [% IF library.library_hours.count > 0 %] >+ [% FOR i IN [0..6] %] >+ [% IF library.library_hours.as_list.$i.open_time != null || library.library_hours.as_list.$i.close_time != null %] >+ [% set_hours = 1 %] >+ [% END %] >+ [% END %] >+ [% END %] >+ [% IF set_hours > 0 # Existing library %] > [% SET library_hours = library.library_hours.as_list %] > <table id="library_hours_table"> > <thead> >@@ -574,12 +583,18 @@ > <td> > <span>[% PROCESS dayname day=d %]</span> > </td> >- <td> >- <span>[% hr.open_time | html %]</span> >- </td> >- <td> >- <span>[% hr.close_time | html %]</span> >- </td> >+ [% IF hr.open_time == null && hr.close_time == null %] >+ <td colspan="2" style="text-align: center;"> >+ <span>Closed</span> >+ </td> >+ [% ELSE %] >+ <td> >+ <span>[% IF hr.open_time != null %][% hr.open_time.substr(0,5) | html %][% END %]</span> >+ </td> >+ <td> >+ <span>[% IF hr.close_time != null %][% hr.close_time.substr(0,5) | html %][% END %]</span> >+ </td> >+ [% END %] > </tr> > [% END %] > </tbody> >@@ -757,7 +772,15 @@ > { > "data": function( row, type, val, meta ) { > let result = ''; >+ let set_hours = 0; > if ( row.library_hours.length > 0 ) { >+ for (let check_counter = 0; check_counter < 7; check_counter++) { >+ if ( row.library_hours[check_counter].open_time != null || row.library_hours[check_counter].close_time != null ) { >+ set_hours = 1; >+ } >+ } >+ } >+ if ( set_hours > 0 ) { > const daysOfWeek = [ _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday") ]; > > result = '<table id="library_hours_table"><thead><tr><th>Day</th><th>Open time</th><th>Close time</th></tr></thead><tbody>'; >@@ -766,8 +789,16 @@ > const day = i % 7; // Wrap around the day using modulo operator > result += '<tr id="hours_'+day+'">'; > result += '<td>'+daysOfWeek[day]+'</td>'; >- result += '<td><span>'+row.library_hours[day].open_time+'</span></td>'; >- result += '<td><span>'+row.library_hours[day].close_time+'</span></td>'; >+ if ( row.library_hours[day].open_time == null && row.library_hours[day].close_time == null ) { >+ result += '<td colspan="2" style="text-align: center;"><span>Closed</span></td>'; >+ } else { >+ result += '<td><span>'; >+ result += row.library_hours[day].open_time != null ? row.library_hours[day].open_time.substr(0,5) : ''; >+ result += '</span></td>'; >+ result += '<td><span>'; >+ result += row.library_hours[day].close_time != null ? row.library_hours[day].close_time.substr(0,5) : ''; >+ result += '</span></td>'; >+ } > result += '</tr>'; > counter++; > } >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36594
:
170298
|
170460
|
171152
|
171153
|
171213
|
171220
|
171229
|
171952
|
172233