From 92ee7b243906996d59c45194a6f811884b5af51d Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 18 Jun 2010 17:33:28 +0200 Subject: [PATCH] highlight added columns with changed class --- lib/MojoFacets/Data.pm | 4 ++++ public/mojo_facets.css | 2 +- templates/data/edit.html.ep | 2 +- templates/data/items/table.html.ep | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index 7b29b73..62b03e1 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -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, ); } diff --git a/public/mojo_facets.css b/public/mojo_facets.css index 4564c1c..d57d687 100644 --- a/public/mojo_facets.css +++ b/public/mojo_facets.css @@ -146,7 +146,7 @@ span.d { color: #ccc; } -.saved { +.changed { background: #ffe; } diff --git a/templates/data/edit.html.ep b/templates/data/edit.html.ep index 8a58c09..48157d8 100644 --- a/templates/data/edit.html.ep +++ b/templates/data/edit.html.ep @@ -1 +1 @@ -
<%= $new_content %>
+
<%= $new_content %>
diff --git a/templates/data/items/table.html.ep b/templates/data/items/table.html.ep index b7a6cec..a71db30 100644 --- a/templates/data/items/table.html.ep +++ b/templates/data/items/table.html.ep @@ -1,3 +1,4 @@ +
<%= dumper $cols_added %>
@@ -27,7 +28,7 @@ filter % foreach my $row ( @$sorted ) { % foreach my $col ( @$columns ) { -{$col} ? ' class=numeric' : '' %>> +{$col} ? ' class=numeric' : $cols_added->{$col} ? ' class=changed' : '' %>> % if ( ref $row->{$col} eq 'ARRAY' ) { % my $last = $#{ $row->{$col} }; % foreach ( 0 .. $last ) { -- 2.20.1