[Bps-public-commit] rtx-calendar branch allow-custom-field-based-events-2 updated. 1.05-15-g6dc455c

BPS Git Server git at git.bestpractical.com
Fri Sep 1 19:07:13 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, allow-custom-field-based-events-2 has been updated
       via  6dc455c07b85f368c383d4b587fe5db5ddcd7ee0 (commit)
       via  9fd0d6a4118f24f6dc9a2853109754575f4c9939 (commit)
      from  ccc15614ce49b21aacbf86bbfe601693fbfb110a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6dc455c07b85f368c383d4b587fe5db5ddcd7ee0
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Sep 1 16:01:43 2023 -0300

    Support Custom Field based events on Calendar Portlet
    
    Calendar Portlet was not supporting Custom Field based events yet. Fixed
    it.
    
    Also add the custom sorting of events withing a day.

diff --git a/html/Elements/MyCalendar b/html/Elements/MyCalendar
index 175c7e9..5220934 100644
--- a/html/Elements/MyCalendar
+++ b/html/Elements/MyCalendar
@@ -23,7 +23,7 @@
     <td class="<% @classes %>"><div class="inside-day">
       <div class="calendardate"><%$date->day%></div>
 
-%     for my $t ( @{ $Tickets{$date->strftime("%F")} } ) {
+%     for my $t ( $SortCalendarEvents->( @{ $Tickets{ $date->strftime("%F") } || [] } )) {
         <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &>
 %     }
 
@@ -71,8 +71,23 @@ if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) )
 }
 
 # we search all date types in Format string
-my @Dates = grep { $Format =~ m/__${_}(Relative)?__/ } @DateTypes;
+my @CoreDates    = grep { $Format =~ m/__${_}(Relative)?__/ } @DateTypes;
+my @CustomFields = ( $Format =~ /__(CustomField\.\{.*\})__/g );
+my @DateCustomFields;
+
+for my $CustomField (@CustomFields) {
+    my $LintCustomField = $CustomField;
+    $LintCustomField =~ s/CustomField\.\{(.*)\}/$1/;
+    my $CustomFieldObj = RT::CustomField->new( RT->SystemUser );
+    $CustomFieldObj->LoadByName( Name => $LintCustomField );
+    push @DateCustomFields, $CustomField
+        if $CustomFieldObj->id
+        && ( $CustomFieldObj->Type eq 'Date'
+        || $CustomFieldObj->Type eq 'DateTime' );
+}
 
+my @Dates = (@CoreDates, @DateCustomFields);
+ at Dates = map { $_ =~ s/^CustomField\.(.*)$/CF.$1/; $_ } @Dates;
 # used to display or not a date in Element/CalendarEvent
 my %DateTypes = map { $_ => 1 } @Dates;
 
@@ -82,4 +97,6 @@ $m->callback( CallbackName => 'BeforeFindTickets', ARGSRef => \%ARGS, QueryRef =
 
 my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $Query, \@Dates);
 
+my $SortCalendarEvents = RT->Config->Get("CalendarSortEvents");
+
 </%INIT>

commit 9fd0d6a4118f24f6dc9a2853109754575f4c9939
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Sep 1 15:43:38 2023 -0300

    Fix event icon rendering in calendar
    
    GetIcon method was returning random icon for events with date fields
    with the same value, even the date field was not used in the Format of
    the Search.

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index cb3b26c..d9f9975 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -168,7 +168,7 @@ sub GetEventImg {
     my $EventIcon;
     my %CalendarIcons = RT->Config->Get('CalendarIcons');
 CALENDAR_ICON:
-    for my $DateField ( keys %CalendarIcons ) {
+    for my $DateField ( sort keys %{$DateTypes} ) {
 
       # Icon can be a combination of two dates such as Due-Created,
       # or CF.{Date Field}-Created. It can be also single date such as Created

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

Summary of changes:
 html/Elements/MyCalendar | 21 +++++++++++++++++++--
 lib/RTx/Calendar.pm      |  2 +-
 2 files changed, 20 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
rtx-calendar


More information about the Bps-public-commit mailing list