[Rt-commit] rt branch, 4.2/dashboard-in-menu, updated. rt-3.9.7-1238-g226a227
? sunnavy
sunnavy at bestpractical.com
Thu Jan 27 23:46:56 EST 2011
The branch, 4.2/dashboard-in-menu has been updated
via 226a2276afa3a22a3670258c97f50d7bc9284588 (commit)
via edbf3ca677b89cd8dc183812bc2b0bc4f85689a8 (commit)
from dc95ead44a5facc7be31958759b9e48a33576aa4 (commit)
Summary of changes:
lib/RT/Dashboard.pm | 23 +-----
.../{ConfigureMyRT => ConfigureDashboardsInMenu} | 10 +--
.../Global/{MyRT.html => DashboardsInMenu.html} | 67 +++++++-------
.../Users/{MyRT.html => DashboardsInMenu.html} | 66 ++++++--------
share/html/Dashboards/Elements/DashboardsForObject | 6 +-
share/html/Dashboards/Elements/ListOfDashboards | 10 ++-
share/html/Dashboards/Modify.html | 17 +---
share/html/Elements/Tabs | 34 +++++++-
.../MyRT.html => Prefs/DashboardsInMenu.html} | 95 ++++++++++----------
t/web/dashboards-basics.t | 25 +-----
10 files changed, 164 insertions(+), 189 deletions(-)
copy share/html/Admin/Elements/{ConfigureMyRT => ConfigureDashboardsInMenu} (88%)
copy share/html/Admin/Global/{MyRT.html => DashboardsInMenu.html} (67%)
copy share/html/Admin/Users/{MyRT.html => DashboardsInMenu.html} (62%)
copy share/html/{Admin/Global/MyRT.html => Prefs/DashboardsInMenu.html} (55%)
- Log -----------------------------------------------------------------
commit edbf3ca677b89cd8dc183812bc2b0bc4f85689a8
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jan 27 15:56:24 2011 +0800
revert previous changes: we got a better idea, see #16499
diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index ad1943b..b0c3ec6 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -119,10 +119,7 @@ sub SaveAttribute {
return $object->AddAttribute(
'Name' => 'Dashboard',
'Description' => $args->{'Name'},
- 'Content' => {
- Panes => $args->{'Panes'},
- ShowInMenu => $args->{'ShowInMenu'},
- },
+ 'Content' => {Panes => $args->{'Panes'}},
);
}
@@ -137,12 +134,6 @@ sub UpdateAttribute {
);
}
- if ($status && 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'};
@@ -177,18 +168,6 @@ 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/Modify.html b/share/html/Dashboards/Modify.html
index 792ebcb..b089e11 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -67,13 +67,6 @@
<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 type="hidden" class="hidden" name="SetShowInMenu" value="1" />
- <input type="checkbox" class="checkbox" name="ShowInMenu" value="1" <% $Dashboard->ShowInMenu ? 'checked="checked"' : '' %> />
- </td>
- </tr>
</table>
</&>
<& /Elements/Submit, Name => 'Save', Label =>( $Create ? loc('Create') : loc('Save Changes') ) &>
@@ -111,7 +104,6 @@ else {
my ($val, $msg) = $Dashboard->Save(
Name => $ARGS{'Name'},
Privacy => $ARGS{'Privacy'},
- ($SetShowInMenu ? (ShowInMenu => $ShowInMenu) : ()),
);
if (!$val) {
@@ -141,11 +133,8 @@ else {
}
if (!$Create && !$tried_create && $id && $ARGS{'Save'}) {
- my ($ok, $msg) = $Dashboard->Update(
- Privacy => $ARGS{'Privacy'},
- Name => $ARGS{'Name'},
- ($SetShowInMenu ? (ShowInMenu => $ShowInMenu) : ()),
- );
+ my ($ok, $msg) = $Dashboard->Update(Privacy => $ARGS{'Privacy'},
+ Name => $ARGS{'Name'});
if ($ok) {
push @results, loc("Dashboard updated");
@@ -183,7 +172,5 @@ $Create => undef
$Name => undef
$id => '' unless defined $id
$Delete => undef
-$SetShowInMenu => undef
-$ShowInMenu => 0
</%ARGS>
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index e5d5451..7a1dc9c 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -61,7 +61,17 @@ my $query_string = sub {
my $build_main_nav = sub {
my $home = Menu->child( home => title => loc('Homepage'), path => '/' );
- my @dashboards = grep { $_->ShowInMenu } $m->comp("/Dashboards/Elements/ListOfDashboards");
+ 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) {
@@ -69,8 +79,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" );
diff --git a/t/web/dashboards-basics.t b/t/web/dashboards-basics.t
index 85c817d..ed98362 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 => 119;
+use RT::Test tests => 110;
my ($baseurl, $m) = RT::Test->started_ok;
my $url = $m->rt_base_url;
@@ -258,26 +258,3 @@ $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');
-ok( !$m->value('ShowInMenu'), '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' );
-
commit 226a2276afa3a22a3670258c97f50d7bc9284588
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jan 28 11:33:43 2011 +0800
new DashboardsInMenu config pages
diff --git a/share/html/Dashboards/Elements/DashboardsForObject b/share/html/Admin/Elements/ConfigureDashboardsInMenu
similarity index 69%
copy from share/html/Dashboards/Elements/DashboardsForObject
copy to share/html/Admin/Elements/ConfigureDashboardsInMenu
index 1337c0a..db0b20e 100644
--- a/share/html/Dashboards/Elements/DashboardsForObject
+++ b/share/html/Admin/Elements/ConfigureDashboardsInMenu
@@ -46,36 +46,31 @@
%#
%# END BPS TAGGED BLOCK }}}
<%args>
-$Object => undef
+$Action
+$OnSave
+$items
+$panes
+$current_portlets
+$ReadOnly => 0
</%args>
<%init>
-# Returns a hash of dashboards associated on $Object
-
-use RT::Dashboard;
-my %dashboards;
-my $privacy = RT::Dashboard->_build_privacy($Object);
-
-while (my $attr = $Object->Attributes->Next) {
- if ($attr->Name =~ /^Dashboard\b/) {
- my $dashboard = RT::Dashboard->new($session{'CurrentUser'});
- my ($ok, $msg) = $dashboard->Load($privacy, $attr->id);
-
- if (!$ok) {
- $RT::Logger->debug("Unable to load dashboard $ok (privacy $privacy): $msg");
- next;
- }
-
- if ($Object->isa('RT::System')) {
- push @{ $dashboards{system} }, $dashboard;
- }
- elsif ($Object->isa('RT::User')) {
- push @{ $dashboards{personal} }, $dashboard;
- }
- elsif ($Object->isa('RT::Group')) {
- push @{ $dashboards{group}{$Object->Name} }, $dashboard;
- }
- }
+my $portlets = $current_portlets;
+my @panes;
+for my $pane (@$panes) {
+ push @panes, $m->comp(
+ '/Widgets/SelectionBox:new',
+ Action => $Action,
+ Name => $pane,
+ Available => $items,
+ AutoSave => 1,
+ ReadOnly => $ReadOnly,
+ OnSubmit => sub {
+ my $sel = shift;
+ $OnSave->( { dashboards => $sel->{Current} } );
+ },
+ Selected => $portlets,
+ );
}
-return \%dashboards;
-</%init>
+return @panes;
+</%init>
diff --git a/share/html/Dashboards/Elements/DashboardsForObject b/share/html/Admin/Global/DashboardsInMenu.html
similarity index 51%
copy from share/html/Dashboards/Elements/DashboardsForObject
copy to share/html/Admin/Global/DashboardsInMenu.html
index 1337c0a..c57a41a 100644
--- a/share/html/Dashboards/Elements/DashboardsForObject
+++ b/share/html/Admin/Global/DashboardsInMenu.html
@@ -45,37 +45,71 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<%args>
-$Object => undef
-</%args>
+<& /Admin/Elements/Header, Title => loc("Dashboards in menu") &>
+<& /Elements/Tabs &>
+
+<& /Widgets/SelectionBox:header, nojs => 1 &>
+
+<& /Elements/ListActions, actions => \@actions &>
+<br />
+% for my $pane (@panes) {
+<&|/Widgets/TitleBox, title => loc('Dashboards in menu'), bodyclass => "" &>
+<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &></&>
+<br />
+% }
<%init>
-# Returns a hash of dashboards associated on $Object
+my @actions;
+my $sys = RT::System->new( $session{'CurrentUser'} );
-use RT::Dashboard;
-my %dashboards;
-my $privacy = RT::Dashboard->_build_privacy($Object);
+my $has_right = $session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'SuperUser');
-while (my $attr = $Object->Attributes->Next) {
- if ($attr->Name =~ /^Dashboard\b/) {
- my $dashboard = RT::Dashboard->new($session{'CurrentUser'});
- my ($ok, $msg) = $dashboard->Load($privacy, $attr->id);
+my ($dashboard_attr) = $sys->Attributes->Named('DashboardsInMenu');
+my $default_dashboards_in_menu =
+ $dashboard_attr && $dashboard_attr->Content->{dashboards}
+ ? $dashboard_attr->Content->{dashboards}
+ : [];
- if (!$ok) {
- $RT::Logger->debug("Unable to load dashboard $ok (privacy $privacy): $msg");
- next;
- }
+use RT::Dashboards;
+my $dashboards = RT::Dashboards->new( $RT::SystemUser );
+$dashboards->LimitToPrivacy('RT::System-' . $sys->id);
+
+my @dashboards;
+while ( my $dashboard = $dashboards->Next ) {
+ push @dashboards, [$dashboard->id, $dashboard->Name];
+}
- if ($Object->isa('RT::System')) {
- push @{ $dashboards{system} }, $dashboard;
+my @panes = $m->comp(
+ '/Admin/Elements/ConfigureDashboardsInMenu',
+ Action => 'DashboardsInMenu.html',
+ panes => ['dashboards_in_menu'],
+ ReadOnly => !$has_right,
+ items => \@dashboards,
+ current_portlets => $default_dashboards_in_menu,
+ OnSave => sub {
+ my ( $conf ) = @_;
+ my ( $status, $msg );
+
+ if (!$has_right) {
+ push @actions, loc( 'Permission Denied' );
}
- elsif ($Object->isa('RT::User')) {
- push @{ $dashboards{personal} }, $dashboard;
+ elsif ( $dashboard_attr ) {
+ ($status, $msg) = $dashboard_attr->SetContent($conf);
}
- elsif ($Object->isa('RT::Group')) {
- push @{ $dashboards{group}{$Object->Name} }, $dashboard;
+ else {
+ $dashboard_attr = RT::Attribute->new($RT::SystemUser);
+ ( $status, $msg ) = $dashboard_attr->Create(
+ Name => 'DashboardsInMenu',
+ Object => $sys,
+ Content => $conf,
+ );
}
+ push @actions, $status ? loc('Global dashboards in menu saved.') : $msg;
}
-}
-return \%dashboards;
+);
+
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+ for @panes;
+
+
</%init>
diff --git a/share/html/Admin/Users/DashboardsInMenu.html b/share/html/Admin/Users/DashboardsInMenu.html
new file mode 100644
index 0000000..6bcb721
--- /dev/null
+++ b/share/html/Admin/Users/DashboardsInMenu.html
@@ -0,0 +1,120 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2010 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<& /Admin/Elements/Header, Title => $title &>
+<& /Elements/Tabs &>
+
+<& /Widgets/SelectionBox:header, nojs => 1 &>
+
+<& /Elements/ListActions, actions => \@actions &>
+
+<form method="post" action="DashboardsInMenu.html">
+<input type="hidden" name="id" value="<% $id %>" />
+<input type="hidden" name="Reset" value="1" />
+<input type="submit" class="button" value="<%loc('Reset to default')%>">
+</form>
+
+<br />
+
+% for my $pane (@panes) {
+<&|/Widgets/TitleBox, title => loc('Dashboards in menu'), bodyclass => "" &>
+<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &></&>
+<br />
+% }
+
+<%init>
+my @actions;
+my $UserObj = RT::User->new($session{'CurrentUser'});
+$UserObj->Load($id) || Abort("Couldn't load user '" . ($id || '') . "'");
+my $title = loc("Dashboards in menu for the user [_1]", $UserObj->Name);
+
+if ($ARGS{Reset}) {
+ my ($ok, $msg) = $UserObj->SetPreferences('DashboardsInMenu', {});
+ push @actions, $ok ? loc('Preferences saved for user [_1].', $UserObj->Name) : $msg;
+}
+
+my ($default_dashboards) =
+RT::System->new($session{'CurrentUser'})->Attributes->Named('DashboardsInMenu');
+
+my $user = RT::CurrentUser->new( $session{CurrentUser} );
+$user->Load( $UserObj->id );
+my @dashboards =
+ map { [ $_->id, $_->Name ] }
+ $m->comp( "/Dashboards/Elements/ListOfDashboards", User => $user );
+
+
+my $current_pref =
+ $UserObj->Preferences( 'DashboardsInMenu',
+ $default_dashboards ? $default_dashboards->Content : () );
+my $current_portlets =
+ $current_pref && $current_pref->{dashboards}
+ ? $current_pref->{dashboards}
+ : [];
+
+my @panes = $m->comp(
+ '/Admin/Elements/ConfigureDashboardsInMenu',
+ Action => "DashboardsInMenu.html?id=$id",
+ panes => ['dashboards_in_menu'],
+ items => \@dashboards,
+ current_portlets => $current_portlets,
+ OnSave => sub {
+ my ($conf) = @_;
+ my ( $ok, $msg ) =
+ $UserObj->SetPreferences( 'DashboardsInMenu', $conf );
+ push @actions,
+ $ok ? loc('Preferences saved for dashboards in menu.') : $msg;
+ }
+);
+
+
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+ for @panes;
+
+</%init>
+<%ARGS>
+$id => undef
+</%ARGS>
diff --git a/share/html/Dashboards/Elements/DashboardsForObject b/share/html/Dashboards/Elements/DashboardsForObject
index 1337c0a..35aea10 100644
--- a/share/html/Dashboards/Elements/DashboardsForObject
+++ b/share/html/Dashboards/Elements/DashboardsForObject
@@ -57,7 +57,7 @@ my $privacy = RT::Dashboard->_build_privacy($Object);
while (my $attr = $Object->Attributes->Next) {
if ($attr->Name =~ /^Dashboard\b/) {
- my $dashboard = RT::Dashboard->new($session{'CurrentUser'});
+ my $dashboard = RT::Dashboard->new($User);
my ($ok, $msg) = $dashboard->Load($privacy, $attr->id);
if (!$ok) {
@@ -79,3 +79,7 @@ while (my $attr = $Object->Attributes->Next) {
return \%dashboards;
</%init>
+<%args>
+$User => $session{'CurrentUser'}
+</%args>
+
diff --git a/share/html/Dashboards/Elements/ListOfDashboards b/share/html/Dashboards/Elements/ListOfDashboards
index e4ddc0e..0d2ebf6 100644
--- a/share/html/Dashboards/Elements/ListOfDashboards
+++ b/share/html/Dashboards/Elements/ListOfDashboards
@@ -48,13 +48,13 @@
<%init>
# put the list of dashboards into the navigation
use RT::Dashboard;
-
-my @objs = RT::Dashboard->new($session{CurrentUser})->ObjectsForLoading;
+my @objs = RT::Dashboard->new($User)->ObjectsForLoading;
my %dashboard_map;
for my $object (@objs) {
- my $new_dashboards = $m->comp("/Dashboards/Elements/DashboardsForObject", Object => $object);
+ my $new_dashboards = $m->comp("/Dashboards/Elements/DashboardsForObject",
+ Object => $object, User => $User );
push @{ $dashboard_map{$_} }, @{ $new_dashboards->{$_} || [] }
for qw/personal system/;
@@ -75,3 +75,7 @@ $m->callback(%ARGS, dashboards => \@dashboards, CallbackName => 'ModifyDashboard
return @dashboards;
</%init>
+
+<%args>
+$User => $session{CurrentUser}
+</%args>
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 7a1dc9c..1ccc23e 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -61,17 +61,26 @@ my $query_string = sub {
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 ($default_dashboards) =
+ RT::System->new( $session{'CurrentUser'} )
+ ->Attributes->Named('DashboardsInMenu');
+ my $dashboard_pref =
+ $session{CurrentUser}->UserObj->Preferences( 'DashboardsInMenu',
+ $default_dashboards ? $default_dashboards->Content : () );
+ $session{'dashboards_in_menu'} ||= $dashboard_pref->{dashboards} || [];
+
+ my @dashboards;
+ for my $id ( @{$session{'dashboards_in_menu'}} ) {
+ my $dash = RT::Dashboard->new( $session{CurrentUser} );
+ my ( $status, $msg ) = $dash->LoadById($id);
+ if ( $status ) {
+ push @dashboards, $dash;
+ }
+ else {
+ $RT::Logger->warning( "Failed to load dashboard $id: $msg" );
+ }
}
- my $position = 0;
-
my $dashes = Menu()->child('home');
if (@dashboards) {
for my $dash (@dashboards) {
@@ -79,8 +88,14 @@ my $build_main_nav = sub {
path => '/Dashboards/' . $dash->id . '/' . $dash->Name,);
}
- $dashes->child( more => title => loc('All Dashboards'), path => 'Dashboards/index.html' );
}
+
+ $dashes->child(
+ edit => title => loc('Update This Menu'),
+ path => 'Prefs/DashboardsInMenu.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" );
@@ -194,6 +209,8 @@ my $build_admin_menu = sub {
description => loc('Modify global user rights') );
$admin_global->child( 'my-rt' => title => loc('RT at a glance'), path => '/Admin/Global/MyRT.html',
description => loc('Modify the default "RT at a glance" view') );
+ $admin_global->child( 'dashboards-in-menu' => title => loc('Dashboards in menu'), path => '/Admin/Global/DashboardsInMenu.html',
+ description => loc('Customize dashboards in menu') );
$admin_global->child( theme => title => loc('Theme'), path => '/Admin/Global/Theme.html',
description => loc('Customize the look of your RT') );
@@ -287,6 +304,9 @@ my $build_admin_menu = sub {
$tabs->child( memberships => title => loc('Memberships'), path => "/Admin/Users/Memberships.html?id=" . $id );
$tabs->child( history => title => loc('History'), path => "/Admin/Users/History.html?id=" . $id );
$tabs->child( 'my-rt' => title => loc('RT at a glance'), path => "/Admin/Users/MyRT.html?id=" . $id );
+ $tabs->child( 'dashboards-in-menu' => title => loc('Dashboards in menu'),
+ path => '/Admin/Users/DashboardsInMenu.html?id=' . $id );
+
if ( RT->Config->Get('GnuPG')->{'enable'} ) {
$tabs->child( pgp => title => loc('GnuPG'), path => "/Admin/Users/GnuPG.html?id=" . $id );
}
@@ -392,6 +412,8 @@ my $build_admin_menu = sub {
$settings->child( about_me => title => loc('About me'), path => '/User/Prefs.html', );
$settings->child( search_options => title => loc('Search options'), path => '/Prefs/SearchOptions.html', );
$settings->child( myrt => title => loc('RT at a glance'), path => '/Prefs/MyRT.html', );
+ $settings->child( dashboards_in_menu => title => loc('Dashboards in menu'),
+ path => '/Prefs/DashboardsInMenu.html' );
$settings->child( quicksearch => title => 'Quick search' => title => loc('Quick search'), path => '/Prefs/Quicksearch.html');
my $search_menu = $settings->child( 'saved-searches' => title => 'Saved Searches' );
diff --git a/share/html/Dashboards/Elements/ListOfDashboards b/share/html/Prefs/DashboardsInMenu.html
similarity index 51%
copy from share/html/Dashboards/Elements/ListOfDashboards
copy to share/html/Prefs/DashboardsInMenu.html
index e4ddc0e..a9b6f9f 100644
--- a/share/html/Dashboards/Elements/ListOfDashboards
+++ b/share/html/Prefs/DashboardsInMenu.html
@@ -45,33 +45,71 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<%init>
-# put the list of dashboards into the navigation
-use RT::Dashboard;
+<& /Elements/Header, Title => $title &>
+<& /Elements/Tabs
+&>
+<& /Elements/ListActions, actions => \@results &>
-my @objs = RT::Dashboard->new($session{CurrentUser})->ObjectsForLoading;
+<& /Widgets/SelectionBox:header, nojs => 1 &>
-my %dashboard_map;
-for my $object (@objs) {
- my $new_dashboards = $m->comp("/Dashboards/Elements/DashboardsForObject", Object => $object);
+<br />
- push @{ $dashboard_map{$_} }, @{ $new_dashboards->{$_} || [] }
- for qw/personal system/;
+% for my $pane ( @panes ) {
+<&|/Widgets/TitleBox,
+ title => loc('Dashboards in menu'),
+ bodyclass => ""
+&>
+<& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &>
+</&>
+% }
- push @{ $dashboard_map{group}{$_} }, @{ $new_dashboards->{group}{$_} }
- for keys %{ $new_dashboards->{group} || {} };
+<&|/Widgets/TitleBox, title => loc("Reset dashboards in menu") &>
+<form method="post" action="DashboardsInMenu.html">
+<input type="hidden" name="Reset" value="1" />
+<input type="submit" class="button" value="<% loc('Reset to default') %>">
+</form>
+</&>
+
+
+<%INIT>
+my @results;
+my $title = loc("Customize").' '.loc("dashboards in menu");
+my $user = $session{'CurrentUser'}->UserObj;
+
+if ($ARGS{Reset}) {
+ my ($ok, $msg) = $user->SetPreferences('DashboardsInMenu', {});
+ push @results, $ok ? loc('Preferences saved.') : $msg;
+ delete $session{'dashboards_in_menu'};
}
-my @dashboards = (
- (sort { $a->Id <=> $b->Id } @{ $dashboard_map{personal} || [] }),
- (sort { $a->Id <=> $b->Id } @{ $dashboard_map{system} || [] }),
+my ($default_dashboards) =
+RT::System->new($session{'CurrentUser'})->Attributes->Named('DashboardsInMenu');
- map { sort { $a->Id <=> $b->Id } @{ $dashboard_map{group}{$_} } }
- keys %{ $dashboard_map{group} || {} },
+my $dashboard_pref =
+ $session{CurrentUser}->UserObj->Preferences( 'DashboardsInMenu',
+ $default_dashboards ? $default_dashboards->Content : () );
+$session{'dashboards_in_menu'} ||= $dashboard_pref->{dashboards} || [];
+
+my @dashboards = map { [$_->id, $_->Name] } $m->comp("/Dashboards/Elements/ListOfDashboards");
+
+my @panes = $m->comp(
+ '/Admin/Elements/ConfigureDashboardsInMenu',
+ Action => 'DashboardsInMenu.html',
+ panes => ['dashboards in menu'],
+ items => \@dashboards,
+ current_portlets => $session{'dashboards_in_menu'},
+ OnSave => sub {
+ my ( $conf ) = @_;
+ my ( $ok, $msg ) =
+ $user->SetPreferences( 'DashboardsInMenu', $conf );
+ push @results, $ok ? loc('Preferences saved for dashboards_in_menu.') : $msg;
+ delete $session{'dashboards_in_menu'};
+ }
);
-$m->callback(%ARGS, dashboards => \@dashboards, CallbackName => 'ModifyDashboards');
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+ for @panes;
+
+</%INIT>
-return @dashboards;
-</%init>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list