Skip to content

Commit

Permalink
Adding projects is now supported :)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyaray committed Feb 23, 2011
1 parent 5965ddc commit 4046e1d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
24 changes: 12 additions & 12 deletions _attachments/js/chillax-store.js
Expand Up @@ -2,24 +2,24 @@ $chillax.store = {};

$chillax.store._db = null;

$chillax.store.createTask = function (task, callback) {
assert(typeof(callback) === "function", "writeTask, callback");
$chillax.store._writeDoc = function(doc, callback) {
assert(typeof(callback) === "function", "writeProject, callback");

console.log("saveDoc");
console.log(task);

return $chillax.store._db.saveDoc(task, {
return $chillax.store._db.saveDoc(doc, {
"success": callback
});
};

$chillax.store.writeTask = function (task, callback) {
assert(task._id !== undefined, "writeTask, task");
assert(typeof(callback) === "function", "writeTask, callback");
$chillax.store.writeProject = function (project, callback) {
assert(project.type && project.type === "project", "writeProject");
// TODO:
// assert that checks if rev is present and demands that _id also exists
$chillax.store._writeDoc(project, callback);
};

$chillax.store._db.saveDoc(task, {
"success": callback
});
$chillax.store.writeTask = function (task, callback) {
assert(task.type && task.type === "task", "writeTask");
$chillax.store._writeDoc(task, callback);
};

$chillax.store.updateTask = (function () {
Expand Down
23 changes: 22 additions & 1 deletion _attachments/js/chillax-ui.js
Expand Up @@ -235,6 +235,27 @@ $chillax.ui.init = function() {
}
});

$('#createproject').click(function() {
var name = $(this).parent().find('#createprojectname');
var nameStr = name.val();
if (nameStr === "")
{
// do stuff appropriate for when no name is given

return;
}

var project = {
"type":"project",
"name":nameStr
};

$chillax.store.writeProject(project, function(){
console.log("Created project");
$chillax.ui.refreshProjects();
});
});

$('#createtask').click(function() {
var name = $(this).parent().find('#createtaskname');
var nameStr = name.val();
Expand All @@ -252,7 +273,7 @@ $chillax.ui.init = function() {
};

name.val('');
$chillax.store.createTask(task, function(){
$chillax.store.writeTask(task, function(){
console.log("Created task");
$chillax.ui.refreshTasklist($chillax.ui._projectId);
});
Expand Down

0 comments on commit 4046e1d

Please sign in to comment.