mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
[API] Allow tasks to be added
This commit is contained in:
parent
dbe6a4efc1
commit
4a50f325cb
3
tutorials/todo/todo-dialog.html
Normal file
3
tutorials/todo/todo-dialog.html
Normal file
@ -0,0 +1,3 @@
|
||||
<label>Description:
|
||||
<input type="text" class="description">
|
||||
</label>
|
@ -2,8 +2,9 @@ define([
|
||||
"text!./todo.html",
|
||||
"text!./todo-task.html",
|
||||
"text!./todo-toolbar.html",
|
||||
"text!./todo-dialog.html",
|
||||
"zepto"
|
||||
], function (todoTemplate, taskTemplate, toolbarTemplate, $) {
|
||||
], function (todoTemplate, taskTemplate, toolbarTemplate, dialogTemplate, $) {
|
||||
/**
|
||||
* @param {mct.MCT} mct
|
||||
*/
|
||||
@ -111,23 +112,26 @@ define([
|
||||
var $els = $(toolbarTemplate);
|
||||
var $add = $els.find('a.example-add');
|
||||
var $remove = $els.find('a.example-remove');
|
||||
var domainObject = this.domainObject;
|
||||
|
||||
$(container).append($els);
|
||||
|
||||
$add.on('click', function () {
|
||||
var view = {
|
||||
show: function (container) {
|
||||
$(container).append($('<span>Dialog!</span>'));
|
||||
},
|
||||
destroy: function () {
|
||||
var $dialog = $(dialogTemplate),
|
||||
view = {
|
||||
show: function (container) {
|
||||
$(container).append($dialog);
|
||||
},
|
||||
destroy: function () {}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
mct.dialog(view, "Add a Task").then(
|
||||
window.alert.bind(window, 'resolve'),
|
||||
window.alert.bind(window, 'reject')
|
||||
);
|
||||
mct.dialog(view, "Add a Task").then(function () {
|
||||
var description = $dialog.find('input').val();
|
||||
mct.verbs.mutate(domainObject, function (model) {
|
||||
model.tasks.push({ description: description });
|
||||
console.log(model);
|
||||
});
|
||||
});
|
||||
});
|
||||
$remove.on('click', window.alert.bind(window, "Remove!"));
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user