highlight added columns with changed class
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 18 Jun 2010 15:33:28 +0000 (17:33 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 18 Jun 2010 15:33:28 +0000 (17:33 +0200)
lib/MojoFacets/Data.pm
public/mojo_facets.css
templates/data/edit.html.ep
templates/data/items/table.html.ep

index 7b29b73..62b03e1 100644 (file)
@@ -619,6 +619,8 @@ sub items {
        my $commit = $self->param('commit');
        my $test = $self->param('test');
 
+       my $cols_added;
+
        if ( $code && ( $test || $commit ) ) {
                # XXX find columns used in code snippet and show them to user
                foreach my $column ( $code =~ m/\$row->{(.+?)}/g ) {
@@ -627,6 +629,7 @@ sub items {
                        }
                        next if grep { /$column/ } @columns;
                        unshift @columns, $column;
+                       $cols_added->{$column}++;
                        if ( $commit ) {
                                $self->session('columns', [ @columns ]);
                                $loaded->{$path}->{columns} = [ @columns ];
@@ -679,6 +682,7 @@ sub items {
                numeric => { map { $_, $self->_is_numeric($_) } @columns },
                filters => $self->_current_filters,
                code => $code,
+               cols_added => $cols_added,
        );
 
 }
index 4564c1c..d57d687 100644 (file)
@@ -146,7 +146,7 @@ span.d {
        color: #ccc;
 }
 
-.saved {
+.changed {
        background: #ffe;
 }
 
index 8a58c09..48157d8 100644 (file)
@@ -1 +1 @@
-<div class=saved><%= $new_content %></div>
+<div class=changed><%= $new_content %></div>
index b7a6cec..a71db30 100644 (file)
@@ -1,3 +1,4 @@
+<pre class=debug><%= dumper $cols_added %></pre>
 
 <table border=1>
 
@@ -27,7 +28,7 @@ filter
 % foreach my $row ( @$sorted ) {
 <tr title="<%= $row->{_row_id} %>">
 % foreach my $col ( @$columns ) {
-<td<%= $numeric->{$col} ? ' class=numeric' : '' %>>
+<td<%= $numeric->{$col} ? ' class=numeric' : $cols_added->{$col} ? ' class=changed' : '' %>>
 %  if ( ref $row->{$col} eq 'ARRAY' ) {
 %   my $last = $#{ $row->{$col} };
 %   foreach ( 0 .. $last ) {