[Bps-public-commit] rtx-calendar branch multiple-days-events-2 created. 1.05-23-g0c82932

BPS Git Server git at git.bestpractical.com
Thu Nov 16 20:43:40 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtx-calendar".

The branch, multiple-days-events-2 has been created
        at  0c82932894e7a3a6b44999e134668dcc6833bd81 (commit)

- Log -----------------------------------------------------------------
commit 0c82932894e7a3a6b44999e134668dcc6833bd81
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Thu Nov 16 15:43:34 2023 -0500

    RTx-Calendar 1.07

diff --git a/CHANGES b/CHANGES
index 65b8f30..e74e797 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+1.07 2023-11-16
+ - Fix display of multiple day events
+ - Prevent infinite loops when rendering multiple days events
+ - Allow the calendar to be correctly changed to January
+ - Fix crash when changing months using the select boxes
+
 1.06 2023-10-24
  - Minimum version of RT 5.0
  - Add color-coded display of events by ticket status
diff --git a/META.yml b/META.yml
index 858676f..9215247 100644
--- a/META.yml
+++ b/META.yml
@@ -26,6 +26,6 @@ requires:
   perl: 5.10.1
 resources:
   license: http://opensource.org/licenses/gpl-license.php
-version: '1.06'
+version: '1.07'
 x_module_install_rtx_version: '0.43'
-x_requires_rt: '5.0'
+x_requires_rt: 5.0.0
diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index be2486b..7678054 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -4,7 +4,7 @@ use strict;
 use DateTime;
 use DateTime::Set;
 
-our $VERSION = "1.06";
+our $VERSION = "1.07";
 
 RT->AddStyleSheets('calendar.css');
 RT->AddJavaScript('calendar.js');

commit 21bf94a35b46e69449f2d76b588c7db006b8c03e
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Nov 16 14:49:25 2023 -0300

    Fix crash when changing months using the select boxes
    
    After changing a month using the nav links, the query string
    used to pre-populate the action of the form and other elements
    already had a month and year. Since the select boxes for month
    and year had the same name, both variables were considered arrays
    and failed to be parsed.

diff --git a/html/Elements/Calendar b/html/Elements/Calendar
index 3c23762..ff41edc 100644
--- a/html/Elements/Calendar
+++ b/html/Elements/Calendar
@@ -162,13 +162,13 @@ while ($date <= $end) {
 <td valign="top" align="center">
 <form method="post" class="changeCalendarMonth" onsubmit="changeCalendarMonth()">
 
-<select name="Month" class="selectpicker form-control col-3">
+<select name="SelectedMonth" class="selectpicker form-control col-3">
 % for (0..11) {
 <option value="<%$_%>" <% $_ == $Month ? 'selected' : ''%> ><%$rtdate->GetMonth($_)%></option>
 % }
 </select>
 % my $year = (localtime)[5] + 1900;
-<select name="Year" class="selectpicker form-control col-3">
+<select name="SelectedYear" class="selectpicker form-control col-3">
 % for ( ($year-5) .. ($year+5)) {
 <option value="<%$_%>" <% $_ == $Year ? 'selected' : ''%>><%$_%></option>
 % }
@@ -192,8 +192,8 @@ while ($date <= $end) {
 </div>
 <%INIT>
 my $NotFirstAccess = $DECODED_ARGS->{NotFirstAccess};
-my $Month = $DECODED_ARGS->{Month} // (localtime)[4];
-my $Year = $DECODED_ARGS->{Year}  || (localtime)[5] + 1900;
+my $Month = $DECODED_ARGS->{SelectedMonth} // $DECODED_ARGS->{Month} // (localtime)[4];
+my $Year = $DECODED_ARGS->{SelectedYear} // $DECODED_ARGS->{Year}  || (localtime)[5] + 1900;
 my $Query = $DECODED_ARGS->{Query};
 my $Format = $DECODED_ARGS->{Format};
 my $Order = $DECODED_ARGS->{Order};

commit 8f7d47ae9f22628b417bdac81a4b4f7b7e07b192
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Nov 16 11:56:34 2023 -0300

    Allow the calendar to be correctly changed to January
    
    There was a bug when switching from February to January or December to
    January because we send 0 to represent January and it was interpreted as
    false. Checking if the month argument is defined and setting it to the
    current month if not avoids the error.

diff --git a/html/Elements/Calendar b/html/Elements/Calendar
index 4af069e..3c23762 100644
--- a/html/Elements/Calendar
+++ b/html/Elements/Calendar
@@ -192,7 +192,7 @@ while ($date <= $end) {
 </div>
 <%INIT>
 my $NotFirstAccess = $DECODED_ARGS->{NotFirstAccess};
-my $Month = $DECODED_ARGS->{Month} || (localtime)[4];
+my $Month = $DECODED_ARGS->{Month} // (localtime)[4];
 my $Year = $DECODED_ARGS->{Year}  || (localtime)[5] + 1900;
 my $Query = $DECODED_ARGS->{Query};
 my $Format = $DECODED_ARGS->{Format};

commit 5bb25ec21bbd482ef41a3a00ac4c76b18f34b137
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Nov 3 15:09:11 2023 -0300

    Prevent infinite loops when rendering multiple days events
    
    This patch prevents infinite or long loops when rendering multiple days
    events if user set end date to a date many years in the future.

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index 46eeec1..be2486b 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -140,7 +140,11 @@ sub FindTickets {
 
             my $end_date = $ends_date->ISO( Time => 0, Timezone => 'user' );
             my $first_day = 1;
-            while ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
+            # We want to prevent infinite loops if user for some reason
+            # set a future date for year 3000 or something like that
+            my $prevent_infinite_loop = 0;
+            while ( ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
+                && ( $prevent_infinite_loop++ < 10000 ) )
             {
                 my $dateindex = $current_date->ISO( Time => 0, Timezone => 'user' );
 

commit 074f121088429d75ca4a336c559acdd170fe38c8
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Nov 3 15:02:53 2023 -0300

    Fix display of multiple days events
    
    The loop on the code that was checking if an event had multiple days had
    a minor bug because it was adding one day to each loop but using
    unixtime to check if the event had the next day ahead. That was causing
    the last day of the event to be disconnected from the rest if it was
    starting at a time lower than the start time of the event.

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index d37cae8..46eeec1 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -138,9 +138,9 @@ sub FindTickets {
                 Value => $starts_date->Unix,
             );
 
-            my $end_date_unix = $ends_date->Unix;
+            my $end_date = $ends_date->ISO( Time => 0, Timezone => 'user' );
             my $first_day = 1;
-            while ( $current_date->Unix <= $end_date_unix )
+            while ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
             {
                 my $dateindex = $current_date->ISO( Time => 0, Timezone => 'user' );
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
rtx-calendar


More information about the Bps-public-commit mailing list