[Bps-public-commit] rt-extension-mobileui branch, master, updated. 23fa073d9f7bcdb063be02031d12aef4c252f7ae

Jesse Vincent jesse at bestpractical.com
Wed Aug 4 17:40:13 EDT 2010


The branch, master has been updated
       via  23fa073d9f7bcdb063be02031d12aef4c252f7ae (commit)
      from  78ea21e90e8bd0eb8a9b3ce523b308a0d799e884 (commit)

Summary of changes:
 html/m/_elements/menu        |    4 +---
 html/m/_elements/ticket_list |   22 ++++++++++++++++++----
 html/m/tickets/search        |    4 +++-
 3 files changed, 22 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit 23fa073d9f7bcdb063be02031d12aef4c252f7ae
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Aug 4 14:42:09 2010 -0700

    order of searches for saved searches

diff --git a/html/m/_elements/menu b/html/m/_elements/menu
index f1549da..adcf8fd 100644
--- a/html/m/_elements/menu
+++ b/html/m/_elements/menu
@@ -49,10 +49,8 @@ if ( $session{'CurrentUser'}->HasRight( Right  => 'LoadSavedSearch', Object => $
         foreach my $object (@Objects) {
             my @searches = $object->Attributes->Named('SavedSearch');
             foreach my $search (@searches) {
-                warn $search->SubValue("SearchType") ." is the type";
                 next unless $search->SubValue("SearchType") eq 'Ticket';
-                warn YAML::Dump($search->Content); use YAML;
-                push @menu, { label => $search->Description, url => '/m/tickets/search?q=' . $search->SubValue("Query") };
+                push @menu, { label => $search->Description, url => '/m/tickets/search?query=' . $search->SubValue("Query").'&order='.$search->SubValue("Order").'&order_by='.$search->SubValue("OrderBy") };
 
             }
         }
diff --git a/html/m/_elements/ticket_list b/html/m/_elements/ticket_list
index 8877cc2..b69829d 100644
--- a/html/m/_elements/ticket_list
+++ b/html/m/_elements/ticket_list
@@ -1,4 +1,6 @@
 <%args>
+$order => undef
+$order_by => undef
 $query => ''
 $page => 1
 </%args>
@@ -7,11 +9,23 @@ my $collection = RT::Tickets->new($session{'CurrentUser'});
 $collection->FromSQL($query);
 $collection->RowsPerPage(10);
 $collection->GotoPage($page-1);
-$collection->OrderBy( FIELD => 'id', ORDER => 'desc');
+# XXX: ->{'order_by'} is hacky, but there is no way to check if
+# collection is ordered or not
+if ( $order_by) {
+        my @order_by = split /\|/, $order_by;
+        my @order = split /\|/,$order;
+    $collection->OrderByCols(
+        map { { FIELD => $order_by[$_], ORDER => $order[$_] } }
+        ( 0 .. $#order_by )
+    );
+}
+
+
+
 $collection->RedoSearch();
  
 if ($page > 1 && ! @{$collection->ItemsArrayRef||[]}) {
-    RT::Interface::Web::Redirect( RT->Config->Get('WebURL')."/m/tickets/search?page=".($page-1)."&query=".$query);
+    RT::Interface::Web::Redirect( RT->Config->Get('WebURL')."/m/tickets/search?page=".($page-1)."&query=".$query."&order=$order&order_by=$order_by");
 }
 
 </%init>
@@ -37,11 +51,11 @@ loc("Found [quant,_1,ticket]",$collection->Count) &>
 </ul>
 <div id="paging">
 % if ($page > 1) { 
-<a href="<%RT->Config->Get('WebPath')%>/m/tickets/search?page=<%$page-1%>&query=<%$query%>">Back</a>
+<a href="<%RT->Config->Get('WebPath')%>/m/tickets/search?page=<%$page-1%>&query=<%$query%>&order=<%$order%>&order_by=<%$order_by%>">Back</a>
 % }
 Page <%$page%>
 
-<a href="<%RT->Config->Get('WebPath')%>/m/tickets/search?page=<%$page+1%>&query=<%$query%>">Next</a>
+<a href="<%RT->Config->Get('WebPath')%>/m/tickets/search?page=<%$page+1%>&query=<%$query%>&order=<%$order%>&order_by=<%$order_by%>">Next</a>
 </div>
 </&>
 </&>
diff --git a/html/m/tickets/search b/html/m/tickets/search
index 7ae31ff..c9a0b00 100644
--- a/html/m/tickets/search
+++ b/html/m/tickets/search
@@ -1,5 +1,7 @@
 <%args>
 $page => 1
+$order_by => 'id'
+$order => 'desc'
 </%args>
 <%init>
 use RT::Search::Googleish;
@@ -15,6 +17,6 @@ if ($ARGS{'q'}) {
 
 }
 
-$m->comp('../_elements/ticket_list', query => $query, page => $page);
+$m->comp('../_elements/ticket_list', query => $query, page => $page, order_by => $order_by, order => $order);
 $m->abort();
 </%init>

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



More information about the Bps-public-commit mailing list