Skip to content
Browse files

Merge branch 'master' of github.com:comotion/hangover

  • Loading branch information...
2 parents afa49e1 + 687e329 commit 65738614d0e835f6634a270bd5f74b62107b1256 @comotion committed Nov 19, 2012
Showing with 8 additions and 12 deletions.
  1. +1 −2 web/hangover.lua
  2. +6 −9 web/js/hangover.js
  3. +1 −1 web/tmpl/tracks.ejs
View
3 web/hangover.lua
@@ -133,8 +133,7 @@ end
function get_track(web,...)
local id = ...
local track = tracks:get(id)
- local fields = u.keys(track)
- return json.encode{{fields=fields,result=track}}
+ return json.encode(track)
end
View
15 web/js/hangover.js
@@ -55,15 +55,15 @@ $.Controller("search", {
"click": function(el) {
var query={q: $('#query', el.parent()).val()};
db.findAll(query, function(result) {
- console.log(result[0]['result']);
var r = result[0]; // what
if (r['result'].length == undefined) {
console.log("null result");
$("#searchresult").html("<h1>No match</h1>");
return;
}
- r.fields = sort_fields(r.fields);
- $("#searchresult").html($.View("tmpl/tracks.ejs", r));
+ fields = sort_fields(r.fields);
+ console.log(r);
+ $("#searchresult").html($.View("tmpl/tracks.ejs", {fields: fields, results: r.result}));
});
return(false);
}
@@ -83,14 +83,11 @@ $.route.bind('change', function(ev, attr, how, newval, oldval) {
switch(ev['target']['action']) {
case "edit":
db.findOne({id: ev['target']['id']}, function(result) {
- var r = result[0];
- var fields = sort_fields(r.fields)
- $("#content").html($.View("tmpl/database_edit.ejs", {entry: r.result, fields: fields}));
+ var fields = ["filename", "title"]; // sort_fields(r.fields)
+ $("#content").html($.View("tmpl/database_edit.ejs", {entry: result, fields: fields}));
var save_thing = function() {
var form = $('#entry').formParams();
- console.log(r);
- r.result = form;
- result.save();
+ result.update(form);
return(false);
}
$("#save").bind("click", save_thing);
View
2 web/tmpl/tracks.ejs
@@ -6,7 +6,7 @@
<th></th>
</tr>
- <% result.forEach(function(r){ %>
+ <% results.forEach(function(r){ %>
<tr> <!-- TODO: make dragable -->
<% fields.forEach(function(f){ %>
<td><%= r[f] %></td>

0 comments on commit 6573861

Please sign in to comment.
Something went wrong with that request. Please try again.