[Rt-commit] rt branch, menu-redo, updated. 10030915165c6a2d6faee242390922e787240e2e

jesse jesse at bestpractical.com
Thu Nov 5 14:32:32 EST 2009


The branch, menu-redo has been updated
       via  10030915165c6a2d6faee242390922e787240e2e (commit)
       via  80378853b31d210ca41414c56944d69df540ed75 (commit)
       via  6295f29785f6e6984824e5e51005b42de018830a (commit)
       via  c73b757f8f18660a0d80bbebc69977afa4b2b09c (commit)
       via  202e9e99ff51d78e3f28fd7577ebe31899171e44 (commit)
       via  dcf69b65e2805aa160cd6bc4a4846e62afde93f8 (commit)
       via  f1cd431fbfe5ed16778ea1bfc10f3dfd68039bdd (commit)
       via  da5d00db20d316af38d3d49a802be01c90886d34 (commit)
       via  1cc9e1144e13ae58881e7f01c2f459023c342e55 (commit)
       via  7fee39c3c7454dfa7b5a686c0d5e06bea0c9f6ab (commit)
      from  020cda9dcff451e1b9fb69a272ec8cde6b36e434 (commit)

Summary of changes:
 Makefile.PL                                        |    1 +
 lib/RT/Action/UserSettings.pm                      |   88 +++++++----
 lib/RT/Dispatcher.pm                               |   28 ++--
 lib/RT/Interface/Web/QueryBuilder.pm               |  175 ++++++++++++++++++++
 .../Admin/Tools/Shredder/Elements/SelectPlugin     |    2 +-
 share/html/Elements/ListMenu                       |    2 +-
 share/html/REST/1.0/Forms/ticket/default           |    5 +-
 share/html/Search/Build.html                       |   22 +--
 share/html/Search/Elements/EditQuery               |  173 -------------------
 share/html/SelfService/Create.html                 |    2 +-
 share/html/SelfService/CreateTicketInQueue.html    |    2 +-
 t/api/action-createtickets.t                       |    2 +-
 t/approval/basic.t                                 |    2 +-
 t/mail/gateway.t                                   |    9 +-
 t/web/crypt-gnupg.t                                |    2 +-
 t/web/gnupg-select-keys-on-create.t                |    8 +-
 t/web/ticket_owner.t                               |    2 +-
 17 files changed, 277 insertions(+), 248 deletions(-)
 create mode 100644 lib/RT/Interface/Web/QueryBuilder.pm

- Log -----------------------------------------------------------------
commit 6295f29785f6e6984824e5e51005b42de018830a
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Nov 5 10:10:00 2009 -0500

    closer to working Search dispatching

diff --git a/Makefile.PL b/Makefile.PL
index 1929875..469e421 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -93,6 +93,7 @@ features(
         'Test::WWW::Mechanize' => '1.04',
         'Module::Refresh'      => '0.03',
         'Test::Expect'         => '0.31',
+		'Test::Email',
         'XML::Simple',
         'File::Find',
         'Test::Deep', => 0,
diff --git a/lib/RT/Dispatcher.pm b/lib/RT/Dispatcher.pm
index a3ef5f9..5af4f89 100644
--- a/lib/RT/Dispatcher.pm
+++ b/lib/RT/Dispatcher.pm
@@ -279,7 +279,7 @@ before qr{.*} => run {
     }
 };
 
-before qr'Dashboards/(\d*)?' => sub {
+before qr'Dashboards/(\d*)?' => run {
 	page_nav->child( _('Select'), url => "/Dashboards/index.html" );
 	require RT::Dashboard; # not a record class, so not autoloaded :/
     if ( RT::Dashboard->new->_privacy_objects( create => 1 ) ) {
@@ -301,7 +301,7 @@ before qr'Dashboards/(\d*)?' => sub {
 };
 
 
-before '/SelfService' => sub {
+before '/SelfService' => run {
 
     my $queues = RT::Model::QueueCollection->new();
     $queues->find_all_rows;
@@ -334,7 +334,7 @@ before '/SelfService' => sub {
 	#main_nav->child( B =>  html => $m->scomp('GotoTicket'))
 };
 
-before 'Admin/Queues' => sub {
+before 'Admin/Queues' => run {
         if ( Jifty->web->current_user->has_right( object => RT->system, right => 'AdminQueue' ) ) {
             page_nav->child( _('Select'), url => "/Admin/Queues/" );
             page_nav->child( _('Create'), url       => "/Admin/Queues/Modify.html?create=1");
@@ -358,7 +358,7 @@ before 'Admin/Queues' => sub {
     }
 };
 
-before '/Admin/Users' => sub {
+before '/Admin/Users' => run {
 if (Jifty->web->current_user->has_right( object => RT->system, right => 'AdminUsers')) {
 page_nav->child(_('Select'), url => "/Admin/Users/");
 page_nav->child(_('Create'), url => "/Admin/Users/Modify.html?create=1", separator => 1);
@@ -379,7 +379,7 @@ page_nav->child(_('Create'), url => "/Admin/Users/Modify.html?create=1", separat
 
 };
 
-before 'Admin/Groups' => sub {
+before 'Admin/Groups' => run {
 
 page_nav->child( _('Select') => url  => "/Admin/Groups/");
 page_nav->child( _('Create') => url      => "/Admin/Groups/Modify.html?create=1", separator => 1);
@@ -396,7 +396,7 @@ page_nav->child( _('Create') => url      => "/Admin/Groups/Modify.html?create=1"
 };
 
 
-before 'Admin/CustomFields/' => sub {
+before 'Admin/CustomFields/' => run {
     if ( Jifty->web->current_user->has_right( object => RT->system, right => 'AdminCustomField' ) ) {
         page_nav->child( _('Select'), url => "/Admin/CustomFields/" );
         page_nav->child(
@@ -422,7 +422,7 @@ before 'Admin/CustomFields/' => sub {
 
 };
 
-before 'Admin/Global/Workflows' => sub {
+before 'Admin/Global/Workflows' => run {
     if ( my $id = Jifty->web->request->argument('name') ) {
 
 		my $base = '/Admin/Global/Workflows';
@@ -440,14 +440,14 @@ before 'Admin/Global/Workflows' => sub {
     }
     };
 
-before 'Admin/Rules' => sub {
+before 'Admin/Rules' => run {
         page_nav->child(_('Select'), url  => "/Admin/Rules/");
         page_nav->child(_('Create'), url  => "/Admin/Rules/Modify.html?create=1");
 };
 
-before qr'(?:Ticket|Search)/' => sub {
-	my $self = shift;
-    if ( my $id = Jifty->web->request->argument('id') ) {
+before qr'(?:Ticket|Search)/' => run {
+    if ( (Jifty->web->request->argument('id')||'') =~ /^(\d+)$/) {
+		my $id = $1;
         my $obj = RT::Model::Ticket->new();
         $obj->load($id);
 
@@ -574,7 +574,7 @@ before qr'(?:Ticket|Search)/' => sub {
             page_nav->child( _('Advanced')    => url => "/Search/Edit.html$args" );
 
             if ($has_query) {
-                if ($self->{path} =~ qr|^Search/Results.html| &&    #XXX TODO better abstraction
+                if (Jifty->web->request->path =~ qr|^Search/Results.html| &&    #XXX TODO better abstraction
                     Jifty->web->current_user->has_right( right => 'SuperUser', object => RT->system )
                     )
                 {
@@ -595,7 +595,7 @@ before qr'(?:Ticket|Search)/' => sub {
             }
 };
 
-before 'User/Group' => sub {
+before 'User/Group' => run {
     if ( my $id = Jifty->web->request->argument('id') ) {
         my $obj = RT::Model::User->new();
         $obj->load($id);
@@ -609,7 +609,7 @@ before 'User/Group' => sub {
 
 };
 
-before 'Prefs' => sub {
+before 'Prefs' => run {
 	my $tabs;
 	my @searches = RT::System->new->saved_searches();
 

commit 80378853b31d210ca41414c56944d69df540ed75
Merge: 6295f29 c73b757
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Nov 5 10:14:22 2009 -0500

    Merge commit 'origin/3.999-trunk' into menu-redo
    
    * commit 'origin/3.999-trunk':
      small fix to share/html/REST/1.0/Forms/ticket/default
      path fix when calling /_elements/wrapper
      tiny warning fix
      case fix
      diag info things only when $ENV{TEST_VERBOSE} is true
      update Action/UserSettings.pm: display should be _()ed
      delete the  in Action/UserSettings, since it doesn't work well


commit 10030915165c6a2d6faee242390922e787240e2e
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Nov 5 11:13:34 2009 -0500

    First round of moving Search/Build logic to lib/

diff --git a/lib/RT/Interface/Web/QueryBuilder.pm b/lib/RT/Interface/Web/QueryBuilder.pm
new file mode 100644
index 0000000..788a9de
--- /dev/null
+++ b/lib/RT/Interface/Web/QueryBuilder.pm
@@ -0,0 +1,175 @@
+package RT::Interface::Web::QueryBuilder;
+use warnings;
+use strict;
+
+sub process_query {
+	my $self = shift;
+	my $ARGS = shift;
+	my $tree = shift;
+	my $selected = shift;
+	my $new = shift || [];
+
+my @NewSelection = ();
+
+my @results;
+if ( $ARGS->{'up'} || $ARGS->{'down'} ) {
+    if (@$selected) {
+        foreach my $value (@$selected) {
+            my $parent = $value->getParent;
+            my $index = $value->getIndex;
+            my $newindex = $index;
+            $newindex++ if $ARGS->{'down'};
+            $newindex-- if $ARGS->{'up'};
+            if ( $newindex < 0 || $newindex >= $parent->getChildCount ) {
+                push( @results, [ _("error: can't move up"), -1 ] ) if $ARGS->{'up'};
+                push( @results, [ _("error: can't move down"), -1 ] ) if $ARGS->{'down'};
+                next;
+            }
+
+            $parent->removeChild( $index );
+            $parent->insertChild( $newindex, $value );
+        }
+    }
+    else {
+        push( @results, [ _("error: nothing to move"), -1 ] );
+    }
+}
+elsif ( $ARGS->{"left"} ) {
+    if (@$selected) {
+        foreach my $value (@$selected) {
+            my $parent = $value->getParent;
+            if( $value->isRoot || $parent->isRoot ) {
+                push( @results, [ _("error: can't move left"), -1 ] );
+                next;
+            }
+
+            my $grandparent = $parent->getParent;
+            if( $grandparent->isRoot ) {
+                push( @results, [ _("error: can't move left"), -1 ] );
+                next;
+            }
+            
+            my $index = $parent->getIndex;
+            $parent->removeChild($value);
+            $grandparent->insertChild( $index, $value );
+            if ( $parent->isLeaf ) {
+                $grandparent->removeChild($parent);
+            }
+        }
+    }
+    else {
+        push( @results, [ _("error: nothing to move"), -1 ] );
+    }
+}
+elsif ( $ARGS->{"right"} ) {
+    if (@$selected) {
+        foreach my $value (@$selected) {
+            my $parent = $value->getParent;
+            my $index  = $value->getIndex;
+
+            my $newparent;
+            if ( $index > 0 ) {
+                my $sibling = $parent->getChild( $index - 1 );
+                $newparent = $sibling unless $sibling->isLeaf;
+            }
+            $newparent ||= RT::Interface::Web::QueryBuilder::Tree->new( $ARGS->{'and_or'} || 'AND', $parent );
+
+            $parent->removeChild($value);
+            $newparent->addChild($value);
+        }
+    }
+    else {
+        push( @results, [ _("error: nothing to move"), -1 ] );
+    }
+}
+elsif ( $ARGS->{"delete_clause"} ) {
+    if (@$selected) {
+        my (@top);
+        my %Selected = map { $_ => 1 } @$selected;
+        foreach my $node ( @$selected ) {
+            my $tmp = $node->getParent;
+            while ( !$Selected{ $tmp } && !$tmp->isRoot ) {
+                $tmp = $tmp->getParent;
+            }
+            next if $Selected{ $tmp };
+            push @top, $node;
+        }
+
+        my %seen;
+        my @non_siblings_top = grep !$seen{ $_->getParent }++, @top;
+
+        foreach ( @$new ) {
+            my $add = $_->clone;
+            foreach my $sel( @non_siblings_top ) {
+                my $newindex = $sel->getIndex + 1;
+                $sel->insertSibling( $newindex, $add );
+            }
+            $add->getParent->setNodeValue( $ARGS->{'and_or'} );
+            push @NewSelection, $add;
+        }
+        @$new = ();
+    
+        while( my $node = shift @top ) {
+            my $parent = $node->getParent;
+            $parent->removeChild($node);
+            $node->DESTROY;
+        }
+        @$selected = ();
+    }
+    else {
+        push( @results, [ _("error: nothing to delete"), -1 ] );
+    }
+}
+elsif ( $ARGS->{"toggle"} ) {
+    if (@$selected) {
+        my %seen;
+        my @unique_nodes = grep !$seen{ $_ + 0 }++,
+            map ref $_->getNodeValue? $_->getParent: $_,
+            @$selected;
+
+        foreach my $node ( @unique_nodes ) {
+            if ( $node->getNodeValue eq 'AND' ) {
+                $node->setNodeValue('OR');
+            }
+            else {
+                $node->setNodeValue('AND');
+            }
+        }
+    }
+    else {
+        push( @results, [ _("error: nothing to toggle"), -1 ] );
+    }
+}
+
+if ( @$new && @$selected ) {
+    my %seen;
+    my @non_siblings_selected = grep !$seen{ $_->getParent }++, @$selected;
+
+    foreach ( @$new ) {
+        my $add = $_->clone;
+        foreach my $sel( @non_siblings_selected ) {
+            my $newindex = $sel->getIndex + 1;
+            $sel->insertSibling( $newindex, $add );
+        }
+        $add->getParent->setNodeValue( $ARGS->{'and_or'} );
+        push @NewSelection, $add;
+    }
+    @$selected = ();
+}
+elsif ( @$new ) {
+    foreach ( @$new ) {
+        my $add = $_->clone;
+        $tree->addChild( $add );
+        push @NewSelection, $add;
+    }
+    $tree->setNodeValue( $ARGS->{'and_or'} );
+}
+$_->DESTROY foreach @$new;
+
+push @$selected, @NewSelection;
+
+$tree->prune_childless_aggregators;
+
+return @results;
+}
+1;
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index e322f1e..523cc01 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -66,12 +66,6 @@
 %#   action does quote it (this breaks SQLite).
 %#
 <&| /_elements/wrapper, title => _("Query Builder") &>
-<& /Elements/Tabs,
-    current_tab => "Search/Build.html?".$query_string, 
-    title => _("Query Builder"),
-    %query,
-    saved_search_id => $saved_search{'id'},
-&>
 
 <form method="post" action="Build.html" name="build_query">
 <input type="hidden" class="hidden" name="saved_search_id" value="<% $saved_search{'id'} %>" />
@@ -225,7 +219,7 @@ foreach my $arg ( keys %ARGS ) {
                 $op = "IS NOT";
             }
 
-            # This isn't "right", but...
+            # This is not "right", but...
             # It has to be this way until #5182 is fixed
             $value = "'NULL'";
         }
@@ -245,12 +239,12 @@ foreach my $arg ( keys %ARGS ) {
 }
 
 # }}}
-
-push @actions, $m->comp('Elements/EditQuery:Process',
-    %ARGS,
-    tree     => $tree,
-    selected => \@current_values,
-    new      => \@new_values,
+use RT::Interface::Web::QueryBuilder;
+push @actions, RT::Interface::Web::QueryBuilder->process_query(
+    \%ARGS,
+    $tree,
+    \@current_values,
+    \@new_values,
 );
 
 # {{{ Rebuild $Query based on the additions / movements
@@ -307,7 +301,7 @@ if ($new_query) {
     $query_string = 'new_query=1';
 }
 elsif ( $query{'query'} ) {
-    $query_string = $m->comp('/Elements/QueryString', %query );
+$query_string = URI->new->query_form( %query );
 }
 
 # }}}
diff --git a/share/html/Search/Elements/EditQuery b/share/html/Search/Elements/EditQuery
index c3f0d12..19f9cc8 100644
--- a/share/html/Search/Elements/EditQuery
+++ b/share/html/Search/Elements/EditQuery
@@ -68,176 +68,3 @@ $description => undef
 $optionlist => ''
 $actions => []
 </%ARGS>
-
-<%METHOD Process>
-<%ARGS>
-$tree
-$selected
- at new       => ()
-</%ARGS>
-<%INIT>
-
-my @NewSelection = ();
-
-my @results;
-if ( $ARGS{'up'} || $ARGS{'down'} ) {
-    if (@$selected) {
-        foreach my $value (@$selected) {
-            my $parent = $value->getParent;
-            my $index = $value->getIndex;
-            my $newindex = $index;
-            $newindex++ if $ARGS{'down'};
-            $newindex-- if $ARGS{'up'};
-            if ( $newindex < 0 || $newindex >= $parent->getChildCount ) {
-                push( @results, [ _("error: can't move up"), -1 ] ) if $ARGS{'up'};
-                push( @results, [ _("error: can't move down"), -1 ] ) if $ARGS{'down'};
-                next;
-            }
-
-            $parent->removeChild( $index );
-            $parent->insertChild( $newindex, $value );
-        }
-    }
-    else {
-        push( @results, [ _("error: nothing to move"), -1 ] );
-    }
-}
-elsif ( $ARGS{"left"} ) {
-    if (@$selected) {
-        foreach my $value (@$selected) {
-            my $parent = $value->getParent;
-            if( $value->isRoot || $parent->isRoot ) {
-                push( @results, [ _("error: can't move left"), -1 ] );
-                next;
-            }
-
-            my $grandparent = $parent->getParent;
-            if( $grandparent->isRoot ) {
-                push( @results, [ _("error: can't move left"), -1 ] );
-                next;
-            }
-            
-            my $index = $parent->getIndex;
-            $parent->removeChild($value);
-            $grandparent->insertChild( $index, $value );
-            if ( $parent->isLeaf ) {
-                $grandparent->removeChild($parent);
-            }
-        }
-    }
-    else {
-        push( @results, [ _("error: nothing to move"), -1 ] );
-    }
-}
-elsif ( $ARGS{"right"} ) {
-    if (@$selected) {
-        foreach my $value (@$selected) {
-            my $parent = $value->getParent;
-            my $index  = $value->getIndex;
-
-            my $newparent;
-            if ( $index > 0 ) {
-                my $sibling = $parent->getChild( $index - 1 );
-                $newparent = $sibling unless $sibling->isLeaf;
-            }
-            $newparent ||= RT::Interface::Web::QueryBuilder::Tree->new( $ARGS{'and_or'} || 'AND', $parent );
-
-            $parent->removeChild($value);
-            $newparent->addChild($value);
-        }
-    }
-    else {
-        push( @results, [ _("error: nothing to move"), -1 ] );
-    }
-}
-elsif ( $ARGS{"delete_clause"} ) {
-    if (@$selected) {
-        my (@top);
-        my %Selected = map { $_ => 1 } @$selected;
-        foreach my $node ( @$selected ) {
-            my $tmp = $node->getParent;
-            while ( !$Selected{ $tmp } && !$tmp->isRoot ) {
-                $tmp = $tmp->getParent;
-            }
-            next if $Selected{ $tmp };
-            push @top, $node;
-        }
-
-        my %seen;
-        my @non_siblings_top = grep !$seen{ $_->getParent }++, @top;
-
-        foreach ( @new ) {
-            my $add = $_->clone;
-            foreach my $sel( @non_siblings_top ) {
-                my $newindex = $sel->getIndex + 1;
-                $sel->insertSibling( $newindex, $add );
-            }
-            $add->getParent->setNodeValue( $ARGS{'and_or'} );
-            push @NewSelection, $add;
-        }
-        @new = ();
-    
-        while( my $node = shift @top ) {
-            my $parent = $node->getParent;
-            $parent->removeChild($node);
-            $node->DESTROY;
-        }
-        @$selected = ();
-    }
-    else {
-        push( @results, [ _("error: nothing to delete"), -1 ] );
-    }
-}
-elsif ( $ARGS{"toggle"} ) {
-    if (@$selected) {
-        my %seen;
-        my @unique_nodes = grep !$seen{ $_ + 0 }++,
-            map ref $_->getNodeValue? $_->getParent: $_,
-            @$selected;
-
-        foreach my $node ( @unique_nodes ) {
-            if ( $node->getNodeValue eq 'AND' ) {
-                $node->setNodeValue('OR');
-            }
-            else {
-                $node->setNodeValue('AND');
-            }
-        }
-    }
-    else {
-        push( @results, [ _("error: nothing to toggle"), -1 ] );
-    }
-}
-
-if ( @new && @$selected ) {
-    my %seen;
-    my @non_siblings_selected = grep !$seen{ $_->getParent }++, @$selected;
-
-    foreach ( @new ) {
-        my $add = $_->clone;
-        foreach my $sel( @non_siblings_selected ) {
-            my $newindex = $sel->getIndex + 1;
-            $sel->insertSibling( $newindex, $add );
-        }
-        $add->getParent->setNodeValue( $ARGS{'and_or'} );
-        push @NewSelection, $add;
-    }
-    @$selected = ();
-}
-elsif ( @new ) {
-    foreach ( @new ) {
-        my $add = $_->clone;
-        $tree->addChild( $add );
-        push @NewSelection, $add;
-    }
-    $tree->setNodeValue( $ARGS{'and_or'} );
-}
-$_->DESTROY foreach @new;
-
-push @$selected, @NewSelection;
-
-$tree->prune_childless_aggregators;
-
-return @results;
-</%INIT>
-</%METHOD>

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


More information about the Rt-commit mailing list