[Rt-commit] rt branch, dashboard-in-menu, updated. rt-3.9.7-1230-gc619fc2

? sunnavy sunnavy at bestpractical.com
Tue Jan 25 20:22:41 EST 2011


The branch, dashboard-in-menu has been updated
       via  c619fc22cc8e8ba39aa50ce42291957fffe79de6 (commit)
       via  72ef9d8040ac199e705918ed269f243b077d4d42 (commit)
      from  d0ff1a556b4f5236cda5689d10de972292f57408 (commit)

Summary of changes:
 lib/RT/Dashboard.pm                             |   22 +++++++++++++++++++-
 share/html/Dashboards/Elements/ListOfDashboards |    4 +-
 share/html/Dashboards/Modify.html               |   14 ++++++++++++-
 share/html/Elements/Tabs                        |   12 +----------
 t/web/dashboards-basics.t                       |   25 ++++++++++++++++++++++-
 5 files changed, 61 insertions(+), 16 deletions(-)

- Log -----------------------------------------------------------------
commit 72ef9d8040ac199e705918ed269f243b077d4d42
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jan 25 22:28:41 2011 +0800

    use ShowInMenu to determine if the dashboard should appear in menu or not, no number limit any more

diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index b0c3ec6..8efc0cf 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -119,7 +119,10 @@ sub SaveAttribute {
     return $object->AddAttribute(
         'Name'        => 'Dashboard',
         'Description' => $args->{'Name'},
-        'Content'     => {Panes => $args->{'Panes'}},
+        'Content'     => {
+            Panes      => $args->{'Panes'},
+            ShowInMenu => $args->{'ShowInMenu'},
+        },
     );
 }
 
@@ -134,6 +137,11 @@ sub UpdateAttribute {
         );
     }
 
+    if ( defined $args->{'ShowInMenu'} ) {
+        ( $status, $msg ) =
+          $self->{'Attribute'}->SetSubValues( ShowInMenu => $args->{'ShowInMenu'}, );
+    }
+
     if ($status && $args->{'Name'}) {
         ($status, $msg) = $self->{'Attribute'}->SetDescription($args->{'Name'})
             unless $self->Name eq $args->{'Name'};
@@ -168,6 +176,18 @@ sub Panes {
     return $self->{'Attribute'}->SubValue('Panes') || {};
 }
 
+=head2 ShowInMenu
+
+Returns true if $self can be shown in menu, false otherwise.
+
+=cut
+
+sub ShowInMenu {
+    my $self = shift;
+    return unless ref($self->{'Attribute'}) eq 'RT::Attribute';
+    return $self->{'Attribute'}->SubValue('ShowInMenu');
+}
+
 =head2 Portlets
 
 Returns the list of this dashboard's portlets, each a hashref with key
diff --git a/share/html/Dashboards/Elements/ListOfDashboards b/share/html/Dashboards/Elements/ListOfDashboards
index e4ddc0e..312f331 100644
--- a/share/html/Dashboards/Elements/ListOfDashboards
+++ b/share/html/Dashboards/Elements/ListOfDashboards
@@ -56,10 +56,10 @@ my %dashboard_map;
 for my $object (@objs) {
     my $new_dashboards = $m->comp("/Dashboards/Elements/DashboardsForObject", Object => $object);
 
-    push @{ $dashboard_map{$_} }, @{ $new_dashboards->{$_} || [] }
+    push @{ $dashboard_map{$_} }, grep { $_->ShowInMenu } @{ $new_dashboards->{$_} || [] }
         for qw/personal system/;
 
-    push @{ $dashboard_map{group}{$_} }, @{ $new_dashboards->{group}{$_} }
+    push @{ $dashboard_map{group}{$_} }, grep { $_->ShowInMenu } @{ $new_dashboards->{group}{$_} }
         for keys %{ $new_dashboards->{group} || {} };
 }
 
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index b089e11..75d23d7 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -67,6 +67,15 @@
     <td class="label"><&|/l&>Privacy</&>:</td>
     <td><& /Dashboards/Elements/SelectPrivacy, Name => "Privacy", Objects => \@privacies, Default => $Dashboard->Privacy &></td>
 </tr>
+    <tr>
+     <td class="label"><&|/l&>Show In menu</&>:</td>
+     <td class="value">
+     <input name="ShowInMenu" type="radio" value="1" 
+     <% $Dashboard->ShowInMenu ? 'checked="checked"' : '' %> ><&|/l&>yes</&>
+     <input name="ShowInMenu" type="radio" value="0"
+     <% $Dashboard->ShowInMenu ? '' : 'checked="checked"' %> ><&|/l&>no</&>
+     </td>
+    </tr>
 </table>
 </&>
 <& /Elements/Submit, Name => 'Save', Label =>( $Create ? loc('Create') : loc('Save Changes') ) &>
@@ -104,6 +113,7 @@ else {
         my ($val, $msg) = $Dashboard->Save(
             Name    => $ARGS{'Name'},
             Privacy => $ARGS{'Privacy'},
+            ShowInMenu => $ARGS{ShowInMenu}, 
         );
 
         if (!$val) {
@@ -134,7 +144,9 @@ else {
 
 if (!$Create && !$tried_create && $id && $ARGS{'Save'}) {
     my ($ok, $msg) = $Dashboard->Update(Privacy  => $ARGS{'Privacy'},
-                                        Name     => $ARGS{'Name'});
+                                        Name     => $ARGS{'Name'},
+                                        ShowInMenu => $ARGS{ShowInMenu}, 
+                                        );
 
     if ($ok) {
         push @results, loc("Dashboard updated");
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 7a1dc9c..0abee79 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -62,16 +62,6 @@ my $build_main_nav = sub {
 
     my $home = Menu->child( home => title => loc('Homepage'), path => '/' );
     my @dashboards = $m->comp("/Dashboards/Elements/ListOfDashboards");
-    my $limit      = 7;
-
-    my $more = 0;
-    if ( @dashboards > $limit ) {
-        $more = 1;
-        splice @dashboards, $limit;
-    }
-
-    my $position = 0;
-
     my $dashes = Menu()->child('home');
     if (@dashboards) {
         for my $dash (@dashboards) {
@@ -79,8 +69,8 @@ my $build_main_nav = sub {
                        path => '/Dashboards/' . $dash->id . '/' . $dash->Name,);
         }
 
-        $dashes->child( more => title => loc('All Dashboards'), path  => 'Dashboards/index.html' );
     }
+    $dashes->child( more => title => loc('All Dashboards'), path  => 'Dashboards/index.html' );
     my $dashboard = RT::Dashboard->new( $session{CurrentUser} );
     if ( $dashboard->CurrentUserCanCreateAny ) {
         $dashes->child('dashboard_create' => title => loc('New Dashboard') => path => "/Dashboards/Modify.html?Create=1" );

commit c619fc22cc8e8ba39aa50ce42291957fffe79de6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jan 26 08:59:08 2011 +0800

    test ShowInMenu for dashboard

diff --git a/t/web/dashboards-basics.t b/t/web/dashboards-basics.t
index ed98362..759adf5 100644
--- a/t/web/dashboards-basics.t
+++ b/t/web/dashboards-basics.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 
-use RT::Test tests => 110;
+use RT::Test tests => 119;
 my ($baseurl, $m) = RT::Test->started_ok;
 
 my $url = $m->rt_base_url;
@@ -258,3 +258,26 @@ $omech->content_lacks("dashboard test", "matched ticket doesn't show up");
 
 $omech->warning_like(qr/User .* tried to load container user /, "can't see other users' personal searches");
 
+diag "test ShowInMenu option";
+
+$m->get_ok($url.'Dashboards/Modify.html?Create=1');
+$m->form_name('ModifyDashboard');
+$m->field('Name' => 'menu dashboard foo');
+$m->field('ShowInMenu' => 1);
+$m->click_button(value => 'Create');
+$m->content_contains('Saved dashboard menu dashboard foo');
+ok( $m->find_link( text => 'menu dashboard foo' ), 'got link in menu' );
+$m->form_name('ModifyDashboard');
+is( $m->value('ShowInMenu'), 1, 'ShowInMenu input' );
+$m->field('ShowInMenu' => 0);
+$m->click_button(value => 'Save Changes');
+$m->content_contains('Dashboard updated');
+ok( !$m->find_link( text => 'menu dashboard foo' ), 'no link in menu' );
+
+$m->form_name('ModifyDashboard');
+is( $m->value('ShowInMenu'), 0, 'ShowInMenu input' );
+$m->field('ShowInMenu' => 1);
+$m->click_button(value => 'Save Changes');
+$m->content_contains('Dashboard updated');
+ok( $m->find_link( text => 'menu dashboard foo' ), 'got link in menu again' );
+

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


More information about the Rt-commit mailing list