implement replication checkbox
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 27 May 2010 19:19:53 +0000 (21:19 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 27 May 2010 19:19:53 +0000 (21:19 +0200)
use MASTER enviroment variable contains url of another instance
of mojo_facets, and user interface shows checkbox which allow
replication to master instance.

templates/changes/index.html.ep
templates/changes/view.html.ep

index dafd11c..8c96987 100644 (file)
@@ -37,11 +37,19 @@ $(document).ready( function(){
        });
 
        $('a.view').live( 'click', function() {
-               console.debug(this
-                       , this.href
-               );
+               console.debug(this.href);
                $(this).parent().load( this.href + ' form' ).css({ 'border': '3px dashed #f84' });
                return false;
        });
+
+       $('form input[name=_master]').live( 'click', function(){
+               var master = this.value;
+               console.debug('replication master', master);
+
+               $(this).closest('form').attr('action', function() {
+                       return master + this.action;
+               }).css({ 'background': '#ffe' });
+       });
+
 });
 </script>
index a65dc3b..8dd4e5c 100644 (file)
@@ -5,6 +5,9 @@
 % $action = url_for( controller => 'data', action => $action );
 <form method=post action=<%= $action %>>
 <input type=submit value="<%= $action %>">
+% if ( my $master = $ENV{'MASTER'} ) {
+<input class=replication type=checkbox name="_master" value="<%= $master %>" title="replicate to <%= $master %>">
+% }
 % my $params = $change->{params};
 <ul>
 % while ( @$params ) {