From eecf7c8888bde22f9518b84b1ad9b8438f88306e Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 20 Jun 2010 14:04:31 +0200 Subject: [PATCH] another $col_changed cleanup 0 denotes used column (extracted from source using regex), while positive numbers denote added columns. This allow allow us to color used and created columns differently --- lib/MojoFacets/Data.pm | 9 ++++----- public/mojo_facets.css | 4 ++++ templates/data/items/table.html.ep | 16 +++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index 1382fe2..d74763f 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -614,8 +614,7 @@ sub items { $column =~ s/$1$//; } next if $column =~ m/\$/; # hide columns with vars in them - next if grep { /$column/ } @columns; - $cols_changed->{$column}++; + $cols_changed->{$column} = 0; } } @@ -694,14 +693,14 @@ sub items { warn "EVAL ",dump($row); $old->{$_}-- foreach keys %$row; warn "columns changed ",dump($old); - $cols_changed->{$_} += 2 foreach grep { $old->{$_} == -1 } keys %$old; + $cols_changed->{$_}++ foreach grep { $old->{$_} == -1 } keys %$old; } } $row->{_row_id} ||= $id; push @$sorted_items, $row; } - my @added_columns = sort grep { $cols_changed->{$_} > 1 } keys %$cols_changed; + my @added_columns = sort grep { $cols_changed->{$_} > 0 } keys %$cols_changed; unshift @columns, @added_columns; if ( $commit ) { @@ -712,7 +711,7 @@ sub items { warn "# sorted_items ", $#$sorted_items + 1, " offset $offset limit $limit order $sort"; my $code_depends = $self->param('code_depends')|| - join(',', sort grep { $cols_changed->{$_} == 1 } keys %$cols_changed ); + join(',', sort grep { $cols_changed->{$_} == 0 } keys %$cols_changed ); my $code_description = $self->param('code_description') || join(',', @added_columns); diff --git a/public/mojo_facets.css b/public/mojo_facets.css index d57d687..f667e13 100644 --- a/public/mojo_facets.css +++ b/public/mojo_facets.css @@ -150,6 +150,10 @@ span.d { background: #ffe; } +.used { + background: #eee; +} + form.action_filter { float: right; } diff --git a/templates/data/items/table.html.ep b/templates/data/items/table.html.ep index f3866e5..eb18192 100644 --- a/templates/data/items/table.html.ep +++ b/templates/data/items/table.html.ep @@ -1,10 +1,11 @@ +
<%= dumper $cols_changed %>
% my $commit = param('commit'); % foreach my $n ( @$columns ) { -% if ( $cols_changed->{$n} > 1 && ! $commit ) { - % foreach my $col ( @$columns ) { -% my $class = ''; -% $class .= ' numeric' if $numeric->{$col}; -% $class .= ' changed' if $cols_changed->{$col}; -% $class =~ s/^ / class="/ && $class =~ s/$/"/; -> +% my @class ; +% push @class, 'numeric' if $numeric->{$col}; +% if ( defined $cols_changed->{$col} ) { +% push @class, $cols_changed->{$col} ? 'changed' : 'used'; +% } +
+% if ( defined $cols_changed->{$n} && ! $commit ) { +{$n} ? 'changed' : 'used' %>> <%= $n %> % } else { @@ -36,11 +37,12 @@ filter % foreach my $row ( @$sorted ) {
% if ( ref $row->{$col} eq 'ARRAY' ) { % my $last = $#{ $row->{$col} }; % foreach ( 0 .. $last ) { -- 2.20.1