Skip Menu |

This queue is for tickets about the RTx-Calendar CPAN distribution.

Report information
The Basics
Id: 41575
Status: resolved
Priority: 0/
Queue: RTx-Calendar

People
Owner: Nobody in particular
Requestors: rt.cpan [...] sartak.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Make the popup display fields configurable [patch]
Hi Nicolas, A client of ours is using RTx::Calendar and is very happy with it. They've asked us to change what is displayed in the popup window. I've made the fields configurable so everyone can benefit. :) It reuses some (kinda scary) code from Results.tsv. The default display hasn't really changed (I think requestors show email addresses instead of names). Shawn M Moore for Best Practical
Subject: parameterize-popup.diff
=== html/Elements/CalendarEvent ================================================================== --- html/Elements/CalendarEvent (revision 76799) +++ html/Elements/CalendarEvent (revision 76801) @@ -52,36 +52,24 @@ </a> :</strong> <% $subject%><br /> <br /> - <strong><&|/l&>Owner</&>:</strong> <%$Object->OwnerObj->Name %><br /> - <strong><&|/l&>Created</&>:</strong> <%$Object->CreatedObj->AsString %><br /> -% # Shoud we keep thoses dates ? - <strong><&|/l&>Starts</&>:</strong> <% $Object->StartsObj->Unix > 0 ? $Object->StartsObj->AsString : '-' %><br /> - <strong><&|/l&>Started</&>:</strong> <% $Object->StartedObj->Unix > 0 ? $Object->StartedObj->AsString : '-' %><br /> - <strong><&|/l&>LastUpdated</&>:</strong> <% $Object->LastUpdatedObj->Unix > 0 ? $Object->LastUpdatedObj->AsString : '-' %><br /> +%# logic taken from Ticket/Search/Results.tsv +% foreach my $attr (@display_fields) { +% my $value; +% +% if ($attr =~ /(.*)->ISO$/ and $Object->$1->Unix <= 0) { +% $value = '-'; +% } else { +% my $method = '$Object->'.$attr.'()'; +% $method =~ s/->ISO\(\)$/->ISO( Timezone => 'user' )/; +% $value = eval $method; +% if ($@) {die "Failed to find $attr - ". $@}; +% } - <strong><&|/l&>Due</&>:</strong> <% $Object->DueObj->Unix > 0 ? $Object->DueObj->AsString : '-' %><br /> + <strong><&|/l&><% $label_of{$attr} %></&>:</strong> <% $value %><br /> +% } -% # and those one - <strong><&|/l&>Resolved</&>:</strong> <% $Object->ResolvedObj->Unix > 0 ? $Object->ResolvedObj->AsString : '-' %><br /> - -% unless ($IsReminder) { - <strong><&|/l&>Status</&>:</strong> <%loc($Object->Status) %><br /> - <strong><&|/l&>Priority</&>:</strong> <%$Object->Priority %><br /> - <strong><&|/l&>Requestors</&>:</strong> - -% my $members = $Object->Requestors->MembersObj; -% if ($members->Count == 0) { -<&|/l&>none</&> -% } else { -% my @requestors; -% while (my $watcher = $members->Next) { -% push @requestors, $watcher->MemberObj->Object->Name; -% } -<% join ", ", @requestors %> -% } <br /> -% } </span> </div> @@ -107,4 +95,29 @@ $TicketId = $Object->Id; $subject = $Object->Subject; } + +# 3.6 config +my @display_fields = @RT::CalendarPopupFields; + +# 3.8 config +@display_fields = RT->Config->Get('CalendarPopupFields') + if @display_fields == 0; + +# defaults +if (@display_fields == 0) { + @display_fields = qw( + OwnerObj->Name CreatedObj->ISO StartsObj->ISO StartedObj->ISO + LastUpdatedObj->ISO DueObj->ISO ResolvedObj->ISO Status Priority + Requestors->MemberEmailAddressesAsString + ); +} + +my %label_of; +for my $field (@display_fields) { + my $label = $field; + $label =~ s'Obj-.(?:AsString|Name|ISO)''g; + $label =~ s'-\>MemberEmailAddressesAsString''g; + $label_of{$field} = $label; +} + </%init>
Here's a second version of the patch which fixes a bug if you're on 3.6 and don't specify the popup fields in your config.
=== html/Elements/CalendarEvent ================================================================== --- html/Elements/CalendarEvent (/mirror/bps-private/customers/maac/RTx-Calendar-Modified) (revision 76799) +++ html/Elements/CalendarEvent (/mirror/bps-private/customers/maac/RTx-Calendar-MAAC) (local) @@ -52,36 +52,24 @@ </a> :</strong> <% $subject%><br /> <br /> - <strong><&|/l&>Owner</&>:</strong> <%$Object->OwnerObj->Name %><br /> - <strong><&|/l&>Created</&>:</strong> <%$Object->CreatedObj->AsString %><br /> -% # Shoud we keep thoses dates ? - <strong><&|/l&>Starts</&>:</strong> <% $Object->StartsObj->Unix > 0 ? $Object->StartsObj->AsString : '-' %><br /> - <strong><&|/l&>Started</&>:</strong> <% $Object->StartedObj->Unix > 0 ? $Object->StartedObj->AsString : '-' %><br /> - <strong><&|/l&>LastUpdated</&>:</strong> <% $Object->LastUpdatedObj->Unix > 0 ? $Object->LastUpdatedObj->AsString : '-' %><br /> +%# logic taken from Ticket/Search/Results.tsv +% foreach my $attr (@display_fields) { +% my $value; +% +% if ($attr =~ /(.*)->ISO$/ and $Object->$1->Unix <= 0) { +% $value = '-'; +% } else { +% my $method = '$Object->'.$attr.'()'; +% $method =~ s/->ISO\(\)$/->ISO( Timezone => 'user' )/; +% $value = eval $method; +% if ($@) {die "Failed to find $attr - ". $@}; +% } - <strong><&|/l&>Due</&>:</strong> <% $Object->DueObj->Unix > 0 ? $Object->DueObj->AsString : '-' %><br /> + <strong><&|/l&><% $label_of{$attr} %></&>:</strong> <% $value %><br /> +% } -% # and those one - <strong><&|/l&>Resolved</&>:</strong> <% $Object->ResolvedObj->Unix > 0 ? $Object->ResolvedObj->AsString : '-' %><br /> - -% unless ($IsReminder) { - <strong><&|/l&>Status</&>:</strong> <%loc($Object->Status) %><br /> - <strong><&|/l&>Priority</&>:</strong> <%$Object->Priority %><br /> - <strong><&|/l&>Requestors</&>:</strong> - -% my $members = $Object->Requestors->MembersObj; -% if ($members->Count == 0) { -<&|/l&>none</&> -% } else { -% my @requestors; -% while (my $watcher = $members->Next) { -% push @requestors, $watcher->MemberObj->Object->Name; -% } -<% join ", ", @requestors %> -% } <br /> -% } </span> </div> @@ -107,4 +95,29 @@ $TicketId = $Object->Id; $subject = $Object->Subject; } + +# 3.6 config +my @display_fields = @RT::CalendarPopupFields; + +# 3.8 config +@display_fields = RT->Config->Get('CalendarPopupFields') + if @display_fields == 0 && RT->can('Config'); + +# defaults +if (@display_fields == 0) { + @display_fields = qw( + OwnerObj->Name CreatedObj->ISO StartsObj->ISO StartedObj->ISO + LastUpdatedObj->ISO DueObj->ISO ResolvedObj->ISO Status Priority + Requestors->MemberEmailAddressesAsString + ); +} + +my %label_of; +for my $field (@display_fields) { + my $label = $field; + $label =~ s'Obj-.(?:AsString|Name|ISO)''g; + $label =~ s'-\>MemberEmailAddressesAsString''g; + $label_of{$field} = $label; +} + </%init> === lib/RTx/Calendar.pm ================================================================== --- lib/RTx/Calendar.pm (/mirror/bps-private/customers/maac/RTx-Calendar-Modified) (revision 76799) +++ lib/RTx/Calendar.pm (/mirror/bps-private/customers/maac/RTx-Calendar-MAAC) (local) @@ -159,6 +159,11 @@ To enable private searches ICal feeds, you need to give CreateSavedSearch and LoadSavedSearch rights to your users. +You can change which fields show up in the popup display when you +mouse over a date in etc/RT_SiteConfig.pm : + + @CalendarPopupFields = ('Status', 'OwnerObj->Name', 'DueObj->ISO'); + =head1 USAGE A small help section is available in /Prefs/Calendar.html
Done in 0.7