[API] Allow tasks to be added

This commit is contained in:
Victor Woeltjen
2016-06-17 14:18:51 -07:00
parent dbe6a4efc1
commit 4a50f325cb
2 changed files with 20 additions and 13 deletions

View File

@ -0,0 +1,3 @@
<label>Description:
<input type="text" class="description">
</label>

View File

@ -2,8 +2,9 @@ define([
"text!./todo.html", "text!./todo.html",
"text!./todo-task.html", "text!./todo-task.html",
"text!./todo-toolbar.html", "text!./todo-toolbar.html",
"text!./todo-dialog.html",
"zepto" "zepto"
], function (todoTemplate, taskTemplate, toolbarTemplate, $) { ], function (todoTemplate, taskTemplate, toolbarTemplate, dialogTemplate, $) {
/** /**
* @param {mct.MCT} mct * @param {mct.MCT} mct
*/ */
@ -111,23 +112,26 @@ define([
var $els = $(toolbarTemplate); var $els = $(toolbarTemplate);
var $add = $els.find('a.example-add'); var $add = $els.find('a.example-add');
var $remove = $els.find('a.example-remove'); var $remove = $els.find('a.example-remove');
var domainObject = this.domainObject;
$(container).append($els); $(container).append($els);
$add.on('click', function () { $add.on('click', function () {
var view = { var $dialog = $(dialogTemplate),
view = {
show: function (container) { show: function (container) {
$(container).append($('<span>Dialog!</span>')); $(container).append($dialog);
}, },
destroy: function () { destroy: function () {}
}
}; };
mct.dialog(view, "Add a Task").then( mct.dialog(view, "Add a Task").then(function () {
window.alert.bind(window, 'resolve'), var description = $dialog.find('input').val();
window.alert.bind(window, 'reject') mct.verbs.mutate(domainObject, function (model) {
); model.tasks.push({ description: description });
console.log(model);
});
});
}); });
$remove.on('click', window.alert.bind(window, "Remove!")); $remove.on('click', window.alert.bind(window, "Remove!"));
}; };