[Rt-commit] r9654 - in rt/branches/3.6-RELEASE/html: Admin/Elements

ruz at bestpractical.com ruz at bestpractical.com
Tue Nov 13 12:59:33 EST 2007


Author: ruz
Date: Tue Nov 13 12:59:32 2007
New Revision: 9654

Modified:
   rt/branches/3.6-RELEASE/html/Admin/Elements/ConfigureMyRT
   rt/branches/3.6-RELEASE/html/Widgets/SelectionBox

Log:
* add labeling of portlets that are based on components,
  it doesn't support localization, but it's better than empty label
* allow to manage many portlets that are based on the same
  comp by adding optional 'id' key

Modified: rt/branches/3.6-RELEASE/html/Admin/Elements/ConfigureMyRT
==============================================================================
--- rt/branches/3.6-RELEASE/html/Admin/Elements/ConfigureMyRT	(original)
+++ rt/branches/3.6-RELEASE/html/Admin/Elements/ConfigureMyRT	Tue Nov 13 12:59:32 2007
@@ -64,15 +64,35 @@
         AutoSave  => 1,
         OnSubmit  => sub {
             my $sel = shift;
-            $portlets->{$pane} = [
-                map { m/(\w+)-(.*)$}/;
-                      { type => $1,
-                        name => $2 } } @{ $sel->{Current} }
-            ];
+
+            my @res;
+            foreach my $e ( @{ $sel->{Current} } ) {
+                my %row;
+                @row{qw(type name id)} = split /-/, $e, 3;
+                my $old = ( grep {
+                    ($_->{'type'}||'') eq ($row{'type'}||'')
+                    && ($_->{'name'}||'') eq ($row{'name'}||'')
+                    && ($_->{'id'}||'') eq ($row{'id'}||'')
+                } @{ $portlets->{$pane} || [] } )[0];
+                %row = %$old if $old;
+                push @res, \%row;
+            }
+
+            $portlets->{$pane} = \@res;
             $OnSave->( $portlets, $pane );
         },
-        Selected => [ map { join( '-', @{$_}{qw/type name/} ) }
-                      @{ $portlets->{$pane} } ]
+        Selected => [
+            map {
+                join( '-', grep $_, @{$_}{qw/type name id/} )
+            } @{ $portlets->{$pane} }
+        ],
+        Label => {
+            map {
+                join( '-', grep $_, @{$_}{qw/type name id/} ),
+                $_->{'label'}
+            }
+            grep $_->{'label'}, @{ $portlets->{$pane} }
+        },
     );
 }
 

Modified: rt/branches/3.6-RELEASE/html/Widgets/SelectionBox
==============================================================================
--- rt/branches/3.6-RELEASE/html/Widgets/SelectionBox	(original)
+++ rt/branches/3.6-RELEASE/html/Widgets/SelectionBox	Tue Nov 13 12:59:32 2007
@@ -84,7 +84,9 @@
 
 <%method new>
 <%init>
-$ARGS{_item_map} = {map {$_->[0] => $_->[1]} @{$ARGS{Available}}};
+$ARGS{_item_map} = { map { $_->[0] => $_->[1] } @{ $ARGS{Available} } };
+$ARGS{_item_map} = { %{ $ARGS{_item_map} }, %{ $ARGS{'Label'} } }
+    if $ARGS{'Label'};
 return \%ARGS;
 </%init>
 </%method>
@@ -198,7 +200,7 @@
 % if (exists $selected{$_}) {
 selected="selected"
 % }
-><% $self->{_item_map}{$_} %></option>
+><% $self->{_item_map}{$_} || $_ %></option>
 % }
 </select>
  <input name="moveup" type="submit" class="button" value=" &uarr; " />


More information about the Rt-commit mailing list