[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 (
legacyRegistry,
TodoController
) {
) {
legacyRegistry.register("tutorials/todo", {
"name": "To-do Plugin",
"description": "Allows creating and editing to-do lists.",
"extensions": {
"xviews": [
"stylesheets": [
{
"key": "example.todo",
"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"
}
]
}
]
}
"stylesheetUrl": "css/todo.css"
}
],
"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."
},
initialize: function (model) {
model.tasks = [];
model.tasks = [
{ description: "This is a task." }
];
},
creatable: true
});
@ -45,7 +47,7 @@ define([
var $els = $(elements);
var tasks = domainObject.getModel().tasks;
var $message = $els.find('.example-message');
var $list = $els.find('example-todo-task-list');
var $list = $els.find('.example-todo-task-list');
var $buttons = {
all: $els.find('.example-todo-button-all'),
incomplete: $els.find('.example-todo-button-incomplete'),
@ -66,7 +68,6 @@ define([
Object.keys($buttons).forEach(function (k) {
$buttons[k].toggleClass('selected', state.filter === k);
});
tasks = tasks.filter(filters[state.filter]);
$list.empty();
@ -76,6 +77,7 @@ define([
.prop('checked', task.completed);
$taskEls.find('.example-task-description')
.text(task.description);
$list.append($taskEls);
});
$message.toggle(tasks.length < 1);