@@ -1,5 +1,5 @@
1//! Type definitions and `dodrio::Render` implementation for a collection of
1//! Type definitions and `dodrio::Render` implementation for a collection of
2−//! TODO items.
2+//! todo items.
4use crate::controller::Controller;
4use crate::controller::Controller;
5use crate::todo::{Todo, TodoActions};
5use crate::todo::{Todo, TodoActions};
@@ -15,7 +15,7 @@ use std::mem;
15use wasm_bindgen::prelude::*;
15use wasm_bindgen::prelude::*;
16use wasm_bindgen::JsCast;
16use wasm_bindgen::JsCast;
18−/// A collection of TODOs.
18+/// A collection of todos.
19#[derive(Default, Serialize, Deserialize)]
19#[derive(Default, Serialize, Deserialize)]
20#[serde(rename = "todos-dodrio", bound = "")]
20#[serde(rename = "todos-dodrio", bound = "")]
21pub struct Todos<C = Controller> {
21pub struct Todos<C = Controller> {
@@ -33,25 +33,25 @@ pub struct Todos<C = Controller> {
34/// Actions for `Todos` that can be triggered by UI interactions.
34/// Actions for `Todos` that can be triggered by UI interactions.
35pub trait TodosActions: TodoActions {
35pub trait TodosActions: TodoActions {
36− /// Toggle the completion state of all TODO items.
36+ /// Toggle the completion state of all todo items.
37 fn toggle_all(root: &mut dyn RootRender, vdom: VdomWeak);
37 fn toggle_all(root: &mut dyn RootRender, vdom: VdomWeak);
39− /// Update the draft TODO item's text.
39+ /// Update the draft todo item's text.
40 fn update_draft(root: &mut dyn RootRender, vdom: VdomWeak, draft: String);
40 fn update_draft(root: &mut dyn RootRender, vdom: VdomWeak, draft: String);
42− /// Finish the current draft TODO item and add it to the collection of
42+ /// Finish the current draft todo item and add it to the collection of
43− /// TODOs.
43+ /// todos.
44 fn finish_draft(root: &mut dyn RootRender, vdom: VdomWeak);
44 fn finish_draft(root: &mut dyn RootRender, vdom: VdomWeak);
46− /// Change the TODO item visibility filtering to the given `Visibility`.
46+ /// Change the todo item visibility filtering to the given `Visibility`.
47 fn change_visibility(root: &mut dyn RootRender, vdom: VdomWeak, vis: Visibility);
47 fn change_visibility(root: &mut dyn RootRender, vdom: VdomWeak, vis: Visibility);
49− /// Delete all completed TODO items.
49+ /// Delete all completed todo items.
50 fn delete_completed(root: &mut dyn RootRender, vdom: VdomWeak);
50 fn delete_completed(root: &mut dyn RootRender, vdom: VdomWeak);
53impl<C> Todos<C> {
53impl<C> Todos<C> {
54− /// Construct a new TODOs set.
54+ /// Construct a new todos set.
56 /// If an existing set is available in local storage, then us that,
56 /// If an existing set is available in local storage, then us that,
57 /// otherwise create a new set.
57 /// otherwise create a new set.
@@ -62,7 +62,7 @@ impl<C> Todos<C> {
62 Self::from_local_storage().unwrap_or_default()
62 Self::from_local_storage().unwrap_or_default()
65− /// Deserialize a set of TODOs from local storage.
65+ /// Deserialize a set of todos from local storage.
66 pub fn from_local_storage() -> Option<Self> {
66 pub fn from_local_storage() -> Option<Self> {
67 utils::local_storage()
67 utils::local_storage()
68 .get("todomvc-dodrio")
68 .get("todomvc-dodrio")
@@ -71,7 +71,7 @@ impl<C> Todos<C> {
71 .and_then(|json| serde_json::from_str(&json).ok())
71 .and_then(|json| serde_json::from_str(&json).ok())
74− /// Serialize this set of TODOs to local storage.
74+ /// Serialize this set of todos to local storage.
75 pub fn save_to_local_storage(&self) {
75 pub fn save_to_local_storage(&self) {
76 let serialized = serde_json::to_string(self).unwrap_throw();
76 let serialized = serde_json::to_string(self).unwrap_throw();
77 utils::local_storage()
77 utils::local_storage()
@@ -79,41 +79,41 @@ impl<C> Todos<C> {
79 .unwrap_throw();
79 .unwrap_throw();
82− /// Add a new TODO item to this collection.
82+ /// Add a new todo item to this collection.
83 pub fn add_todo(&mut self, todo: Todo<C>) {
83 pub fn add_todo(&mut self, todo: Todo<C>) {
84 self.todos.push(todo);
84 self.todos.push(todo);
87− /// Delete the TODO with the given id.
87+ /// Delete the todo with the given id.
88 pub fn delete_todo(&mut self, id: usize) {
88 pub fn delete_todo(&mut self, id: usize) {
89 self.todos.remove(id);
89 self.todos.remove(id);
90 self.fix_ids();
90 self.fix_ids();
93− /// Delete all completed TODO items.
93+ /// Delete all completed todo items.
94 pub fn delete_completed(&mut self) {
94 pub fn delete_completed(&mut self) {
95 self.todos.retain(|t| !t.is_complete());
95 self.todos.retain(|t| !t.is_complete());
96 self.fix_ids();
96 self.fix_ids();
99− // Fix all TODO identifiers so that they match their index once again.
99+ // Fix all todo identifiers so that they match their index once again.
100 fn fix_ids(&mut self) {
100 fn fix_ids(&mut self) {
101 for (id, todo) in self.todos.iter_mut().enumerate() {
101 for (id, todo) in self.todos.iter_mut().enumerate() {
102 todo.set_id(id);
102 todo.set_id(id);
106− /// Get a shared slice of the underlying set of TODO items.
106+ /// Get a shared slice of the underlying set of todo items.
107 pub fn todos(&self) -> &[Todo<C>] {
107 pub fn todos(&self) -> &[Todo<C>] {
108 &self.todos
108 &self.todos
111− /// Get an exclusive slice of the underlying set of TODO items.
111+ /// Get an exclusive slice of the underlying set of todo items.
112 pub fn todos_mut(&mut self) -> &mut [Todo<C>] {
112 pub fn todos_mut(&mut self) -> &mut [Todo<C>] {
113 &mut self.todos
113 &mut self.todos
116− /// Set the draft TODO item text.
116+ /// Set the draft todo item text.
117 pub fn set_draft<S: Into<String>>(&mut self, draft: S) {
117 pub fn set_draft<S: Into<String>>(&mut self, draft: S) {
118 self.draft = draft.into();
118 self.draft = draft.into();
@@ -123,12 +123,12 @@ impl<C> Todos<C> {
123 mem::replace(&mut self.draft, String::new())
123 mem::replace(&mut self.draft, String::new())
126− /// Get the current visibility for these TODOs.
126+ /// Get the current visibility for these todos.
127 pub fn visibility(&self) -> Visibility {
127 pub fn visibility(&self) -> Visibility {
128 self.visibility
128 self.visibility
131− /// Set the visibility for these TODOS.
131+ /// Set the visibility for these todoS.
132 pub fn set_visibility(&mut self, vis: Visibility) {
132 pub fn set_visibility(&mut self, vis: Visibility) {
133 self.visibility = vis;
133 self.visibility = vis;