-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
121 additions
and
7 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use relm_attributes::widget; | ||
use widgets::tasks::Msg::{Complete, Edit}; | ||
|
||
#[derive(Msg)] | ||
pub enum Msg { | ||
Complete(::tasks::Task), | ||
Edit(::tasks::Task), | ||
Update(::tasks::List, bool, bool), | ||
} | ||
|
||
impl Widget | ||
{ | ||
fn update_tasks(&mut self, list: &::tasks::List, defered: bool, done: bool) | ||
{ | ||
let today = ::chrono::Local::now() | ||
.date() | ||
.naive_local(); | ||
|
||
let tasks = list.tasks.iter() | ||
.filter(|x| { | ||
x.flagged | ||
&& (done || !x.finished) | ||
&& (defered || x.threshold_date.is_none() || x.threshold_date.unwrap() <= today) | ||
}) | ||
.cloned() | ||
.collect(); | ||
|
||
self.tasks.emit(::widgets::tasks::Msg::Update(tasks)); | ||
} | ||
} | ||
|
||
#[widget] | ||
impl ::relm::Widget for Widget | ||
{ | ||
fn model(_: ()) -> () | ||
{ | ||
} | ||
|
||
fn update(&mut self, event: Msg) | ||
{ | ||
use self::Msg::*; | ||
|
||
match event { | ||
Complete(_) => (), | ||
Edit(_) => (), | ||
Update(list, defered, done) => self.update_tasks(&list, defered, done), | ||
} | ||
} | ||
|
||
view! | ||
{ | ||
#[name="tasks"] | ||
::widgets::Tasks { | ||
Complete(ref task) => Msg::Complete(task.clone()), | ||
Edit(ref task) => Msg::Edit(task.clone()), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ mod agenda; | |
mod application; | ||
mod done; | ||
mod edit; | ||
mod flag; | ||
mod inbox; | ||
mod logger; | ||
mod search; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters