-% layout 'default';
-<h2><%= $message %></h2>
+% layout 'ui';
-<ul>
-% foreach my $change ( @$changes ) {
-<li>
-<%= $change->{t} %>
-<a href="<%= url_for( controller => 'changes', action => 'view' )->query( uid => $change->{uid} ) %>"><%= $change->{action} %></a>
+% my $dump = param('dump');
+
+<form method=post>
+<input name=apply type=submit value="Apply"> on
+<select name=on_path>
+% foreach my $p ( @$loaded ) {
+<option<%= $p eq $on_path ? ' selected' : '' %>><%= $p %></option>
% }
+</select>
+
+<span class=count><%= $#{ $changes } + 1 %></span>
+
+<label><input type=checkbox name=dump <%= $dump ? 'checked' : '' %>>dump</label>
+
+% if ( $on_path ) {
+<ul id=status>
+% foreach my $status ( keys %$stats ) {
+<li><label>
+<input name=show type=checkbox value="<%= $status %>" checked>
+<%= $status %>
+<span class=count><%= $stats->{$status} %></span>
+</label>
+% }
</ul>
+
+% if ( ! param('commit') && param('apply') ) {
+<input type=submit name=commit value="Commit changes">
+% } elsif ( param('commit') ) {
+<b>
+Changes commited to <a href="<%= url_for( controller => 'data', action => 'items' )->query( path => $on_path ) %>"><%= $on_path %></a>
+</b>
+<pre><%= dumper stash('commit_changed') %></pre>
+% }
+
+% }
+
+</form>
+
+% my $tr = { new => [ qw( old new ) ], code => [ qw( code columns_changed ) ] };
+
+<table>
+
+% foreach my $e ( @$changes ) {
+
+% foreach my $type ( keys %$tr ) {
+% if ( exists $e->{$type} ) {
+<tr>
+<th></th>
+<th><%= $tr->{$type}->[0] %></th>
+<th><%= $tr->{$type}->[1] %></th>
+</tr>
+% delete $tr->{$type}; last;
+% }
+% }
+
+<tr class="change <%= $e->{_status} || 'unknown' %>">
+<td>
+<%= $e->{time} %>
+<tt><%= $e->{column} %></tt>
+% if ( my $status = $e->{_status} ) {
+% my ( $pk, $id ) = %{ $e->{unique} };
+<a href="<%= url_for( controller => 'data', action => 'filter' )->query( filter_name => $pk, filter_vals => $id ) %>"><%= $id %></a>
+<%= $status %>
+% } else {
+<a href="<%= url_for( action => 'remove' )->query( time => $e->{time} ) %>">remove</a>
+% }
+
+% if ( defined $e->{new} ) {
+</td><td><%== defined $e->{old} && join('<span class=d>¶</span>', @{$e->{old}}) %>
+</td><td><%== join('<span class=d>¶</span>', @{$e->{new}}) %>
+% } elsif ( defined $e->{code} ) {
+</td><td><pre><%= $e->{code} %></pre></td>
+</td><td><pre class=debug><%= dumper $e->{commit_changed} %></pre>
+% } else {
+</td><td colspan=2><pre class=debug><%= dumper $e %></pre>
+% }
+
+% if ( $dump ) {
+</td><td><pre class=debug><%= dumper $e %></pre>
+% }
+</tr>
+% }
+
+</table>
+
+<pre class=debug>
+<%= dumper( $stats ) %>
+</pre>
+
+<script type="text/javascript">
+
+$(document).ready( function(){
+ console.debug('ready');
+ $('ul#status > li input[type=checkbox]').click( function(){
+ var toggle = this.value;
+ console.debug('click',this,toggle);
+ $('tr.'+toggle).toggleClass('hidden');
+ });
+});
+
+</script>