[Rt-commit] r17849 - in rt/3.999/trunk: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Jan 21 00:59:25 EST 2009


Author: sunnavy
Date: Wed Jan 21 00:59:25 2009
New Revision: 17849

Modified:
   rt/3.999/trunk/   (props changed)
   rt/3.999/trunk/lib/RT/Dashboard.pm

Log:
 r18935 at sunnavys-mb:  sunnavy | 2009-01-21 13:55:20 +0800
 merged lib/RT/Dashboard.pm


Modified: rt/3.999/trunk/lib/RT/Dashboard.pm
==============================================================================
--- rt/3.999/trunk/lib/RT/Dashboard.pm	(original)
+++ rt/3.999/trunk/lib/RT/Dashboard.pm	Wed Jan 21 00:59:25 2009
@@ -108,7 +108,8 @@
     return $object->add_attribute(
         'name'        => 'Dashboard',
         'description' => $args->{'name'},
-        'content'     => { Searches => $args->{'searches'} },
+        'content'     => { Panes => $args->{'panes'} },
+        
     );
 }
 
@@ -117,10 +118,9 @@
     my $args = shift;
 
     my ( $status, $msg ) = ( 1, undef );
-    if ( defined $args->{'searches'} ) {
+    if ( defined $args->{'panes'} ) {
         ( $status, $msg ) =
-          $self->{'attribute'}
-          ->set_sub_values( searches => $args->{'searches'}, );
+          $self->{'attribute'}->set_sub_values( panes => $args->{'panes'}, );
     }
 
     if ( $status && $args->{'name'} ) {
@@ -141,68 +141,73 @@
             ( $status, $msg ) = $attr->set_object_id($new_obj_id);
         }
         $self->{'privacy'} = $args->{'privacy'} if $status;
+            
     }
 
     return ( $status, $msg );
 }
 
-=head2 searches
+=head2 panes
 
-Returns a list of loaded saved searches
+Returns a hashref of pane name to portlets
 
 =cut
 
-sub searches {
+sub panes {
     my $self = shift;
-    return map {
-        my $search = RT::SavedSearch->new( current_user => $self->current_user );
-        $search->load( $_->[0], $_->[1] );
-        $search
-    } $self->search_ids;
+    return unless ref( $self->{'attribute'} ) eq 'RT::Model::Attribute';
+    return $self->{'attribute'}->sub_value('panes') || {};
+    
 }
 
-=head2 search_ids
+=head2 portlets
 
-Returns a list of array references, each being a saved-search privacy, ID, and
-description
+Returns the list of this dashboard's portlets, each a hashref with key
+C<portlet_type> being C<search> or C<component>.
 
 =cut
 
-sub search_ids {
+sub portlets {
     my $self = shift;
-    return unless ref( $self->{'attribute'} ) eq 'RT::Model::Attribute';
-    return @{ $self->{'attribute'}->sub_value('searches') || [] };
+    return map { @$_ } values %{ $self->panes };
 }
 
-=head2 search_privacies
+=head2 searches
 
-Returns a list of array references, each one being suitable to pass to
-/Elements/ShowSearch.
+Returns a list of loaded saved searches
 
 =cut
 
-sub search_privacies {
+sub searches {
     my $self = shift;
-    return map { [ $self->search_privacy(@$_) ] } $self->search_ids;
+    return map {
+        my $search = RT::SavedSearch->new;
+        $search->load( $_->{privacy}, $_->{id} );
+        $search
+    } grep { $_->{portlet_type} eq 'search' } $self->portlets;
 }
 
-=head2 search_privacy TYPE, ID, DESC
+=head2 show_search_name portlet
 
 Returns an array for one saved search, suitable for passing to
 /Elements/ShowSearch.
 
 =cut
 
-sub search_privacy {
-    my $self = shift;
-    my ( $type, $id, $desc ) = @_;
-    if ( $type eq 'RT::System' ) {
-        return name =>  $desc;
+sub show_search_name {
+    my $self    = shift;
+    my $portlet = shift;
+
+    if ( $portlet->{privacy} eq 'RT::System' ) {
+        return name => $portlet->{description};
     }
 
-    return saved_search => join( '-', $type, 'SavedSearch', $id );
+    return saved_search =>
+      join( '-', $portlet->{privacy}, 'SavedSearch', $portlet->{id} );
 }
 
+
+
 =head2 possible_hidden_searches
 
 This will return a list of saved searches that are potentially not visible by
@@ -219,8 +224,8 @@
 }
 
 # _privacy_objects: returns a list of objects that can be used to load
-# dashboards from. If the Modify parameter is true, then check modify rights.
-# If the Create parameter is true, then check create rights. Otherwise, check
+# dashboards from. If the modify parameter is true, then check modify rights.
+# If the create parameter is true, then check create rights. Otherwise, check
 # read rights.
 
 sub _privacy_objects {


More information about the Rt-commit mailing list