[API] Show tasks from todo

This commit is contained in:
Victor Woeltjen 2016-05-27 16:46:06 -07:00
parent 03cb0ccb57
commit a79e958ffc
2 changed files with 11 additions and 49 deletions

View File

@ -4,56 +4,16 @@ define([
], function ( ], function (
legacyRegistry, legacyRegistry,
TodoController TodoController
) { ) {
legacyRegistry.register("tutorials/todo", { legacyRegistry.register("tutorials/todo", {
"name": "To-do Plugin", "name": "To-do Plugin",
"description": "Allows creating and editing to-do lists.", "description": "Allows creating and editing to-do lists.",
"extensions": { "extensions": {
"xviews": [ "stylesheets": [
{ {
"key": "example.todo", "stylesheetUrl": "css/todo.css"
"type": "example.todo",
"glyph": "2",
"name": "List",
"templateUrl": "templates/todo.html",
"editable": true,
"toolbar": {
"sections": [
{
"items": [
{
"text": "Add Task",
"glyph": "+",
"method": "addTask",
"control": "button"
}
]
},
{
"items": [
{
"glyph": "Z",
"method": "removeTask",
"control": "button"
}
]
}
]
}
} }
], ]
"controllers": [ }
{ });
"key": "TodoController",
"implementation": TodoController,
"depends": [ "$scope", "dialogService" ]
}
],
"stylesheets": [
{
"stylesheetUrl": "css/todo.css"
}
]
}
});
}); });

View File

@ -14,7 +14,9 @@ define([
description: "A list of things that need to be done." description: "A list of things that need to be done."
}, },
initialize: function (model) { initialize: function (model) {
model.tasks = []; model.tasks = [
{ description: "This is a task." }
];
}, },
creatable: true creatable: true
}); });
@ -45,7 +47,7 @@ define([
var $els = $(elements); var $els = $(elements);
var tasks = domainObject.getModel().tasks; var tasks = domainObject.getModel().tasks;
var $message = $els.find('.example-message'); var $message = $els.find('.example-message');
var $list = $els.find('example-todo-task-list'); var $list = $els.find('.example-todo-task-list');
var $buttons = { var $buttons = {
all: $els.find('.example-todo-button-all'), all: $els.find('.example-todo-button-all'),
incomplete: $els.find('.example-todo-button-incomplete'), incomplete: $els.find('.example-todo-button-incomplete'),
@ -66,7 +68,6 @@ define([
Object.keys($buttons).forEach(function (k) { Object.keys($buttons).forEach(function (k) {
$buttons[k].toggleClass('selected', state.filter === k); $buttons[k].toggleClass('selected', state.filter === k);
}); });
tasks = tasks.filter(filters[state.filter]); tasks = tasks.filter(filters[state.filter]);
$list.empty(); $list.empty();
@ -76,6 +77,7 @@ define([
.prop('checked', task.completed); .prop('checked', task.completed);
$taskEls.find('.example-task-description') $taskEls.find('.example-task-description')
.text(task.description); .text(task.description);
$list.append($taskEls);
}); });
$message.toggle(tasks.length < 1); $message.toggle(tasks.length < 1);