Add weekday selection for weekly recurrence and fix RRULE generation
- Add weekday selection UI for weekly recurring events with checkboxes - Implement BYDAY parameter generation in RRULE based on selected days - Fix missing RRULE generation in iCalendar output - Convert reminder durations to proper EventReminder structs - Add responsive CSS styling for weekday selection interface 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -451,22 +451,83 @@ pub async fn create_event(
|
||||
.collect()
|
||||
};
|
||||
|
||||
// Parse reminders (for now, just store as a simple reminder duration)
|
||||
let reminders: Vec<chrono::Duration> = match request.reminder.to_lowercase().as_str() {
|
||||
"15min" => vec![chrono::Duration::minutes(15)],
|
||||
"30min" => vec![chrono::Duration::minutes(30)],
|
||||
"1hour" => vec![chrono::Duration::hours(1)],
|
||||
"2hours" => vec![chrono::Duration::hours(2)],
|
||||
"1day" => vec![chrono::Duration::days(1)],
|
||||
"2days" => vec![chrono::Duration::days(2)],
|
||||
"1week" => vec![chrono::Duration::weeks(1)],
|
||||
// Parse reminders and convert to EventReminder structs
|
||||
let reminders: Vec<crate::calendar::EventReminder> = match request.reminder.to_lowercase().as_str() {
|
||||
"15min" => vec![crate::calendar::EventReminder {
|
||||
minutes_before: 15,
|
||||
action: crate::calendar::ReminderAction::Display,
|
||||
description: None,
|
||||
}],
|
||||
"30min" => vec![crate::calendar::EventReminder {
|
||||
minutes_before: 30,
|
||||
action: crate::calendar::ReminderAction::Display,
|
||||
description: None,
|
||||
}],
|
||||
"1hour" => vec![crate::calendar::EventReminder {
|
||||
minutes_before: 60,
|
||||
action: crate::calendar::ReminderAction::Display,
|
||||
description: None,
|
||||
}],
|
||||
"2hours" => vec![crate::calendar::EventReminder {
|
||||
minutes_before: 120,
|
||||
action: crate::calendar::ReminderAction::Display,
|
||||
description: None,
|
||||
}],
|
||||
"1day" => vec![crate::calendar::EventReminder {
|
||||
minutes_before: 1440, // 24 * 60
|
||||
action: crate::calendar::ReminderAction::Display,
|
||||
description: None,
|
||||
}],
|
||||
"2days" => vec![crate::calendar::EventReminder {
|
||||
minutes_before: 2880, // 48 * 60
|
||||
action: crate::calendar::ReminderAction::Display,
|
||||
description: None,
|
||||
}],
|
||||
"1week" => vec![crate::calendar::EventReminder {
|
||||
minutes_before: 10080, // 7 * 24 * 60
|
||||
action: crate::calendar::ReminderAction::Display,
|
||||
description: None,
|
||||
}],
|
||||
_ => Vec::new(),
|
||||
};
|
||||
|
||||
// Parse recurrence (basic implementation)
|
||||
// Parse recurrence with BYDAY support for weekly recurrence
|
||||
let recurrence_rule = match request.recurrence.to_lowercase().as_str() {
|
||||
"daily" => Some("FREQ=DAILY".to_string()),
|
||||
"weekly" => Some("FREQ=WEEKLY".to_string()),
|
||||
"weekly" => {
|
||||
// Handle weekly recurrence with optional BYDAY parameter
|
||||
let mut rrule = "FREQ=WEEKLY".to_string();
|
||||
|
||||
// Check if specific days are selected (recurrence_days has 7 elements: [Sun, Mon, Tue, Wed, Thu, Fri, Sat])
|
||||
if request.recurrence_days.len() == 7 {
|
||||
let selected_days: Vec<&str> = request.recurrence_days
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, &selected)| {
|
||||
if selected {
|
||||
Some(match i {
|
||||
0 => "SU", // Sunday
|
||||
1 => "MO", // Monday
|
||||
2 => "TU", // Tuesday
|
||||
3 => "WE", // Wednesday
|
||||
4 => "TH", // Thursday
|
||||
5 => "FR", // Friday
|
||||
6 => "SA", // Saturday
|
||||
_ => return None,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
if !selected_days.is_empty() {
|
||||
rrule.push_str(&format!(";BYDAY={}", selected_days.join(",")));
|
||||
}
|
||||
}
|
||||
|
||||
Some(rrule)
|
||||
},
|
||||
"monthly" => Some("FREQ=MONTHLY".to_string()),
|
||||
"yearly" => Some("FREQ=YEARLY".to_string()),
|
||||
_ => None,
|
||||
|
||||
Reference in New Issue
Block a user