[Rt-commit] r15745 - in rt/3.8/trunk: . etc/upgrade/3.8.2 share/html/Dashboards
sartak at bestpractical.com
sartak at bestpractical.com
Wed Sep 3 20:43:05 EDT 2008
Author: sartak
Date: Wed Sep 3 20:43:04 2008
New Revision: 15745
Modified:
rt/3.8/trunk/ (props changed)
rt/3.8/trunk/etc/upgrade/3.8.2/content
rt/3.8/trunk/lib/RT/Dashboard.pm
rt/3.8/trunk/share/html/Dashboards/Queries.html
Log:
r70994 at onn: sartak | 2008-09-03 20:11:18 -0400
Begin support for two-pane dashboards!
Modified: rt/3.8/trunk/etc/upgrade/3.8.2/content
==============================================================================
--- rt/3.8/trunk/etc/upgrade/3.8.2/content (original)
+++ rt/3.8/trunk/etc/upgrade/3.8.2/content Wed Sep 3 20:43:04 2008
@@ -15,17 +15,21 @@
for my $attr (@dashboards) {
my $props = $attr->Content;
if (exists $props->{Searches}) {
- $props->{Portlets} = [ map {
- my ($privacy, $id, $desc) = @$_;
+ $props->{Panes} = {
+ body => [
+ map {
+ my ($privacy, $id, $desc) = @$_;
- {
- portlet_type => 'search',
- privacy => $privacy,
- id => $id,
- description => $desc,
-
- }
- } @{ delete $props->{Searches} } ];
+ {
+ portlet_type => 'search',
+ privacy => $privacy,
+ id => $id,
+ description => $desc,
+ pane => 'body',
+ }
+ } @{ delete $props->{Searches} }
+ ],
+ };
}
my ($status, $msg) = $attr->SetContent( $props );
$RT::Logger->error($msg) unless $status;
Modified: rt/3.8/trunk/lib/RT/Dashboard.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Dashboard.pm (original)
+++ rt/3.8/trunk/lib/RT/Dashboard.pm Wed Sep 3 20:43:04 2008
@@ -108,7 +108,7 @@
return $object->AddAttribute(
'Name' => 'Dashboard',
'Description' => $args->{'Name'},
- 'Content' => {Portlets => $args->{'Portlets'}},
+ 'Content' => {Panes => $args->{'Panes'}},
);
}
@@ -117,9 +117,9 @@
my $args = shift;
my ($status, $msg) = (1, undef);
- if (defined $args->{'Portlets'}) {
+ if (defined $args->{'Panes'}) {
($status, $msg) = $self->{'Attribute'}->SetSubValues(
- Portlets => $args->{'Portlets'},
+ Panes => $args->{'Panes'},
);
}
@@ -145,6 +145,18 @@
return ($status, $msg);
}
+=head2 Panes
+
+Returns a hashref of pane name to portlets
+
+=cut
+
+sub Panes {
+ my $self = shift;
+ return unless ref($self->{'Attribute'}) eq 'RT::Attribute';
+ return $self->{'Attribute'}->SubValue('Panes') || {};
+}
+
=head2 Portlets
Returns the list of this dashboard's portlets, each a hashref with key
@@ -154,8 +166,7 @@
sub Portlets {
my $self = shift;
- return unless ref($self->{'Attribute'}) eq 'RT::Attribute';
- return @{ $self->{'Attribute'}->SubValue('Portlets') || [] };
+ return map { @$_ } values %{ $self->Panes };
}
=head2 Searches
Modified: rt/3.8/trunk/share/html/Dashboards/Queries.html
==============================================================================
--- rt/3.8/trunk/share/html/Dashboards/Queries.html (original)
+++ rt/3.8/trunk/share/html/Dashboards/Queries.html Wed Sep 3 20:43:04 2008
@@ -59,23 +59,19 @@
<& Elements/HiddenSearches, searches => \@hidden_searches, Dashboard => $Dashboard &>
% }
-<form action="<%RT->Config->Get('WebPath')%>/Dashboards/Queries.html" method="post" enctype="multipart/form-data" name="DashboardQueries">
+<table width="100%" border="0">
+% for my $pane (@panes) {
+<tr><td valign="top" class="boxcontainer">
+<form action="Queries.html" method="post" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<%$Dashboard->Id%>" />
<input type="hidden" class="hidden" name="Privacy" value="<%$Dashboard->Privacy%>" />
-<table width="100%" border="0">
-<tr>
-<td valign="top" class="boxcontainer">
-<&| /Widgets/TitleBox, title => loc('Queries') &>
-<table>
-</td><td>
-<& /Widgets/SelectionBox:show, self => $sel, nojs => 1 &>
-</td></tr>
-</table>
+<&| /Widgets/TitleBox, title => $pane->{DisplayName} &>
+ <& /Widgets/SelectionBox:show, self => $pane, nojs => 1 &>
</&>
-
-</td>
-</tr>
+</form>
+</td></tr>
+% }
</table>
</form>
@@ -93,24 +89,26 @@
my %desc_of;
my @items;
-my @selected;
+my %selected;
# Get the list of queries already in use
-for my $portlet ($Dashboard->Portlets) {
- my ($name, $desc);
+do {
+ my $panes = $Dashboard->Panes;
+ for my $pane (keys %$panes) {
+ for my $portlet (@{ $panes->{$pane} }) {
+ my $name;
+ if ($portlet->{portlet_type} eq 'search') {
+ $name = join '-', 'search', $portlet->{id}, $portlet->{privacy};
+ }
+ else {
+ $name = join '-', 'component', $portlet->{component};
+ }
- if ($portlet->{portlet_type} eq 'search') {
- $name = join '-', 'search', $portlet->{id}, $portlet->{privacy};
- $desc = $portlet->{description};
- }
- else {
- $name = join '-', 'component', $portlet->{component};
- $desc = $portlet->{component};
+ push @{ $selected{$pane} }, $name;
+ $desc_of{$name} = $portlet->{description};
+ }
}
-
- push @selected, $name;
- $desc_of{$name} = $desc;
-}
+};
my @components = @{ RT->Config->Get('HomepageComponents') };
my %allowed_components = map {$_ => 1} @components;
@@ -139,53 +137,73 @@
}
}
-# Create a selectionbox widget for those queries
-my $sel = $m->comp(
- '/Widgets/SelectionBox:new',
- Action => 'Dashboards/Queries.html',
- Name => "Searches",
- Available => \@items,
- Selected => \@selected,
- AutoSave => 1,
- OnSubmit => sub {
- my $self = shift;
-
- my @portlets;
- for (@{ $self->{Current} }) {
- my $item = $_;
- my $desc = $desc_of{$item};
- my $portlet_type = $1 if $item =~ s/^(\w+)-//;
-
- if ($portlet_type eq 'search') {
- my ($search_id, $privacy) = split '-', $item, 2;
- push @portlets, {
- portlet_type => $portlet_type,
- privacy => $privacy,
- id => $search_id,
- description => $desc,
- };
+# Create selectionbox widgets for those queries
+
+my %pane_name = (
+ 'body' => loc('Body'),
+ 'sidebar' => loc('Sidebar'),
+);
+
+my @panes;
+for my $pane (keys %pane_name) {
+ my $sel = $m->comp(
+ '/Widgets/SelectionBox:new',
+ Action => 'Queries.html',
+ Name => "Searches-$pane",
+ DisplayName => $pane_name{$pane},
+ Available => \@items,
+ Selected => $selected{$pane},
+ AutoSave => 1,
+ OnSubmit => sub {
+ my $self = shift;
+
+ my @portlets;
+ for (@{ $self->{Current} }) {
+ my $item = $_;
+ my $desc = $desc_of{$item};
+ my $portlet_type = $1 if $item =~ s/^(\w+)-//;
+
+ if ($portlet_type eq 'search') {
+ my ($search_id, $privacy) = split '-', $item, 2;
+ push @portlets, {
+ portlet_type => $portlet_type,
+ privacy => $privacy,
+ id => $search_id,
+ description => $desc,
+ pane => $pane,
+ };
+ }
+ elsif ($portlet_type eq 'component') {
+ push @portlets, {
+ portlet_type => $portlet_type,
+ component => $item,
+ path => "/Elements/$item",
+ description => $item,
+ pane => $pane,
+ };
+ }
}
- elsif ($portlet_type eq 'component') {
- push @portlets, {
- portlet_type => $portlet_type,
- component => $item,
- path => "/Elements/$item",
- description => $item,
- };
+
+ # we want to keep all the other panes the same
+ my $panes = $Dashboard->Panes;
+ $panes->{$pane} = \@portlets;
+
+ my ($ok, $msg) = $Dashboard->Update(Panes => $panes);
+
+ if ($ok) {
+ push @results, loc("Dashboard updated");
}
- }
+ else {
+ push @results, loc("Dashboard could not be updated: [_1]", $msg);
+ }
+ },
+ );
- my ($ok, $msg) = $Dashboard->Update(Portlets => \@portlets);
+ push @panes, $sel;
+}
- if ($ok) {
- push @results, loc("Dashboard updated");
- }
- else {
- push @results, loc("Dashboard could not be updated: [_1]", $msg);
- }
- },
-);
-$m->comp('/Widgets/SelectionBox:process', %ARGS, self => $sel, nojs => 1);
+$m->comp('/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1)
+ for @panes;
my @hidden_searches = $Dashboard->PossibleHiddenSearches;
</%INIT>
More information about the Rt-commit
mailing list