mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
[API] Allow tasks to be added
This commit is contained in:
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.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!"));
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user