From e6341bb01533cc32252676ea40bb94bbd2613a37 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sat, 12 Apr 2014 14:58:12 -0700 Subject: [PATCH] installers (calendaring), RT#16584 --- rt/share/html/Elements/CalendarSlotHeaderSchedule | 17 ++ rt/share/html/Elements/CalendarSlotSchedule | 90 ++++++++++ rt/share/html/Search/Calendar.html | 198 ++++++++++------------ rt/share/html/Search/Schedule.html | 4 +- 4 files changed, 195 insertions(+), 114 deletions(-) create mode 100644 rt/share/html/Elements/CalendarSlotHeaderSchedule create mode 100644 rt/share/html/Elements/CalendarSlotSchedule diff --git a/rt/share/html/Elements/CalendarSlotHeaderSchedule b/rt/share/html/Elements/CalendarSlotHeaderSchedule new file mode 100644 index 000000000..d7e1b76b9 --- /dev/null +++ b/rt/share/html/Elements/CalendarSlotHeaderSchedule @@ -0,0 +1,17 @@ +<%ARGS> +$Date => undef +$Tickets => undef +$DateTypes => undef +@username => () +$slots => $default_slots + +% foreach my $username ( @username ) { + <% $username %> +% } +% if ( scalar(@username) < $slots ) { + + +% } +<%ONCE> +my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5; + diff --git a/rt/share/html/Elements/CalendarSlotSchedule b/rt/share/html/Elements/CalendarSlotSchedule new file mode 100644 index 000000000..e94bddfe2 --- /dev/null +++ b/rt/share/html/Elements/CalendarSlotSchedule @@ -0,0 +1,90 @@ +<%ARGS> + @Tickets => () + $slots => $default_slots, + $sday => undef, + $tod_row => undef, + $timestep => $default_timestep, + +<%SHARED> +my @slots = ( [], [], [], [], [], [], [] ); + +% warn $sday; +% #for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { +% for my $t (@Tickets) { +% +% #XXX off by 1h on daylight savings boundaries... 2 sundays a year +% my $starts = ($t->StartsObj->Unix - $t->StartsObj->SetToMidnight(Timezone=>'user'))/60; +% +% if ( $starts >= $tod_row && $starts < ($tod_row + $timestep) ) { +% #then we're a new entry, find a slot for us +% my $s = 0; +% while ( ref($slots[$sday]->[$s]) ) { $s++ } +% $slots[$sday]->[$s] = [ $t->Id, $t ]; +% } +% +% #XXX also off by 1h on daylight savings boundaries +% my $due = $t->DueObj->Unix - $t->DueObj->SetToMidnight; +% +% if ( $due <= $tod_row && $due > ($tod_row + $timestep ) ) { +% #then find our slot and remove us +% @{ $slots[$sday] } = +% map { (!ref($_) || $_->[0] != $t->Id) ? $_ : '' } +% @{ $slots[$sday] }; +% } +% +% } +% +% pop @{ $slots[$sday] } while @{ $slots[$sday] } && !ref($slots[$sday]->[-1]); +% +% #now display: +% +% if ( scalar(@{$slots[$sday]}) > $slots ) { +% #overflow situation, eek... could be handled better, how? + + + class="weekly +%# <% $is_today ? 'today' +%# : $is_yesterday ? 'yesterday' +%# : $is_aweekago ? 'aweekago' +%# : '' +%# %> + " + >MULTIPLE + + +% } else { +% +% foreach my $slot ( @{ $slots[$sday] } ) { +% my( $id, $ticket ) = @$slot; + + <% $id %> + + +% } +% +% if ( scalar(@{$slots[$sday]}) < $slots ) { + + + class="weekly +%# <% $is_today ? 'today' +%# : $is_yesterday ? 'yesterday' +%# : $is_aweekago ? 'aweekago' +%# : '' +%# %> + " + > + +% } +% +% } +<%ONCE> +my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5; +my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h + diff --git a/rt/share/html/Search/Calendar.html b/rt/share/html/Search/Calendar.html index c425751ff..bf07ff3e2 100644 --- a/rt/share/html/Search/Calendar.html +++ b/rt/share/html/Search/Calendar.html @@ -1,21 +1,22 @@ -<%args> -$Month => (localtime)[4] -$Year => (localtime)[5] + 1900 -$Query => undef -$Format => undef -$Order => undef -$OrderBy => undef +<%ARGS> +$Month => (localtime)[4] +$Year => (localtime)[5] + 1900 +$Query => undef +$Format => undef +$Order => undef +$OrderBy => undef $RowsPerPage => undef -$NewQuery => 0 -$WeekDay => undef -$WeekMonth => undef -$WeekYear => undef -$OrigMonth => undef -$OrigYear => undef -$Embed => undef -$DayDisplay => undef -@DayDisplayArgs => () - +$NewQuery => 0 +$WeekDay => undef +$WeekMonth => undef +$WeekYear => undef +$OrigMonth => undef +$OrigYear => undef +$Embed => undef +$Display => undef +@DisplayArgs => () +$slots => $default_slots + % my $title; % if ( $WeekMonth ) { @@ -91,7 +92,7 @@ $DayDisplay => undef % if ( $WeekDay ) { - valign="middle"> + valign="middle"> <& week_collapse, date=>$start, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString, Embed=>$Embed, &> @@ -130,7 +131,7 @@ $DayDisplay => undef % if ( $date <= $end ) { #a second week? not going to work for week view yet - valign="middle"> + valign="middle"> <& week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString, Embed=>$Embed, &> % } @@ -138,115 +139,87 @@ $DayDisplay => undef % } #while ($date <= $end) -% my $sday = 0; -% my @slots = ( [], [], [], [], [], [], [] ); + + + +% #slot header callback +% if ( defined($Display) && $Display =~ /^(\w+)$/ ) { +% +% my $el = "/Elements/CalendarSlotHeader$1"; + +% for (0..6) { + <& $el, Date => $date, + DateTypes => \%DateTypes, + slots => $slots, + @DisplayArgs, + &> +% } +% } + + % foreach my $row ( @week_rows ) { <& td_time, $row &> % $date = $start; -% $sday = 0; +% my $sday = 0; % while ($date <= $end) { % % my $is_today = (DateTime->compare($today, $date) == 0); % my $is_yesterday = (DateTime->compare($yesterday, $date) == 0); % my $is_aweekago = (DateTime->compare($aweekago, $date) == 0); -%# -%# class="<% $is_today ? 'today' -%# : $is_yesterday ? 'yesterday' -%# : $is_aweekago ? 'aweekago' -%# : '' -%# %>" -%# > - -% #XXX display these in a time aware fashion -%#% my $sp = 3; -%#% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { -%#% $sp--; -%# <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &> -%#% } -%# <% ($sp>0) ? '
'x$sp : '' |n %> - -% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { +% #slot callback +% if ( defined($Display) && $Display =~ /^(\w+)$/ ) { +% my $el = "/Elements/CalendarSlot$1"; + <& $el, Date => $date, + DateTypes => \%DateTypes, + Tickets => $Tickets{$date->strftime("%F")} || [], + slots => $slots, + sday => $sday, + tod_row => $row, + timestep => $timestep, + @DisplayArgs, + &> +% } else { + +% #just display the normal events for this day? + +% for my $Ticket ( @{ $Tickets{$date->strftime("%F")} } ) { +% my %dt = +% map { $_=>1 } +% grep { +% my $meth = $_.'Obj'; % -% #XXX off by 1h on daylight savings boundaries... two sundays a year -% my $starts = ($t->StartsObj->Unix - $t->StartsObj->SetToMidnight(Timezone=>'user'))/60; +% #XXX off by 1h on daylight savings boundaries.. 2 sundays a year +% my $tod = ( $Ticket->$meth->Unix +% - $Ticket->$meth->SetToMidnight(Timezone=>'user') +% ) / 60; % -% if ( $starts >= $row && $starts < ($row + $timestep) ) { -% #then we're a new entry, find a slot for us -% my $s = 0; -% while ( ref($slots[$sday]->[$s]) ) { $s++ } -% $slots[$sday]->[$s] = [ $t->Id, $t ]; +% RTx::Calendar::LocalDate($Ticket->$meth->Unix) eq $date->strftime('%F') #today +% && $tod >= $row && $tod < ($row+$timestep); #and in timeslot +% } keys %DateTypes; +% next unless keys %dt; + <& /Elements/CalendarEvent, + Object => $Ticket, + Date => $date, + DateTypes => \%dt + &> +% unless ( $Ticket eq ${ $Tickets{$date->strftime("%F")} }[-1] ) { #hmm, no.. not with "next unless $dt" :/ +
+% } % } -% -% #XXX also off by 1h on daylight savings boundaries -% my $due = $t->DueObj->Unix - $t->DueObj->SetToMidnight; -% -% if ( $due <= $row && $due > ($row + $timestep ) ) { -% #then find our slot and remove us -% @{ $slots[$sday] } = -% map { (!ref($_) || $_->[0] != $t->Id) ? $_ : '' } -% @{ $slots[$sday] }; -% } -% -% } -% -% pop @{ $slots[$sday] } while @{ $slots[$sday] } && !ref($slots[$sday]->[-1]); -% -% #now display: -% -% if ( scalar(@{$slots[$sday]}) > $slots ) { -% #overflow situation, eek... could be handled better, how? - - - class="weekly - <% $is_today ? 'today' - : $is_yesterday ? 'yesterday' - : $is_aweekago ? 'aweekago' - : '' - %>" - >MULTIPLE - - -% } else { -% -% foreach my $slot ( @{ $slots[$sday] } ) { -% my( $id, $ticket ) = @$slot; - - <% $id %> - + -% } -% -% if ( scalar(@{$slots[$sday]}) < $slots ) { - - - class="weekly - <% $is_today ? 'today' - : $is_yesterday ? 'yesterday' - : $is_aweekago ? 'aweekago' - : '' - %>" - > - -% } -% -% } +% } % $date = $set->next($date); % if ( $date->day_of_week == $startday_of_week ) { % if ( $date <= $end ) { #a second week? not going to work for week view yet - valign="middle"> + valign="middle"> <& week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString, Embed=>$Embed, &> % } @@ -254,6 +227,7 @@ $DayDisplay => undef % % $sday++; % } #while ($date <= $end) + % } #foreach my $row ( @week_rows ) % % } else { @@ -280,13 +254,13 @@ $DayDisplay => undef %>calendardate" ><% $date->day %> -% if ( defined($DayDisplay) && $DayDisplay =~ /^(\w+)$/ ) { +% if ( defined($Display) && $Display =~ /^(\w+)$/ ) { % % my $el = "/Elements/CalendarDay$1"; <& $el, Tickets => $Tickets{$date->strftime("%F")}, Date => $date, DateTypes => \%DateTypes, - @DayDisplayArgs, + @DisplayArgs, &> % % } else { @@ -407,7 +381,7 @@ $etime = 1080 unless $etime =~ /^\d+$/; #6pm my $timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h my $rowspan = ($etime-$stime) / $timestep; -my $slots = RT->Config->Get('CalendarWeeklySlots') || 5; +my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5; my $wt = $stime; my @week_rows = (); @@ -417,7 +391,7 @@ while ( $wt < $etime ) { push @week_rows, $wt; $wt+=$timestep } <%INIT> use RTx::Calendar qw(FirstDay LastDay LastDayOfWeek); -$Embed =~ /^[\w\.]+$/ or die 'xss'; +$Embed =~ /^[\w\.]*$/ or die 'xss'; my $title = loc("Calendar"); @@ -469,14 +443,14 @@ if ($Query) { Order => $Order, OrderBy => $OrderBy, Rows => $RowsPerPage, - @DayDisplayArgs, + @DisplayArgs, ); } else { $QueryString = $m->comp( '/Elements/QueryString', NewQuery => 1, - @DayDisplayArgs, + @DisplayArgs, ); } diff --git a/rt/share/html/Search/Schedule.html b/rt/share/html/Search/Schedule.html index bbbfffdc9..0f8896c87 100644 --- a/rt/share/html/Search/Schedule.html +++ b/rt/share/html/Search/Schedule.html @@ -8,8 +8,8 @@ <& /Search/Calendar.html, @_, Embed => 'Schedule.html', - DayDisplay => 'Schedule', - DayDisplayArgs => [ username => $ARGS{username} ], + Display => 'Schedule', + DisplayArgs => [ username => $ARGS{username} ], &> <%init> -- 2.11.0