[Rt-commit] r13580 - in rt/3.8/trunk: . share/html/Dashboards/Elements
sartak at bestpractical.com
sartak at bestpractical.com
Tue Jun 24 20:11:33 EDT 2008
Author: sartak
Date: Tue Jun 24 20:11:23 2008
New Revision: 13580
Added:
rt/3.8/trunk/share/html/Dashboards/Elements/DashboardsForObjects
Modified:
rt/3.8/trunk/ (props changed)
rt/3.8/trunk/share/html/Dashboards/Elements/DashboardsForObject
rt/3.8/trunk/share/html/Dashboards/index.html
Log:
r63210 at onn: sartak | 2008-06-24 20:10:34 -0400
Refactor some of the dashboard display code for reuse
Modified: rt/3.8/trunk/share/html/Dashboards/Elements/DashboardsForObject
==============================================================================
--- rt/3.8/trunk/share/html/Dashboards/Elements/DashboardsForObject (original)
+++ rt/3.8/trunk/share/html/Dashboards/Elements/DashboardsForObject Tue Jun 24 20:11:23 2008
@@ -49,10 +49,10 @@
$Object => undef
</%args>
<%init>
-# Returns an array of dashboards associated on $Object
+# Returns a hash of dashboards associated on $Object
use RT::Dashboard;
-my @dashboards;
+my %dashboards;
my $privacy = RT::Dashboard->_build_privacy($Object);
while (my $attr = $Object->Attributes->Next) {
@@ -61,9 +61,17 @@
my ($ok) = $dashboard->Load($privacy, $attr->id);
next if !$ok;
- push @dashboards, $dashboard;
+ 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;
+ }
}
}
-return @dashboards;
+return \%dashboards;
</%init>
Added: rt/3.8/trunk/share/html/Dashboards/Elements/DashboardsForObjects
==============================================================================
--- (empty file)
+++ rt/3.8/trunk/share/html/Dashboards/Elements/DashboardsForObjects Tue Jun 24 20:11:23 2008
@@ -0,0 +1,68 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2008 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 }}}
+<%args>
+ at Objects
+$dashboards => {}
+</%args>
+<%init>
+# Returns a hash of dashboards associated with @Objects
+
+for my $object (@Objects) {
+ my $new_dashboards = $m->comp("/Dashboards/Elements/DashboardsForObject", Object => $object);
+
+ push @{ $dashboards->{$_} }, @{ $new_dashboards->{$_} || [] }
+ for qw/personal system/;
+
+ push @{ $dashboards->{group}{$_} }, @{ $new_dashboards->{group}{$_} }
+ for keys %{ $new_dashboards->{group} || {} };
+}
+
+return $dashboards;
+</%init>
+
+
Modified: rt/3.8/trunk/share/html/Dashboards/index.html
==============================================================================
--- rt/3.8/trunk/share/html/Dashboards/index.html (original)
+++ rt/3.8/trunk/share/html/Dashboards/index.html Tue Jun 24 20:11:23 2008
@@ -54,44 +54,27 @@
<& /Dashboards/Elements/ShowDashboards,
Type => "Personal",
- Dashboards => \@personal_dashboards,
+ Dashboards => $dashboards->{personal},
&>
<& /Dashboards/Elements/ShowDashboards,
Type => "System",
- Dashboards => \@system_dashboards,
+ Dashboards => $dashboards->{system},
&>
-% for my $group (sort keys %group_dashboards) {
+% for my $group (sort keys %{ $dashboards->{group} || {} }) {
<& /Dashboards/Elements/ShowDashboards,
Type => $group,
- Dashboards => $group_dashboards{$group},
+ Dashboards => $dashboards->{group}{$group},
&>
% }
<%INIT>
my $title = loc("Dashboards");
-my @personal_dashboards;
-my @system_dashboards;
-my %group_dashboards;
-
use RT::Dashboard;
my @objs = RT::Dashboard->new($session{CurrentUser})->_PrivacyObjects(ShowSystem => 1);
-
-for my $object (@objs) {
- for my $dashboard ($m->comp("/Dashboards/Elements/DashboardsForObject", Object => $object)) {
- if ($object->isa('RT::System')) {
- push @system_dashboards, $dashboard;
- }
- elsif ($object->isa('RT::User')) {
- push @personal_dashboards, $dashboard;
- }
- else {
- push @{ $group_dashboards{$object->Name} }, $dashboard;
- }
- }
-}
+my $dashboards = $m->comp("/Dashboards/Elements/DashboardsForObjects", Objects => \@objs);
my @actions;
if (defined $Unsubscribed) {
More information about the Rt-commit
mailing list