[Rt-commit] r18164 - in rt/3.999/branches/merge_to_3.8.2: share/html/Dashboards

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Feb 4 02:52:28 EST 2009


Author: sunnavy
Date: Wed Feb  4 02:52:22 2009
New Revision: 18164

Modified:
   rt/3.999/branches/merge_to_3.8.2/   (props changed)
   rt/3.999/branches/merge_to_3.8.2/share/html/Dashboards/Queries.html

Log:
 r19496 at sunnavys-mb:  sunnavy | 2009-02-04 13:58:40 +0800
 rescue missed merge stuff for share/html/Dashboards/Queries.html


Modified: rt/3.999/branches/merge_to_3.8.2/share/html/Dashboards/Queries.html
==============================================================================
--- rt/3.999/branches/merge_to_3.8.2/share/html/Dashboards/Queries.html	(original)
+++ rt/3.999/branches/merge_to_3.8.2/share/html/Dashboards/Queries.html	Wed Feb  4 02:52:22 2009
@@ -85,13 +85,33 @@
 
 my %desc_of;
 my @items;
-my @selected;
+my %selected;
 
 # Get the list of queries already in use
-for ($Dashboard->search_ids) {
-    my ($privacy, $id, $desc) = @$_;
-    my $name = "$id-$privacy";
-    push @selected, $name;
+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};
+            }
+
+            push @{ $selected{$pane} }, $name;
+            $desc_of{$name} = $portlet->{description};
+        }
+    }
+};
+
+my @components = @{ RT->config->get('HomepageComponents') };
+my %allowed_components = map {$_ => 1} @components;
+
+for my $desc (@components) {
+    my $name = "component-$desc";
+    push @items, [$name, $desc];
     $desc_of{$name} = $desc;
 }
 
@@ -107,40 +127,80 @@
         my ($desc, $search) = @$_;
         my $SearchType = $search->content->{'SearchType'} || 'Ticket';
         my $privacy = $Dashboard->_build_privacy($object);
-        my $name = $search->id . '-' . $privacy;
+        my $name = 'search-' . $search->id . '-' . $privacy;
         push @items, [$name, $desc];
         $desc_of{$name} = $desc;
     }
 }
 
-# Create a selectionbox widget for those queries
-my $sel = $m->comp(
-    '/Widgets/SelectionBox:new',
-    action    => 'Dashboards/Queries.html',
-    name      => "searches",
-    available => \@items,
-    selected  => \@selected,
-    auto_save  => 1,
-    on_submit  => sub {
-        my $self = shift;
-
-        # transform list of "SearchID-PrivacyObjType-PrivacyObjID"s to
-        # list of [Privacy, SearchID, description]s
-        my $searches = [ map {
-            [ reverse(split /-/, $_, 2), $desc_of{$_} ]
-        } @{ $self->{Current} } ];
+# Create selectionbox widgets for those queries
+my %pane_name = (
+    'body'    => _('Body'),
+    'sidebar' => _('Sidebar'),
+);
+
+my @panes;
+for my $pane (keys %pane_name) {
+    my $sel = $m->comp(
+        '/Widgets/SelectionBox:new',
+        action      => 'Queries.html',
+        name        => "Searches-$pane",
+        display_name => $pane_name{$pane},
+        available   => \@items,
+        selected    => $selected{$pane},
+        auto_save    => 1,
+        on_submit    => 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,
+                    };
+                }
+            }
+
+            # 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, _("Dashboard updated");
+            }
+            else {
+                push @results, _("Dashboard could not be updated: %1", $msg);
+            }
+        },
+    );
 
-        my ($ok, $msg) = $Dashboard->update(searches => $searches);
+    push @panes, $sel;
+}
 
-        if ($ok) {
-            push @results, _("Dashboard updated");
-        }
-        else {
-            push @results, _("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->possible_hidden_searches;
 
 </%INIT>
 <%ARGS>


More information about the Rt-commit mailing list