Permalink
Browse files

Less code, more feature with SavedSearch widget.

  • Loading branch information...
1 parent b466770 commit 2a7b8882973a316acca6ee4fdc48fd2a9d2ff650 Chia-liang Kao committed Nov 23, 2006
Showing with 26 additions and 55 deletions.
  1. +13 −13 html/Reports/Activity/Elements/LimitReport
  2. +13 −42 html/Reports/Activity/index.html
@@ -1,24 +1,24 @@
<form action="index.html" method="GET">
Query:
-<textarea name="query" rows="5" cols="80"><% $query %></textarea><br />
+<textarea name="Query" rows="5" cols="80"><% $Query %></textarea><br />
-Report type: <select name="type">
-<option value="ActivityDetail" <% $ARGS{path} =~ /ActivityDetail/ ? 'selected' : '' %>>Activity detail</option>
-<option value="ActivitySummary" <% $ARGS{path} =~ /ActivitySummary/ ? 'selected' : '' %>>Activity summary</option>
-<option value="ResolutionComments" <% $ARGS{path} =~ /ResolutionComments/ ? 'selected' : '' %>>Resolution comments</option>
-<option value="ResolutionStatistics" <% $ARGS{path} =~ /ResolutionStatistics/ ? 'selected' : '' %>>Resolution statistics</option>
-<option value="WorkedStatistics" <% $ARGS{path} =~ /WorkedStatistics/ ? 'selected' : '' %>>Time worked statistics</option>
+Report type: <select name="ReportType">
+<option value="ActivityDetail" <% $ReportType =~ /ActivityDetail/ ? 'selected' : '' %>>Activity detail</option>
+<option value="ActivitySummary" <% $ReportType =~ /ActivitySummary/ ? 'selected' : '' %>>Activity summary</option>
+<option value="ResolutionComments" <% $ReportType =~ /ResolutionComments/ ? 'selected' : '' %>>Resolution comments</option>
+<option value="ResolutionStatistics" <% $ReportType =~ /ResolutionStatistics/ ? 'selected' : '' %>>Resolution statistics</option>
+<option value="WorkedStatistics" <% $ReportType =~ /WorkedStatistics/ ? 'selected' : '' %>>Time worked statistics</option>
</select><br />
-Start date: <input type="text" name="start" value="<% $start %>" /><br />
-End date: <input type="text" name="end" value="<% $end %>" /><br />
+Start date: <input type="text" name="Start" value="<% $Start %>" /><br />
+End date: <input type="text" name="End" value="<% $End %>" /><br />
<& /Elements/Submit, Label => loc('Report') &>
</form>
<%args>
-$type => undef
-$start => undef
-$end => undef
-$query => undef
+$ReportType => undef
+$Start => undef
+$End => undef
+$Query => undef
</%args>
<%init>
</%init>
@@ -1,32 +1,18 @@
<&| Elements/Wrapper, %ARGS, title => loc("Activity reports"), show_print_link => 0 &>
<& /Elements/ListActions, actions => \@actions &>
-% if ($type) {
-<form method="post" action="index.html" name="SaveChart">
-
-<& /Search/Elements/SelectSearchObject, Name => 'Owner', Objects => \@Objects &><br />
-
-<&|/l&>Description</&>:<br>
-<font size="-1"><input size="25" name="Description" value="" /></font>
-<input type="hidden" class="hidden" name="query" value="<% $query %>" />
-<input type="hidden" class="hidden" name="start" value="<% $start %>" />
-<input type="hidden" class="hidden" name="end" value="<% $end %>" />
-<input type="hidden" class="hidden" name="type" value="<% $type %>" />
-
-<input type="submit" name="Save" value="<%loc('Save')%>" class="button" />
-</form>
-
-<& /Search/Elements/ActivityReport, Query => $query, Start => $start, End => $end, ReportType => $type &>
+% if ($ReportType) {
+<& /Widgets/SavedSearch:show, %ARGS, Action => 'index.html', self => $saved_search &>
+<& /Search/Elements/ActivityReport, %ARGS &>
% }
</&>
<%args>
-$type => undef
+$ReportType => undef
$start => undef
$end => undef
$query => undef
-$Description => undef
</%args>
<%init>
unless ($start) {
@@ -41,30 +27,15 @@
$ARGS{end} = substr($now->ISO,0,10);
}
-my @Objects = RT::SavedSearches->new( $session{CurrentUser} )->_PrivacyObjects;
-push @Objects, RT::System->new($session{'CurrentUser'})
- if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
- Right => 'SuperUser');
+$ARGS{ReportType} ||= $ARGS{type};
+$ARGS{Start} ||= $ARGS{start};
+$ARGS{End} ||= $ARGS{end};
+$ARGS{Query} ||= $ARGS{query};
-my @actions;
-if ( $ARGS{Save} ) {
- my $saved_search = RT::SavedSearch->new( $session{'CurrentUser'} );
- my ( $ok, $search_msg ) = $saved_search->Save(
- Privacy => $ARGS{'Owner'},
- Name => $Description,
- Type => 'ActivityReport',
- SearchParams => {
- Query => $query,
- ReportType => $type,
- Start => $start,
- End => $end,
- });
- if ($ok) {
- push @actions, loc( 'Report [_1] saved.', $Description );
- }
- else {
- push @actions, [ loc("Can't save report").': '.loc($search_msg), 0 ];
- }
-}
+my $saved_search = $m->comp( '/Widgets/SavedSearch:new',
+ SearchType => 'ActivityReport',
+ SearchFields => [qw(Query ReportType Start End)] );
+
+my @actions = $m->comp( '/Widgets/SavedSearch:process', args => \%ARGS, self => $saved_search );
</%init>

0 comments on commit 2a7b888

Please sign in to comment.