Web Programming
Todo SPA (Editing)
The objective of this exercise is to extend the
todo single-page application so that todos can be edited.
Tasks
-
In the
main
module, extend the show
function with an optional parameter and pass it to the constructor of the component to be shown.
-
Add the following methods to the
service
module:
getTodo(user, id)
sends an AJAX request to fetch the todo with the specified identifier
putTodo(user, todo)
sends an AJAX request to update the specified todo
-
Implement the
EditTodo
component:
- The template contains a form that allows to edit the title, category and due date of a todo (the identifier must also be included in the form, but is immutable).
- The constructor fetches the todo with the identifier passed as parameter and renders its properties in the form.
- Two event handlers are registered to save the edited todo or to cancel the action.
-
In the
TodoList
component, add a link to each rendered todo that shows the EditTodo
component passing the identifier of the corresponding todo when clicked.