diff options
author | Joris | 2022-02-26 18:35:24 +0100 |
---|---|---|
committer | Joris | 2022-02-26 18:35:24 +0100 |
commit | 2d80413609130f1c121dcae39a150a27dd9f02ea (patch) | |
tree | a8c807b7e95d5049ea43a1757d292b5cb745524b /src/app/form | |
parent | 1445e23a26c6581ad0c3f5b5016e47e95d224e9f (diff) |
Show repeated events
Diffstat (limited to 'src/app/form')
-rw-r--r-- | src/app/form/mod.rs | 4 | ||||
-rw-r--r-- | src/app/form/repetition.rs | 34 |
2 files changed, 19 insertions, 19 deletions
diff --git a/src/app/form/mod.rs b/src/app/form/mod.rs index 5c60bc5..9cb6ba7 100644 --- a/src/app/form/mod.rs +++ b/src/app/form/mod.rs @@ -85,10 +85,10 @@ pub async fn show(app: &App, event: Event, is_new: bool) { update::send(tx.clone(), msg); dialog.close() }, - Err(err) => println!("Error when upserting event: {err}") + Err(err) => eprintln!("Error when upserting event: {err}") } }, - None => println!("Event is not valid: {event:?}") + None => eprintln!("Event is not valid: {event:?}") } })); diff --git a/src/app/form/repetition.rs b/src/app/form/repetition.rs index ac56479..87c8d84 100644 --- a/src/app/form/repetition.rs +++ b/src/app/form/repetition.rs @@ -7,7 +7,7 @@ use crate::{ model::event::Event, model::{ repetition, - repetition::{MonthFrequency, Repetition}, + repetition::{DayOfMonth, Repetition}, }, }; @@ -19,14 +19,14 @@ static WEEKDAYS: [Weekday; 7] = [Mon, Tue, Wed, Thu, Fri, Sat, Sun]; pub struct Model { pub view: gtk::Box, - pub no_radio: gtk::CheckButton, - pub day_interval_radio: gtk::CheckButton, - pub day_interval_entry: gtk::Entry, - pub monthly_radio: gtk::CheckButton, - pub monthly_entry: gtk::Entry, - pub first_day_radio: gtk::CheckButton, - pub first_day_dropdown: gtk::DropDown, - pub yearly_radio: gtk::CheckButton, + no_radio: gtk::CheckButton, + day_interval_radio: gtk::CheckButton, + day_interval_entry: gtk::Entry, + monthly_radio: gtk::CheckButton, + monthly_entry: gtk::Entry, + first_day_radio: gtk::CheckButton, + first_day_dropdown: gtk::DropDown, + yearly_radio: gtk::CheckButton, } pub fn view(event: &Event) -> Model { @@ -44,7 +44,7 @@ pub fn view(event: &Event) -> Model { view.append(&no_radio); let default = match event.repetition { - Some(Repetition::Daily { frequency }) => frequency.to_string(), + Some(Repetition::Daily { period }) => period.to_string(), _ => "".to_string(), }; let day_interval_entry = gtk::Entry::builder().text(&default).build(); @@ -58,7 +58,7 @@ pub fn view(event: &Event) -> Model { let default = match event.repetition { Some(Repetition::Monthly { - frequency: MonthFrequency::Day { day }, + day: DayOfMonth::Day { day }, }) => day.to_string(), _ => "".to_string(), }; @@ -69,8 +69,8 @@ pub fn view(event: &Event) -> Model { let (active, default) = match event.repetition { Some(Repetition::Monthly { - frequency: MonthFrequency::FirstDay { day }, - }) => (true, day), + day: DayOfMonth::Weekday { weekday }, + }) => (true, weekday), _ => (false, Mon), }; let first_day_dropdown = gtk::DropDown::from_strings(&WEEKDAYS_STR); @@ -131,17 +131,17 @@ pub fn validate(model: &Model) -> Option<Repetition> { None } else if model.day_interval_radio.is_active() { repetition::validate_day(&model.day_interval_entry.buffer().text()) - .map(|d| Repetition::Daily { frequency: d }) + .map(|d| Repetition::Daily { period: d }) } else if model.monthly_radio.is_active() { repetition::validate_day(&model.monthly_entry.buffer().text()).map(|d| { Repetition::Monthly { - frequency: MonthFrequency::Day { day: d }, + day: DayOfMonth::Day { day: d }, } }) } else if model.first_day_radio.is_active() { - let day = WEEKDAYS[model.first_day_dropdown.selected() as usize]; + let weekday = WEEKDAYS[model.first_day_dropdown.selected() as usize]; Some(Repetition::Monthly { - frequency: MonthFrequency::FirstDay { day }, + day: DayOfMonth::Weekday { weekday }, }) } else if model.yearly_radio.is_active() { Some(Repetition::Yearly) |