% layout 'ui';
-<h2><%= $message %></h2>
-<form class=action_filter>
-<input type=submit value="Filter changes">
-<ul>
-% foreach my $type ( sort keys %$actions ) {
+% 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 type=checkbox name=action_filter value="<%= $type %>">
-<%= $type %><span class=count><%= $actions->{$type} %></span>
+<input name=show type=checkbox value="<%= $status %>" checked>
+<%= $status %>
+<span class=count><%= $stats->{$status} %></span>
</label>
-% }
+% }
</ul>
-<input type=submit value="Filter changes">
+
+% 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>
-<tr><th>action</th><th>timestamp</th></tr>
-% foreach my $change ( @$changes ) {
-<tr><td>
-<a class="view" href="<%= url_for( controller => 'changes', action => 'view' )->query( uid => $change->{uid} ) %>"><%= $change->{action} %></a>
-</td><td>
-<tt class=ts><%= $change->{t} %></tt>
-</td></tr>
+
+% 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} ) {
+% if ( defined $e->{unique} ) {
+% 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 class=remove 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>
% }
-</table>
-% my $more = ( $#$changes ) * 10;
-Show <a href="<%= url_for( controller => 'changes', action => 'index' )->query( max => $more ) %>"><%= $more %> changes</a>
+% if ( $dump ) {
+</td><td><pre class=debug><%= dumper $e %></pre>
+% }
+</tr>
+% }
-<script type="text/javascript" src="/js/date_pretty.js"></script>
-<script type="text/javascript">
-$(document).ready( function(){
- console.debug('convert timestamps');
- $('tt.ts').each( function(){
- $(this).text( date_pretty( new Date(this.textContent * 1000) ) );
- });
+</table>
- $('a.view').live( 'click', function() {
- console.debug(this.href);
- var e = $(this).parent();
- var link_html = e.html();
- $.ajax({
- url: this.href,
- success: function(data){
- var form = $(data).filter('form');
- console.debug('ajax',e,form);
- e.html( form )
- .addClass( 'change_box' )
- .append(
- $('<input type=button value=hide>').click( function() {
-console.debug(this,link_html);
- e.html( link_html ).removeClass( 'change_box' ).addClass( 'change_viewed' );
- })
- )
- ;
- }
- })
- return false;
- });
+<pre class=debug>
+<%= dumper( $stats ) %>
+</pre>
- $('form input[name=_master]').live( 'click', function(){
- var master = this.value;
- console.debug('replication master', master);
+<script type="text/javascript">
- $(this).closest('form').attr('action', function() {
- return master + this.action;
- }).css({ 'background': '#ffe' });
+$(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>