[Bps-public-commit] rtx-calendar branch multiple-days-events-pod-update created. 1.05-21-gf6cf414

BPS Git Server git at git.bestpractical.com
Wed Nov 8 14:19:48 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-pod-update has been created
        at  f6cf414386697e5cb0ab7f1828613d3060f4bfad (commit)

- Log -----------------------------------------------------------------
commit f6cf414386697e5cb0ab7f1828613d3060f4bfad
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Tue Nov 7 15:23:13 2023 -0300

    Update POD with new features
    
    Add information about custom field based events, multiple days events
    and new calendar portlets.
    
    Also bring the help section information from the UI to the POD in the
    usage section.

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index be2486b..dbd30c1 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -329,8 +329,23 @@ Date fields in the search results are displayed/used in the calendar,
 for example if you have a ticket with a due date, it won't be displayed on
 that date unless the Due field is included in the search result format.
 
-There's a portlet to put on your home page (see Prefs/MyRT.html), see the
-CONFIGURATION section below for details on adding it.
+You can also display events based on Date or DateTime custom fields on the
+Calendar.
+
+It can also show multiple-day events, such as a maintenance window that
+starts on one day and ends on another.
+
+Finally, you can see event details by hovering over the event in the
+calendar.
+
+=begin HTML
+
+<p><img width="500px" src="https://static.bestpractical.com/images/calendar/calendar.png" alt="Calendar Overview" /></p>
+
+=end HTML
+
+There are also special calendar portlets that you can add to your home
+page. See the CONFIGURATION section below for details on adding them.
 
 =head1 RT VERSION
 
@@ -375,20 +390,26 @@ RT dashboards:
 
 =over
 
-=item C<MyCalendar>, a summary of the events for the current week.
+=item C<MyCalendar>
+
+A summary of the events for the current week.
+
+=item C<Calendar>
 
-=item C<Calendar>, a full month of the calendar view, without sidebar.
+A full-month view of the calendar.
 
-=item C<CalendarWithSidebar>, a full month of the calendar view, with
-sidebar which includes an extra status filter and legends of the calendars.
+=item C<CalendarWithSidebar>
+
+A full-month view of the calendar, with a sidebar that includes an extra
+status filter and legends of the calendars.
 
 =back
 
 C<$HomepageComponents> in F<etc/RT_SiteConfig.pm>:
 
-  Set($HomepageComponents, [qw(QuickCreate Quicksearch
-     MyCalendar Calendar CalendarWithSidebar
-     MyAdminQueues MySupportQueues MyReminders RefreshHomepage)]);
+    Set($HomepageComponents, [qw(QuickCreate Quicksearch
+        MyCalendar Calendar CalendarWithSidebar
+        MyAdminQueues MySupportQueues MyReminders RefreshHomepage)]);
 
 =head2 Display configuration
 
@@ -404,11 +425,12 @@ F<etc/RT_SiteConfig.pm>:
 You can change which fields show up in the popup display when you
 mouse over a date in F<etc/RT_SiteConfig.pm>:
 
-    Set(@CalendarPopupFields,
-        ('Status',
-         'OwnerObj->Name',
-         'DueObj->ISO',
-         'CustomField.{Maintenance Estimated Start Date/Time - ET}'));
+    Set(@CalendarPopupFields, (
+        'Status',
+        'OwnerObj->Name',
+        'DueObj->ISO',
+        'CustomField.{Maintenance Estimated Start Date/Time - ET}',
+    ));
 
 =head3 Event colors
 
@@ -451,7 +473,7 @@ C<$CalendarIcons> setting to your F<etc/RT_SiteConfig.pm>:
             => 'maint.png',
     ));
 
-The images should be placed on F<local/static/images>.
+The images should be placed in F<local/static/images>.
 
 =head3 Multiple days events
 
@@ -459,19 +481,43 @@ You can define multiple days events by adding the C<%CalendarMultipleDaysEvents>
 setting to your F<etc/RT_SiteConfig.pm>:
 
     Set( %CalendarMultipleDaysEvents, (
-            'Maintenance' => {
-                'Starts' => 'Starts',
-                'Ends'   => 'Due',
-            },
-        )
-    );
+        'Maintenance' => {
+            'Starts' => 'Starts',
+            'Ends'   => 'Due',
+        },
+    ));
 
 Note that the Starts and Ends fields must be included in the search result
 Format in order the event to be displayed on the calendar.
 
 =head1 USAGE
 
-A small help section is available in /Search/Calendar.html
+=head2 Displaying reminders
+
+Reminders are displayed on the calendar only if you explicitly add the
+following clause to your query:
+
+    AND ( Type = 'ticket' OR Type = 'reminder' )
+
+=head2 Displaying other kind of dates
+
+By default, RTx::Calendar displays Due and Starts dates. You can select other
+date fields with the Display Columns section in the Query Builder.
+The following format will display the two additional date fields, LastUpdated and a
+custom field called Maintenance Date:
+
+    '<small>__Due__</small>',
+    '<small>__Starts__</small>',
+    '<small>__LastUpdated__</small>',
+    '<small>__CustomField.{Maintenance Date}__</small>'
+
+=head2 Changing the default query
+
+You can change the default query used by Calendar.html and Calendar portlets,
+by saving a query with the name C<calendar> in the Query Builder.
+
+Note that, first, the calendar will check for a user-level saved search,
+then a group-level saved search, and finally, a system-level saved search.
 
 =head1 AUTHOR
 

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

    Prevent infinite loops when rendering multi day events
    
    This prevents infinite or long loops when rendering multi day events
    if the user set an end 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 b698afe875cadf1dbb55f273193c542c484f28d3
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Nov 3 15:02:53 2023 -0300

    Fix bug causing multi day events to not show correctly
    
    The loop on the code checking if an event had multiple days had a bug
    caused by adding one day to each loop but using unixtime() to check if
    the event continued to the next day. This caused the last day of the
    event to be disconnected from the rest of the event if the end time
    of the event was before the start time.

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