From 9137465ad9ef3e3e539a5243af9da2017b052cbe Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 23 May 2010 17:54:15 +0200 Subject: [PATCH] round-trip changes to server This allows changes to collect edits which in turn make them persistant. --- lib/MojoFacets/Data.pm | 8 ++++++++ public/edit_table.js | 17 ++++++++++------- public/mojo_facets.css | 4 ++++ templates/data/edit.html.ep | 1 + 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 templates/data/edit.html.ep diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index 68a6b0c..cd8174a 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -452,5 +452,13 @@ sub facet { ); } +sub edit { + my $self = shift; + my $content = $self->param('content'); + + $self->render( + content => $content + ); +} 1; diff --git a/public/edit_table.js b/public/edit_table.js index 73404fe..c230c7f 100644 --- a/public/edit_table.js +++ b/public/edit_table.js @@ -14,16 +14,19 @@ var cell_blur = function() { var y = $(this).parent().parent().attr('rowIndex'); var content = $(this).val(); - if ( 0 ) { // leave delimiters in edited cells visible - var vals = content.split('¶'); - content = vals.join('¶'); - } - -// var cell = $(''+content+''); - $(this).replaceWith( content ); +// $(this).replaceWith( content ); var name = $('table tr th:nth('+x+') > a').text(); console.info( x, y, pk, id, name, content ); + + var update = $(this); + + $.post( '/data/edit', { pk: pk, id: id, name: name, content: content } , function(data) { + console.debug( data ); + var vals = content.split('¶'); + data = vals.join('¶'); + update.replaceWith( data ); + }); } var cell_click = function(event) { diff --git a/public/mojo_facets.css b/public/mojo_facets.css index 81fb772..6a1a959 100644 --- a/public/mojo_facets.css +++ b/public/mojo_facets.css @@ -136,3 +136,7 @@ a#excluded { span.d { color: #ccc; } + +.saved { + background: #ffe; +} diff --git a/templates/data/edit.html.ep b/templates/data/edit.html.ep new file mode 100644 index 0000000..31309b5 --- /dev/null +++ b/templates/data/edit.html.ep @@ -0,0 +1 @@ +
<%= $content %>
-- 2.20.1