apply on current dataset by default
[MojoFacets.git] / templates / changes / index.html.ep
1 % layout 'ui';
2
3
4 % my $dump = param('dump');
5 % my $apply_on_path = param('apply_on_path') || session('path');
6
7 <form method=post>
8 <input type=submit value="Apply"> on
9 <select name=apply_on_path>
10 % foreach my $p ( @$loaded ) {
11 <option<%= $p eq $apply_on_path ? ' selected' : '' %>><%= $p %></option>
12 % }
13 </select>
14
15 <span class=count><%= $#{ $changes } + 1 %></span>
16
17 <label><input type=checkbox name=dump <%= $dump ? 'checked' : '' %>>dump</label>
18
19 % if ( $apply_on_path ) {
20 <ul id=status>
21 %  foreach my $status ( keys %$stats ) {
22 <li><label>
23 <input name=show type=checkbox value="<%= $status %>" checked>
24 <%= $status %>
25 <span class=count><%= $stats->{$status} %></span>
26 </label>
27 %  }
28 </ul>
29
30 %  if ( ! param('commit') ) {
31 <input type=submit name=commit value="Commit changes">
32 %  } else {
33 <b>
34 Changes commited to <a href="<%= url_for( controller => 'data', action => 'load' )->query( path => $apply_on_path ) %>"><%= $apply_on_path %></a>
35 </b>
36 %  }
37
38 % }
39
40 </form>
41
42 % my $tr = { new => [ qw( old new ) ], code => [ qw( code columns_changed ) ] };
43
44 <table>
45
46 % foreach my $e ( @$changes ) {
47
48 %  foreach my $type ( keys %$tr ) {
49 %   if ( exists $e->{$type} ) {
50 <tr>
51 <th></th>
52 <th><%= $tr->{$type}->[0] %></th>
53 <th><%= $tr->{$type}->[1] %></th>
54 </tr>
55 %    delete $tr->{$type}; last;
56 %   }
57 %  }
58
59 <tr class="change <%= $e->{_status} || 'unknown' %>">
60 <td>
61 <%= $e->{time} %>
62 <tt><%= $e->{column} %></tt>
63 %  if ( my $status = $e->{_status} ) {
64 %    my ( $pk, $id ) = %{ $e->{unique} };
65 <a href="<%= url_for( controller => 'data', action => 'filter' )->query( filter_name => $pk, filter_vals => $id ) %>"><%= $id %></a>
66 <%= $status %>
67 %  } else {
68 <a href="<%= url_for( action => 'remove' )->query( time => $e->{time} ) %>">remove</a>
69 %  }
70
71 % if ( defined $e->{new} ) {
72 </td><td><%== defined $e->{old} && join('<span class=d>&para;</span>', @{$e->{old}}) %>
73 </td><td><%==                      join('<span class=d>&para;</span>', @{$e->{new}}) %>
74 % } elsif ( defined $e->{code} ) {
75 </td><td><pre><%= $e->{code} %></pre></td>
76 </td><td><pre class=debug><%= dumper $e->{commit_changed} %></pre>
77 % } else {
78 </td><td colspan=2><pre class=debug><%= dumper $e %></pre>
79 % }
80
81 %  if ( $dump ) {
82 </td><td><pre class=debug><%= dumper $e %></pre>
83 %  }
84 </tr>
85 % }
86
87 </table>
88
89 <pre class=debug>
90 <%= dumper( $stats ) %>
91 </pre>
92
93 <script type="text/javascript">
94
95 $(document).ready( function(){
96         console.debug('ready');
97         $('ul#status > li input[type=checkbox]').click( function(){
98                 var toggle = this.value;
99                 console.debug('click',this,toggle);
100                 $('tr.'+toggle).toggleClass('hidden');
101         });
102 });
103
104 </script>