[Bps-public-commit] rtx-calendar branch allow-custom-field-based-events created. 1.05-6-ge950a51
BPS Git Server
git at git.bestpractical.com
Tue Aug 22 17:19:57 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 has been created
at e950a511ea92100b33a002f1bba0078f2e206e3a (commit)
- Log -----------------------------------------------------------------
commit e950a511ea92100b33a002f1bba0078f2e206e3a
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Tue Aug 22 14:17:11 2023 -0300
Add Status Filter to Calendar
Allow user to filter events by status.
Also update the table header to be a bootstrap div container instead
of a table, so it can accommodate the new filter better.
diff --git a/html/Search/Calendar.html b/html/Search/Calendar.html
index 71ea271..3ccc107 100644
--- a/html/Search/Calendar.html
+++ b/html/Search/Calendar.html
@@ -7,6 +7,9 @@ $Order => undef
$OrderBy => undef
$RowsPerPage => undef
$NewQuery => 0
+ at FilterOnStatus => undef
+$BaseQuery => undef
+$FilterOnStatusClear => undef
</%args>
<& /Elements/Header, Title => $title &>
@@ -22,29 +25,57 @@ $NewQuery => 0
<&| /Widgets/TitleBox,
title => loc('Calendar for [_1] [_2]', $rtdate->GetMonth($Month), $Year) &>
-<table width="100%">
-<tr>
-<td align="left">
+<form id="FilterOnStatusForm"
+ action="<%$RT::WebPath%>/Search/Calendar.html?<%$QueryString%>" method="post">
+ <input type="hidden" name="BaseQuery" value="<%$BaseQuery%>" />
+ <div class="container col-12 mt-1 mb-1">
+ <div class="row align-items-center">
+ <div class="col-1 text-left">
% my ($PMonth, $PYear) = ($Month - 1, $Year);
% if ($PMonth < 0) {
% $PYear--;
% $PMonth = 11;
% }
-<a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">« <%$rtdate->GetMonth($PMonth)%></a>
-</td>
-<th align="center">
- <font size="+1"><% $rtdate->GetMonth($Month). " $Year" %></font>
-</th>
-<td align="right">
+ <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">« <%$rtdate->GetMonth($PMonth)%></a>
+ </div>
+ <div class="col text-center">
+ <div class="row">
+ <div class="col-2">
+ <font size="+1"><% $rtdate->GetMonth($Month). " $Year" %></font>
+ </div>
+ <div class="col-2 label"><% loc( 'Filter on [_1]', loc('Status') ) %>:</div>
+ <div class="col-3">
+ <select name="FilterOnStatus" id="FilterOnStatus"
+ class="selectpicker form-control tall" multiple="multiple" size="6">
+% for my $Status (sort keys %StatusesAvailable) {
+ <option value="<% $Status %>"
+% if (@FilterOnStatus && $FilterOnStatus[0]) {
+ <% (grep { $Status eq $_ } @FilterOnStatus) ? 'selected="selected"':''%>
+% }
+ ><% loc($Status) %></option>
+% }
+ </select>
+ </div>
+ <div class="col-2 text-left">
+% if ($FilterOnStatus[0]) {
+ <button type="submit" id="FilterOnStatusClear" name="FilterOnStatusClear"
+ value="1" class="button btn btn-primary"><% loc('Clear') %></button>
+% }
+ <input type="submit" value="<% loc('Filter') %>" class="button btn btn-primary" />
+ </div>
+ </div>
+ </div>
+ <div class="col-1 text-right">
% my ($NMonth, $NYear) = ($Month + 1, $Year);
% if ($NMonth > 11) {
% $NYear++;
% $NMonth = 0;
% }
-<a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%> »</a>
-</td>
-</tr>
-</table>
+ <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%> »</a>
+ </div>
+ </div>
+</div>
+</form>
<table class="rtxcalendar">
@@ -219,6 +250,11 @@ my %legend = (
</%ONCE>
<%INIT>
+if ($FilterOnStatusClear) {
+ $Query = $BaseQuery if $BaseQuery;
+ @FilterOnStatus = ();
+}
+$BaseQuery ||= $Query;
my $title = loc("Calendar");
my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/;
@@ -256,10 +292,16 @@ my $set = DateTime::Set->from_recurrence(
next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) }
);
+if ($FilterOnStatus[0]) {
+ my $StatusClause = join " OR ", map { "Status = '$_'" } @FilterOnStatus;
+ $Query .= " AND " if $Query;
+ $Query .= "($StatusClause)";
+}
+
my $QueryString =
$m->comp(
'/Elements/QueryString',
- Query => $Query,
+ Query => $BaseQuery,
Format => $Format,
Order => $Order,
OrderBy => $OrderBy,
@@ -302,6 +344,15 @@ $m->callback( CallbackName => 'BeforeFindTickets', ARGSRef => \%ARGS, QueryRef =
my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F"));
+my %StatusesAvailable;
+for my $Dates (keys %Tickets) {
+ my $TicketsOnTheDate = $Tickets{$Dates};
+ for my $Ticket (@$TicketsOnTheDate) {
+ my $Status = $Ticket->Status;
+ $StatusesAvailable{$Status}++;
+ }
+}
+
my $SortCalendarEvents = sub {
return @_;
};
commit 5c6a9fd71ac85a15a869b1b821586fccb3949abf
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Thu Aug 17 15:44:01 2023 -0300
Update the legend of the Calendar
Upgrade the code of the legend area to match bootstrap 4.
Added the custom icons to the legend.
Added the custom colors and their statuses to the legend.
diff --git a/html/Search/Calendar.html b/html/Search/Calendar.html
index 5225cca..71ea271 100644
--- a/html/Search/Calendar.html
+++ b/html/Search/Calendar.html
@@ -116,23 +116,54 @@ $NewQuery => 0
</tr>
</table>
-<table width="100%">
-% foreach my $legend (sort keys %legend) {
- <tr>
- <td align="right">
- <img src="<%$RT::WebImagesURL%>/<%$legend%>.png" />
- </td>
- <td align="left">
-% my $more = 0;
-% foreach ( @{$legend{$legend}} ) {
- <% $more++ ? ', ' : '' %>
- <&|/l&><% $_ %></&>
+<div class="container mt-4">
+ <div class="row">
+ <div class="col-6">
+ <div class="row">
+ <div class="col-2 pl-1 pr-1"> </div>
+ <div class="col-auto text-left pl-1 pr-1"><b><&|/l&>Event Types</&></b></div>
+ </div>
+% foreach my $legend (sort keys %legend) {
+ <div class="row">
+ <div class="col-3 text-right pl-1 pr-1">
+ <img src="<%$RT::WebImagesURL%>/<%$legend%>.png" />
+ </div>
+ <div class="col text-left pl-1 pr-1">
+% my $more = 0;
+% foreach ( @{$legend{$legend}} ) {
+ <% $more++ ? ', ' : '' %>
+ <&|/l&><% $_ %></&>
+% }
+ </div>
+ </div>
+% }
+% if (RT->Config->Get('CalendarCustomIcons')) {
+% my %CalendarCustomIcons = RT->Config->Get('CalendarCustomIcons');
+% foreach my $legend (sort keys %CalendarCustomIcons) {
+% my $legendLabel = $legend;
+% $legendLabel =~ s/^CF\.\{(.*)\}/$1/;
+ <div class="row">
+ <div class="col-3 text-right pl-1 pr-1">
+ <span class="tip"><% $CalendarCustomIcons{$legend}|n %></span>
+ </div>
+ <div class="col text-left pl-1 pr-1">
+ <&|/l&><% $legendLabel %></&>
+ </div>
+ </div>
% }
- </td>
- </tr>
-% }
-
-</table>
+% }
+ </div>
+ <div class="col-6">
+% if (RT->Config->Get('CalendarColorStatusMap')) {
+ <b><&|/l&>State Colors</&></b><br />
+% my %ColorStatusMap = RT->Config->Get('CalendarColorStatusMap');
+% foreach my $Status (sort { lc($a) cmp lc($b) } keys %ColorStatusMap) {
+ <span style="color: <% $ColorStatusMap{$Status} %>"><% $Status %><span><br />
+% }
+% }
+ </div>
+ </div>
+</div>
</&>
commit 3a7a63e931398674a710c6a6d4649302e8f1c2eb
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Thu Aug 17 15:43:46 2023 -0300
Add feature to customize Icon of events on the calendar
Since we allow now to add custom fields to the calendar, we need to
allow to customize the icon of the event based on its type.
diff --git a/html/Elements/CalendarEvent b/html/Elements/CalendarEvent
index ca374f7..9a6750f 100644
--- a/html/Elements/CalendarEvent
+++ b/html/Elements/CalendarEvent
@@ -6,45 +6,7 @@ $DateTypes => undef
<div class="day">
<small>
-% if ($IsReminder and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today) {
- <img src="<%$RT::WebImagesURL%>/reminder.png" />
-
-% } elsif ($DateTypes->{Resolved}
-% and RTx::Calendar::LocalDate($Object->ResolvedObj->Unix) eq $today) {
- <img src="<%$RT::WebImagesURL%>/resolved.png" />
-
-% } elsif ($DateTypes->{Starts} and $DateTypes->{Due}
-% and RTx::Calendar::LocalDate($Object->StartsObj->Unix) eq $today and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today ) {
- <img src="<%$RT::WebImagesURL%>/starts_due.png" />
-
-% } elsif ($DateTypes->{Due} and $DateTypes->{Created}
-% and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today and RTx::Calendar::LocalDate($Object->CreatedObj->Unix) eq $today ) {
- <img src="<%$RT::WebImagesURL%>/created_due.png" />
-
-% } elsif ($DateTypes->{Starts}
-% and RTx::Calendar::LocalDate($Object->StartsObj->Unix) eq $today) {
- <img src="<%$RT::WebImagesURL%>/starts.png" />
-
-% } elsif ($DateTypes->{Due}
-% and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today) {
- <img src="<%$RT::WebImagesURL%>/due.png" />
-
-% } elsif ($DateTypes->{Created}
-% and RTx::Calendar::LocalDate($Object->CreatedObj->Unix) eq $today) {
- <img src="<%$RT::WebImagesURL%>/created.png" />
-
-% } elsif ($DateTypes->{Started}
-% and RTx::Calendar::LocalDate($Object->StartedObj->Unix) eq $today) {
- <img src="<%$RT::WebImagesURL%>/started.png" />
-
-% } elsif ($DateTypes->{LastUpdated}
-% and RTx::Calendar::LocalDate($Object->LastUpdatedObj->Unix) eq $today) {
- <img src="<%$RT::WebImagesURL%>/updated.png" />
-
-% } else {
- <img src="<%$RT::WebImagesURL%>/reminder.png" />
-% }
-
+ <% RTx::Calendar::GetEventIcon($Object, $today, $DateTypes, $IsReminder)|n %>
<a href="<%$RT::WebPath%>/Ticket/Display.html?id=<%$TicketId%>" <% $StatusColor|n %>>
<% $Object->QueueObj->Name %> #<% $TicketId %>
<% $display_owner ? 'by ' . $Object->OwnerObj->Name : '' %>
diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index 61eeb5d..5ebd0f9 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -141,6 +141,73 @@ sub SearchDefaultCalendar {
}
}
+sub GetEventIcon {
+ my $Object = shift;
+ my $CurrentDate = shift;
+ my $DateTypes = shift;
+ my $IsReminder = shift;
+ my $EventIcon;
+ if (RT->Config->Get('CalendarCustomIcons')) {
+ my %CalendarCustomIcons = RT->Config->Get('CalendarCustomIcons');
+ for my $DateField (keys %CalendarCustomIcons) {
+ my $DateValue;
+ if ($DateField =~ /^CF\./){
+ my $cf = $DateField;
+ $cf =~ s/^CF\.\{(.*)\}/$1/;
+ $DateValue = $Object->FirstCustomFieldValue($cf);
+ next unless $DateValue;
+ $DateValue =~ s/(.*) (.*)/$1/;
+ } else {
+ my $DateObj = $DateField . "Obj";
+ $DateValue = LocalDate( $Object->$DateObj->Unix );
+ }
+ if ($DateValue eq $CurrentDate) {
+ $EventIcon = $CalendarCustomIcons{$DateField};
+ return $EventIcon;
+ }
+ }
+ }
+ if ($IsReminder and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $CurrentDate) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/reminder.png" />';
+
+ } elsif ($DateTypes->{Resolved}
+ and RTx::Calendar::LocalDate($Object->ResolvedObj->Unix) eq $CurrentDate) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/resolved.png" />';
+
+ } elsif ($DateTypes->{Starts} and $DateTypes->{Due}
+ and RTx::Calendar::LocalDate($Object->StartsObj->Unix) eq $CurrentDate and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $CurrentDate ) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/starts_due.png" />';
+
+ } elsif ($DateTypes->{Due} and $DateTypes->{Created}
+ and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $CurrentDate and RTx::Calendar::LocalDate($Object->CreatedObj->Unix) eq $CurrentDate ) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/created_due.png" />';
+
+ } elsif ($DateTypes->{Starts}
+ and RTx::Calendar::LocalDate($Object->StartsObj->Unix) eq $CurrentDate) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/starts.png" />';
+
+ } elsif ($DateTypes->{Due}
+ and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $CurrentDate) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/due.png" />';
+
+ } elsif ($DateTypes->{Created}
+ and RTx::Calendar::LocalDate($Object->CreatedObj->Unix) eq $CurrentDate) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/created.png" />';
+
+ } elsif ($DateTypes->{Started}
+ and RTx::Calendar::LocalDate($Object->StartedObj->Unix) eq $CurrentDate) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/started.png" />';
+
+ } elsif ($DateTypes->{LastUpdated}
+ and RTx::Calendar::LocalDate($Object->LastUpdatedObj->Unix) eq $CurrentDate) {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/updated.png" />';
+
+ } else {
+ $EventIcon = '<img src="' . $RT::WebImagesURL . '/reminder.png" />';
+ }
+ return $EventIcon;
+}
+
1;
__END__
@@ -241,6 +308,14 @@ adding the C<$CalendarColorStatusMap> setting to your F<etc/RT_SiteConfig.pm>:
'resolved' => '#aaa',
));
+Custom Icons can be defined for the events in the calendar by adding the
+C<$CalendarCustomIcons> setting to your F<etc/RT_SiteConfig.pm>:
+
+ Set(%CalendarCustomIcons, (
+ 'CF.{Maintenance Estimated Start Date/Time - ET}'
+ => '<small class="ml-1"><i class="fas fa-cog"></i></small>'
+ ));
+
=head1 USAGE
A small help section is available in /Search/Calendar.html
commit d280bf44f1f9c0cafbec71303b726c82b3beaebf
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Thu Aug 17 15:32:18 2023 -0300
Add feature to customize color of events on the calendar
diff --git a/html/Elements/CalendarEvent b/html/Elements/CalendarEvent
index 0f891b1..ca374f7 100644
--- a/html/Elements/CalendarEvent
+++ b/html/Elements/CalendarEvent
@@ -45,7 +45,7 @@ $DateTypes => undef
<img src="<%$RT::WebImagesURL%>/reminder.png" />
% }
- <a href="<%$RT::WebPath%>/Ticket/Display.html?id=<%$TicketId%>">
+ <a href="<%$RT::WebPath%>/Ticket/Display.html?id=<%$TicketId%>" <% $StatusColor|n %>>
<% $Object->QueueObj->Name %> #<% $TicketId %>
<% $display_owner ? 'by ' . $Object->OwnerObj->Name : '' %>
<% length($Object->Subject) > 80 ? substr($Object->Subject, 0, 77) . "..." : $Object->Subject %></a></small><br />
@@ -88,17 +88,30 @@ my $TicketId;
my $ticket;
my $subject;
my $IsReminder;
+my $status;
if ($Object->Type eq 'reminder') {
$IsReminder = 1;
if ($Object->RefersTo->First) {
- $ticket = $Object->RefersTo->First->TargetObj;
- $TicketId = $ticket->Id;
- $subject = $Object->Subject . " (" . $ticket->Subject . ")";
+ $ticket = $Object->RefersTo->First->TargetObj;
+ $TicketId = $ticket->Id;
+ $subject = $Object->Subject . " (" . $ticket->Subject . ")";
+ $status = $ticket->Status;
}
} else {
$TicketId = $Object->Id;
$subject = $Object->Subject;
+ $status = $Object->Status;
+}
+
+# Colors per status
+my %CalendarColorStatusMap;
+if (RT->Config->Get('CalendarColorStatusMap')) {
+ %CalendarColorStatusMap = RT->Config->Get('CalendarColorStatusMap');
+}
+my $StatusColor = '';
+if ($CalendarColorStatusMap{$status}) {
+ $StatusColor ='style="color: '.$CalendarColorStatusMap{$status}.'"';
}
my $display_owner = $RT::CalendarDisplayOwner;
diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index 6413b9c..61eeb5d 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -230,6 +230,17 @@ the events by status:
return @SortedTickets;
});
+It's also possible to change the color of the events in the calendar by
+adding the C<$CalendarColorStatusMap> setting to your F<etc/RT_SiteConfig.pm>:
+
+ Set(%CalendarColorStatusMap, (
+ 'new' => 'blue',
+ 'open' => 'blue',
+ 'approved' => 'green',
+ 'rejected' => 'red',
+ 'resolved' => '#aaa',
+ ));
+
=head1 USAGE
A small help section is available in /Search/Calendar.html
commit 46b06b2cd10ef5a79c408abdf20bb3b6623d8916
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Wed Aug 16 11:45:20 2023 -0300
Add setting to allow customize the sort order of the events
Add $CalendarSortCalendarEvents setting to allow customize the sort order
of the events in a day cell of the calendar. This is a sub that takes
the Objects list (that can be tickets or reminders) and returns a sorted
list of the objects.
diff --git a/html/Search/Calendar.html b/html/Search/Calendar.html
index 00caeff..5225cca 100644
--- a/html/Search/Calendar.html
+++ b/html/Search/Calendar.html
@@ -68,7 +68,7 @@ $NewQuery => 0
<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 &>
% }
@@ -271,4 +271,10 @@ $m->callback( CallbackName => 'BeforeFindTickets', ARGSRef => \%ARGS, QueryRef =
my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F"));
+my $SortCalendarEvents = sub {
+ return @_;
+};
+if (RT->Config->Get("CalendarSortCalendarEvents")) {
+ $SortCalendarEvents = RT->Config->Get("CalendarSortCalendarEvents");
+}
</%INIT>
diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index 3f03c77..6413b9c 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -220,6 +220,16 @@ mouse over a date in F<etc/RT_SiteConfig.pm>:
Set(@CalendarPopupFields, ('Status', 'OwnerObj->Name', 'DueObj->ISO'));
+You can set the order that the events will presented in the day cell with
+the C<$CalendarSortCalendarEvents> setting. The following example sorts
+the events by status:
+
+ Set($CalendarSortCalendarEvents, sub {
+ my @Tickets = @_;
+ my @SortedTickets = sort { lc($a->Status) cmp lc($b->Status) } @Tickets;
+ return @SortedTickets;
+ });
+
=head1 USAGE
A small help section is available in /Search/Calendar.html
commit 20a529c4f13e061592d8c0391a674a0df4d900a8
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Fri Jul 28 16:10:17 2023 -0300
Allow date time Custom Fields to be used in Calendar
It's possible now to add __CustomField.{Custom Field Name}__ to search
format so it will appear on calendar.
diff --git a/html/Elements/CalendarEvent b/html/Elements/CalendarEvent
index 5b8a6c5..0f891b1 100644
--- a/html/Elements/CalendarEvent
+++ b/html/Elements/CalendarEvent
@@ -41,6 +41,8 @@ $DateTypes => undef
% and RTx::Calendar::LocalDate($Object->LastUpdatedObj->Unix) eq $today) {
<img src="<%$RT::WebImagesURL%>/updated.png" />
+% } else {
+ <img src="<%$RT::WebImagesURL%>/reminder.png" />
% }
<a href="<%$RT::WebPath%>/Ticket/Display.html?id=<%$TicketId%>">
@@ -60,6 +62,9 @@ $DateTypes => undef
%
% if ($attr =~ /(.*)->ISO$/ and $Object->$1->Unix <= 0) {
% $value = '-';
+% } elsif ($attr =~ /CustomField\.\{(.*)\}$/) {
+% my $cf = $1;
+% $value = $Object->FirstCustomFieldValue($cf);
% } else {
% my $method = '$Object->'.$attr.'()';
% $method =~ s/->ISO\(\)$/->ISO( Timezone => 'user' )/;
@@ -123,6 +128,7 @@ for my $field (@display_fields) {
my $label = $field;
$label =~ s'Obj-.(?:AsString|Name|ISO)''g;
$label =~ s'-\>MemberEmailAddressesAsString''g;
+ $label =~ s/CustomField\.\{(.*)\}/$1/g;
$label_of{$field} = $label;
}
diff --git a/html/Search/Calendar.html b/html/Search/Calendar.html
index 9c5e71e..00caeff 100644
--- a/html/Search/Calendar.html
+++ b/html/Search/Calendar.html
@@ -192,6 +192,17 @@ my $title = loc("Calendar");
my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/;
+# push Date Time CFs to DateTypes
+my $CFs = RT::CustomFields->new($session{'CurrentUser'});
+$CFs->Limit(
+ FIELD => 'Type',
+ VALUE => 'DateTime',
+);
+
+while ( my $CF = $CFs->Next ) {
+ push @DateTypes, 'CustomField.{' . $CF->Name . '}';
+}
+
my $rtdate = RT::Date->new($session{'CurrentUser'});
my $weekstart = 'Sunday'; #RT::SiteConfig? user pref?
@@ -243,7 +254,13 @@ $TempQuery = $Query if $Query;
$TempFormat = $Format if $Format;
# we search all date types in Format string
-my @Dates = grep { $TempFormat =~ m/__${_}(Relative)?__/ } @DateTypes;
+my @Dates = grep {
+ my $LintField=${_};
+ $LintField=~s/(\{|\})/\\$1/;
+ $TempFormat =~ m/__$LintField(Relative)?__/
+} @DateTypes;
+
+ at Dates = map { $_ =~ s/^CustomField\.(.*)$/CF.$1/; $_ } @Dates;
# used to display or not a date in Element/CalendarEvent
my %DateTypes = map { $_ => 1 } @Dates;
diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index 9bb375d..3f03c77 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -71,14 +71,24 @@ sub FindTickets {
# How to find the LastContacted date ?
for my $Date (@$Dates) {
- my $DateObj = $Date . "Obj";
- push @{ $Tickets{ LocalDate( $Ticket->$DateObj->Unix ) } },
+ my $dateindex;
+ if ($Date =~ /^CF\./){
+ my $cf = $Date;
+ $cf =~ s/^CF\.\{(.*)\}/$1/;
+ $dateindex = $Ticket->FirstCustomFieldValue($cf);
+ next unless $dateindex;
+ $dateindex =~ s/(.*) (.*)/$1/;
+ } else {
+ my $DateObj = $Date . "Obj";
+ $dateindex = LocalDate( $Ticket->$DateObj->Unix );
+ }
+ push @{ $Tickets{$dateindex } },
$Ticket
# if reminder, check it's refering to a ticket
unless ( $Ticket->Type eq 'reminder'
and not $Ticket->RefersTo->First )
- or $AlreadySeen{ LocalDate( $Ticket->$DateObj->Unix ) }
+ or $AlreadySeen{ $dateindex }
{$Ticket}++;
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
rtx-calendar
More information about the Bps-public-commit
mailing list