Skip to content

Commit

Permalink
hello
Browse files Browse the repository at this point in the history
  • Loading branch information
krav committed Nov 19, 2012
1 parent 0060d31 commit 6b93ae0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
21 changes: 16 additions & 5 deletions web/js/hangover.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ var sort_fields = function(fields) {
return result.reverse(); return result.reverse();
} }



$.Model('db', { $.Model('db', {
findAll: "/db", findAll: "GET /db",
findOne: "/db" findOne: "GET /db",
update: "PUT /db/{id}",
}, {}); }, {});


$.Controller("search", { $.Controller("search", {
Expand Down Expand Up @@ -80,9 +82,18 @@ $.route.bind('change', function(ev, attr, how, newval, oldval) {
case "database": case "database":
switch(ev['target']['action']) { switch(ev['target']['action']) {
case "edit": case "edit":
db.findOne({id: ev['target']['id']}, function(result) { db.findOne({id: ev['target']['id']}, function(result) {
var r = result[0]; // FIXME sort - extract keys var r = result[0];
$("#content").html($.View("tmpl/database_edit.ejs", {entry: r})); var fields = sort_fields(r.fields)
$("#content").html($.View("tmpl/database_edit.ejs", {entry: r.result, fields: fields}));
var save_thing = function() {
var form = $('#entry').formParams();
console.log(r);
r.result = form;
result.save();
return(false);
}
$("#save").bind("click", save_thing);
}); });
break; // edit break; // edit
default: default:
Expand Down
2 changes: 1 addition & 1 deletion web/lib/lamt
Submodule lamt updated from 6a2772 to 1c6f6e
2 changes: 0 additions & 2 deletions web/tmpl/database.ejs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
<h3>Upload</h3> <h3>Upload</h3>
<form class="well form-search" method="post" enctype="multipart/form-data" action="/db"> <form class="well form-search" method="post" enctype="multipart/form-data" action="/db">
<fieldset> <fieldset>
<input type="text" id="artist"></input>
<input type="text" id="title"></input>
<input type="file" name="file" /> <input type="file" name="file" />
<button type="submit" class="btn btn-danger">Upload!</button> <button type="submit" class="btn btn-danger">Upload!</button>
</fieldset> </fieldset>
Expand Down

0 comments on commit 6b93ae0

Please sign in to comment.