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