Compare commits
9 Commits
a9521ad536
...
419cb3d790
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
419cb3d790 | ||
|
|
53a62fb05e | ||
|
|
322c88612a | ||
|
|
4aa53d79e7 | ||
|
|
3464754489 | ||
|
|
e56253b9c2 | ||
|
|
cb8cc7258c | ||
|
|
b576cd8c4a | ||
|
|
a773159016 |
@@ -5,6 +5,10 @@
|
||||
}
|
||||
|
||||
:80, :443 {
|
||||
@backend {
|
||||
path /api /api/*
|
||||
}
|
||||
reverse_proxy @backend calendar-backend:3000
|
||||
try_files {path} /index.html
|
||||
root * /srv/www
|
||||
file_server
|
||||
|
||||
@@ -361,11 +361,10 @@ impl CalDAVClient {
|
||||
None
|
||||
};
|
||||
|
||||
// Determine if it's an all-day event
|
||||
let all_day = properties
|
||||
.get("DTSTART")
|
||||
.map(|s| !s.contains("T"))
|
||||
.unwrap_or(false);
|
||||
// Determine if it's an all-day event by checking for VALUE=DATE parameter
|
||||
let empty_string = String::new();
|
||||
let dtstart_raw = properties.get("DTSTART").unwrap_or(&empty_string);
|
||||
let all_day = dtstart_raw.contains("VALUE=DATE") || (!dtstart_raw.contains("T") && dtstart_raw.len() == 8);
|
||||
|
||||
// Parse status
|
||||
let status = properties
|
||||
|
||||
@@ -76,10 +76,54 @@ pub async fn get_calendar_events(
|
||||
|
||||
// If year and month are specified, filter events
|
||||
if let (Some(year), Some(month)) = (params.year, params.month) {
|
||||
let target_date = chrono::NaiveDate::from_ymd_opt(year, month, 1).unwrap();
|
||||
let month_start = target_date;
|
||||
let month_end = if month == 12 {
|
||||
chrono::NaiveDate::from_ymd_opt(year + 1, 1, 1).unwrap()
|
||||
} else {
|
||||
chrono::NaiveDate::from_ymd_opt(year, month + 1, 1).unwrap()
|
||||
} - chrono::Duration::days(1);
|
||||
|
||||
all_events.retain(|event| {
|
||||
let event_year = event.dtstart.year();
|
||||
let event_month = event.dtstart.month();
|
||||
event_year == year && event_month == month
|
||||
let event_date = event.dtstart.date_naive();
|
||||
|
||||
// For non-recurring events, check if the event date is within the month
|
||||
if event.rrule.is_none() || event.rrule.as_ref().unwrap().is_empty() {
|
||||
let event_year = event.dtstart.year();
|
||||
let event_month = event.dtstart.month();
|
||||
return event_year == year && event_month == month;
|
||||
}
|
||||
|
||||
// For recurring events, check if they could have instances in this month
|
||||
// Include if:
|
||||
// 1. The event starts before or during the requested month
|
||||
// 2. The event doesn't have an UNTIL date, OR the UNTIL date is after the month start
|
||||
if event_date > month_end {
|
||||
// Event starts after the requested month
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check UNTIL date in RRULE if present
|
||||
if let Some(ref rrule) = event.rrule {
|
||||
if let Some(until_pos) = rrule.find("UNTIL=") {
|
||||
let until_part = &rrule[until_pos + 6..];
|
||||
let until_end = until_part.find(';').unwrap_or(until_part.len());
|
||||
let until_str = &until_part[..until_end];
|
||||
|
||||
// Try to parse UNTIL date (format: YYYYMMDDTHHMMSSZ or YYYYMMDD)
|
||||
if until_str.len() >= 8 {
|
||||
if let Ok(until_date) = chrono::NaiveDate::parse_from_str(&until_str[..8], "%Y%m%d") {
|
||||
if until_date < month_start {
|
||||
// Recurring event ended before the requested month
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include the recurring event - the frontend will do proper expansion
|
||||
true
|
||||
});
|
||||
}
|
||||
|
||||
@@ -414,9 +458,15 @@ pub async fn create_event(
|
||||
parse_event_datetime(&request.start_date, &request.start_time, request.all_day)
|
||||
.map_err(|e| ApiError::BadRequest(format!("Invalid start date/time: {}", e)))?;
|
||||
|
||||
let end_datetime = parse_event_datetime(&request.end_date, &request.end_time, request.all_day)
|
||||
let mut end_datetime = parse_event_datetime(&request.end_date, &request.end_time, request.all_day)
|
||||
.map_err(|e| ApiError::BadRequest(format!("Invalid end date/time: {}", e)))?;
|
||||
|
||||
// For all-day events, add one day to end date for RFC-5545 compliance
|
||||
// RFC-5545 uses exclusive end dates for all-day events
|
||||
if request.all_day {
|
||||
end_datetime = end_datetime + chrono::Duration::days(1);
|
||||
}
|
||||
|
||||
// Validate that end is after start (allow equal times for all-day events)
|
||||
if request.all_day {
|
||||
if end_datetime < start_datetime {
|
||||
@@ -712,9 +762,15 @@ pub async fn update_event(
|
||||
parse_event_datetime(&request.start_date, &request.start_time, request.all_day)
|
||||
.map_err(|e| ApiError::BadRequest(format!("Invalid start date/time: {}", e)))?;
|
||||
|
||||
let end_datetime = parse_event_datetime(&request.end_date, &request.end_time, request.all_day)
|
||||
let mut end_datetime = parse_event_datetime(&request.end_date, &request.end_time, request.all_day)
|
||||
.map_err(|e| ApiError::BadRequest(format!("Invalid end date/time: {}", e)))?;
|
||||
|
||||
// For all-day events, add one day to end date for RFC-5545 compliance
|
||||
// RFC-5545 uses exclusive end dates for all-day events
|
||||
if request.all_day {
|
||||
end_datetime = end_datetime + chrono::Duration::days(1);
|
||||
}
|
||||
|
||||
// Validate that end is after start (allow equal times for all-day events)
|
||||
if request.all_day {
|
||||
if end_datetime < start_datetime {
|
||||
|
||||
@@ -175,6 +175,7 @@ pub async fn create_event_series(
|
||||
// Create the VEvent for the series
|
||||
let mut event = VEvent::new(uid.clone(), start_datetime);
|
||||
event.dtend = Some(end_datetime);
|
||||
event.all_day = request.all_day; // Set the all_day flag properly
|
||||
event.summary = if request.title.trim().is_empty() {
|
||||
None
|
||||
} else {
|
||||
|
||||
BIN
calendar.db
BIN
calendar.db
Binary file not shown.
BIN
favicon_big.png
Normal file
BIN
favicon_big.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 952 KiB |
BIN
frontend/favicon.ico
Normal file
BIN
frontend/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
@@ -7,6 +7,7 @@
|
||||
<base data-trunk-public-url />
|
||||
<link data-trunk rel="css" href="styles.css">
|
||||
<link data-trunk rel="copy-file" href="styles/google.css">
|
||||
<link data-trunk rel="icon" href="favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::components::{
|
||||
CalendarContextMenu, ContextMenu, CreateCalendarModal, CreateEventModal, DeleteAction,
|
||||
CalendarContextMenu, ContextMenu, CreateCalendarModal, CreateEventModalV2, DeleteAction,
|
||||
EditAction, EventClass, EventContextMenu, EventCreationData, EventStatus, RecurrenceType,
|
||||
ReminderType, RouteHandler, Sidebar, Theme, ViewMode,
|
||||
};
|
||||
@@ -1031,9 +1031,11 @@ pub fn App() -> Html {
|
||||
on_create_event={on_create_event_click}
|
||||
/>
|
||||
|
||||
<CreateEventModal
|
||||
<CreateEventModalV2
|
||||
is_open={*create_event_modal_open}
|
||||
selected_date={(*selected_date_for_event).clone()}
|
||||
initial_start_time={None}
|
||||
initial_end_time={None}
|
||||
event_to_edit={(*event_context_menu_event).clone()}
|
||||
edit_scope={(*event_edit_scope).clone()}
|
||||
on_close={Callback::from({
|
||||
@@ -1048,242 +1050,6 @@ pub fn App() -> Html {
|
||||
}
|
||||
})}
|
||||
on_create={on_event_create}
|
||||
on_update={Callback::from({
|
||||
let auth_token = auth_token.clone();
|
||||
let create_event_modal_open = create_event_modal_open.clone();
|
||||
let event_context_menu_event = event_context_menu_event.clone();
|
||||
let event_edit_scope = event_edit_scope.clone();
|
||||
move |(original_event, updated_data): (VEvent, EventCreationData)| {
|
||||
web_sys::console::log_1(&format!("Updating event: {:?}, edit_scope: {:?}", updated_data, updated_data.edit_scope).into());
|
||||
create_event_modal_open.set(false);
|
||||
event_context_menu_event.set(None);
|
||||
event_edit_scope.set(None);
|
||||
|
||||
if let Some(token) = (*auth_token).clone() {
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
let calendar_service = CalendarService::new();
|
||||
|
||||
// Get CalDAV password from storage
|
||||
let password = if let Ok(credentials_str) = LocalStorage::get::<String>("caldav_credentials") {
|
||||
if let Ok(credentials) = serde_json::from_str::<serde_json::Value>(&credentials_str) {
|
||||
credentials["password"].as_str().unwrap_or("").to_string()
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
||||
// Convert local times to UTC for backend storage
|
||||
let start_local = updated_data.start_date.and_time(updated_data.start_time);
|
||||
let end_local = updated_data.end_date.and_time(updated_data.end_time);
|
||||
|
||||
let start_utc = start_local.and_local_timezone(chrono::Local).unwrap().to_utc();
|
||||
let end_utc = end_local.and_local_timezone(chrono::Local).unwrap().to_utc();
|
||||
|
||||
// Format UTC date and time strings for backend
|
||||
let start_date = start_utc.format("%Y-%m-%d").to_string();
|
||||
let start_time = start_utc.format("%H:%M").to_string();
|
||||
let end_date = end_utc.format("%Y-%m-%d").to_string();
|
||||
let end_time = end_utc.format("%H:%M").to_string();
|
||||
|
||||
// Convert enums to strings for backend
|
||||
let status_str = match updated_data.status {
|
||||
EventStatus::Tentative => "tentative",
|
||||
EventStatus::Cancelled => "cancelled",
|
||||
_ => "confirmed",
|
||||
}.to_string();
|
||||
|
||||
let class_str = match updated_data.class {
|
||||
EventClass::Private => "private",
|
||||
EventClass::Confidential => "confidential",
|
||||
_ => "public",
|
||||
}.to_string();
|
||||
|
||||
let reminder_str = match updated_data.reminder {
|
||||
ReminderType::Minutes15 => "15min",
|
||||
ReminderType::Minutes30 => "30min",
|
||||
ReminderType::Hour1 => "1hour",
|
||||
ReminderType::Hours2 => "2hours",
|
||||
ReminderType::Day1 => "1day",
|
||||
ReminderType::Days2 => "2days",
|
||||
ReminderType::Week1 => "1week",
|
||||
_ => "none",
|
||||
}.to_string();
|
||||
|
||||
let recurrence_str = match updated_data.recurrence {
|
||||
RecurrenceType::Daily => "daily",
|
||||
RecurrenceType::Weekly => "weekly",
|
||||
RecurrenceType::Monthly => "monthly",
|
||||
RecurrenceType::Yearly => "yearly",
|
||||
_ => "none",
|
||||
}.to_string();
|
||||
|
||||
// Check if the calendar has changed
|
||||
let calendar_changed = original_event.calendar_path.as_ref() != updated_data.selected_calendar.as_ref();
|
||||
|
||||
if calendar_changed {
|
||||
// Calendar changed - need to delete from original and create in new
|
||||
web_sys::console::log_1(&"Calendar changed - performing delete + create".into());
|
||||
|
||||
// First delete from original calendar
|
||||
if let Some(original_calendar_path) = &original_event.calendar_path {
|
||||
if let Some(event_href) = &original_event.href {
|
||||
match calendar_service.delete_event(
|
||||
&token,
|
||||
&password,
|
||||
original_calendar_path.clone(),
|
||||
event_href.clone(),
|
||||
"single".to_string(), // delete single occurrence
|
||||
None
|
||||
).await {
|
||||
Ok(_) => {
|
||||
web_sys::console::log_1(&"Original event deleted successfully".into());
|
||||
|
||||
// Now create the event in the new calendar
|
||||
match calendar_service.create_event(
|
||||
&token,
|
||||
&password,
|
||||
updated_data.title,
|
||||
updated_data.description,
|
||||
start_date,
|
||||
start_time,
|
||||
end_date,
|
||||
end_time,
|
||||
updated_data.location,
|
||||
updated_data.all_day,
|
||||
status_str,
|
||||
class_str,
|
||||
updated_data.priority,
|
||||
updated_data.organizer,
|
||||
updated_data.attendees,
|
||||
updated_data.categories,
|
||||
reminder_str,
|
||||
recurrence_str,
|
||||
updated_data.recurrence_days,
|
||||
updated_data.selected_calendar
|
||||
).await {
|
||||
Ok(_) => {
|
||||
web_sys::console::log_1(&"Event moved to new calendar successfully".into());
|
||||
// Trigger a page reload to refresh events from all calendars
|
||||
web_sys::window().unwrap().location().reload().unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
web_sys::console::error_1(&format!("Failed to create event in new calendar: {}", err).into());
|
||||
web_sys::window().unwrap().alert_with_message(&format!("Failed to move event to new calendar: {}", err)).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
web_sys::console::error_1(&format!("Failed to delete original event: {}", err).into());
|
||||
web_sys::window().unwrap().alert_with_message(&format!("Failed to delete original event: {}", err)).unwrap();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
web_sys::console::error_1(&"Original event missing href for deletion".into());
|
||||
web_sys::window().unwrap().alert_with_message("Cannot move event - original event missing href").unwrap();
|
||||
}
|
||||
} else {
|
||||
web_sys::console::error_1(&"Original event missing calendar_path for deletion".into());
|
||||
web_sys::window().unwrap().alert_with_message("Cannot move event - original event missing calendar path").unwrap();
|
||||
}
|
||||
} else {
|
||||
// Calendar hasn't changed - check if we should use series endpoint
|
||||
let use_series_endpoint = updated_data.edit_scope.is_some() && original_event.rrule.is_some();
|
||||
|
||||
if use_series_endpoint {
|
||||
// Use series endpoint for recurring event modal edits
|
||||
let update_scope = match updated_data.edit_scope.as_ref().unwrap() {
|
||||
EditAction::EditThis => "this_only",
|
||||
EditAction::EditFuture => "this_and_future",
|
||||
EditAction::EditAll => "all_in_series",
|
||||
};
|
||||
|
||||
// For single occurrence edits, we need the occurrence date
|
||||
let occurrence_date = if update_scope == "this_only" || update_scope == "this_and_future" {
|
||||
// Use the original event's start date as the occurrence date
|
||||
Some(original_event.dtstart.format("%Y-%m-%d").to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
match calendar_service.update_series(
|
||||
&token,
|
||||
&password,
|
||||
original_event.uid,
|
||||
updated_data.title,
|
||||
updated_data.description,
|
||||
start_date,
|
||||
start_time,
|
||||
end_date,
|
||||
end_time,
|
||||
updated_data.location,
|
||||
updated_data.all_day,
|
||||
status_str,
|
||||
class_str,
|
||||
updated_data.priority,
|
||||
updated_data.organizer,
|
||||
updated_data.attendees,
|
||||
updated_data.categories,
|
||||
reminder_str,
|
||||
recurrence_str,
|
||||
updated_data.selected_calendar,
|
||||
update_scope.to_string(),
|
||||
occurrence_date,
|
||||
).await {
|
||||
Ok(_) => {
|
||||
web_sys::console::log_1(&"Series updated successfully".into());
|
||||
web_sys::window().unwrap().location().reload().unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
web_sys::console::error_1(&format!("Failed to update series: {}", err).into());
|
||||
web_sys::window().unwrap().alert_with_message(&format!("Failed to update series: {}", err)).unwrap();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Use regular event endpoint for non-recurring events or legacy updates
|
||||
match calendar_service.update_event(
|
||||
&token,
|
||||
&password,
|
||||
original_event.uid,
|
||||
updated_data.title,
|
||||
updated_data.description,
|
||||
start_date,
|
||||
start_time,
|
||||
end_date,
|
||||
end_time,
|
||||
updated_data.location,
|
||||
updated_data.all_day,
|
||||
status_str,
|
||||
class_str,
|
||||
updated_data.priority,
|
||||
updated_data.organizer,
|
||||
updated_data.attendees,
|
||||
updated_data.categories,
|
||||
reminder_str,
|
||||
recurrence_str,
|
||||
updated_data.recurrence_days,
|
||||
updated_data.selected_calendar,
|
||||
original_event.exdate.clone(),
|
||||
Some("update_series".to_string()), // This is for event edit modal, preserve original RRULE
|
||||
None // No until_date for edit modal
|
||||
).await {
|
||||
Ok(_) => {
|
||||
web_sys::console::log_1(&"Event updated successfully".into());
|
||||
// Trigger a page reload to refresh events from all calendars
|
||||
web_sys::window().unwrap().location().reload().unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
web_sys::console::error_1(&format!("Failed to update event: {}", err).into());
|
||||
web_sys::window().unwrap().alert_with_message(&format!("Failed to update event: {}", err)).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})}
|
||||
available_calendars={user_info.as_ref().map(|ui| ui.calendars.clone()).unwrap_or_default()}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::components::{
|
||||
CalendarHeader, CreateEventModal, EventCreationData, EventModal, MonthView, ViewMode, WeekView,
|
||||
CalendarHeader, CreateEventModalV2, EventCreationData, EventModal, MonthView, ViewMode, WeekView,
|
||||
};
|
||||
use crate::models::ical::VEvent;
|
||||
use crate::services::{calendar_service::UserInfo, CalendarService};
|
||||
@@ -492,7 +492,7 @@ pub fn Calendar(props: &CalendarProps) -> Html {
|
||||
/>
|
||||
|
||||
// Create event modal
|
||||
<CreateEventModal
|
||||
<CreateEventModalV2
|
||||
is_open={*show_create_modal}
|
||||
selected_date={create_event_data.as_ref().map(|(date, _, _)| *date)}
|
||||
event_to_edit={None}
|
||||
@@ -521,15 +521,6 @@ pub fn Calendar(props: &CalendarProps) -> Html {
|
||||
}
|
||||
})
|
||||
}}
|
||||
on_update={{
|
||||
let show_create_modal = show_create_modal.clone();
|
||||
let create_event_data = create_event_data.clone();
|
||||
Callback::from(move |(_original_event, _updated_data): (VEvent, EventCreationData)| {
|
||||
show_create_modal.set(false);
|
||||
create_event_data.set(None);
|
||||
// TODO: Handle actual event update
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -18,9 +18,45 @@ pub fn calendar_context_menu(props: &CalendarContextMenuProps) -> Html {
|
||||
return html! {};
|
||||
}
|
||||
|
||||
// Smart positioning to keep menu within viewport
|
||||
let (x, y) = {
|
||||
let mut x = props.x;
|
||||
let mut y = props.y;
|
||||
|
||||
// Try to get actual viewport dimensions
|
||||
if let Some(window) = web_sys::window() {
|
||||
if let (Ok(width), Ok(height)) = (window.inner_width(), window.inner_height()) {
|
||||
if let (Some(w), Some(h)) = (width.as_f64(), height.as_f64()) {
|
||||
let viewport_width = w as i32;
|
||||
let viewport_height = h as i32;
|
||||
|
||||
// Calendar context menu: "Create Event" with icon
|
||||
let menu_width = 180; // "Create Event" text + icon + padding
|
||||
let menu_height = 60; // Single item + padding + margins
|
||||
|
||||
// Adjust horizontally if too close to right edge
|
||||
if x + menu_width > viewport_width - 10 {
|
||||
x = x.saturating_sub(menu_width);
|
||||
}
|
||||
|
||||
// Adjust vertically if too close to bottom edge
|
||||
if y + menu_height > viewport_height - 10 {
|
||||
y = y.saturating_sub(menu_height);
|
||||
}
|
||||
|
||||
// Ensure minimum margins from edges
|
||||
x = x.max(5);
|
||||
y = y.max(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(x, y)
|
||||
};
|
||||
|
||||
let style = format!(
|
||||
"position: fixed; left: {}px; top: {}px; z-index: 1001;",
|
||||
props.x, props.y
|
||||
x, y
|
||||
);
|
||||
|
||||
let on_create_event_click = {
|
||||
|
||||
@@ -20,9 +20,45 @@ pub fn context_menu(props: &ContextMenuProps) -> Html {
|
||||
return html! {};
|
||||
}
|
||||
|
||||
// Smart positioning to keep menu within viewport
|
||||
let (x, y) = {
|
||||
let mut x = props.x;
|
||||
let mut y = props.y;
|
||||
|
||||
// Try to get actual viewport dimensions
|
||||
if let Some(window) = web_sys::window() {
|
||||
if let (Ok(width), Ok(height)) = (window.inner_width(), window.inner_height()) {
|
||||
if let (Some(w), Some(h)) = (width.as_f64(), height.as_f64()) {
|
||||
let viewport_width = w as i32;
|
||||
let viewport_height = h as i32;
|
||||
|
||||
// Generic context menu: "Delete Calendar"
|
||||
let menu_width = 180; // "Delete Calendar" text + padding
|
||||
let menu_height = 60; // Single item + padding + margins
|
||||
|
||||
// Adjust horizontally if too close to right edge
|
||||
if x + menu_width > viewport_width - 10 {
|
||||
x = x.saturating_sub(menu_width);
|
||||
}
|
||||
|
||||
// Adjust vertically if too close to bottom edge
|
||||
if y + menu_height > viewport_height - 10 {
|
||||
y = y.saturating_sub(menu_height);
|
||||
}
|
||||
|
||||
// Ensure minimum margins from edges
|
||||
x = x.max(5);
|
||||
y = y.max(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(x, y)
|
||||
};
|
||||
|
||||
let style = format!(
|
||||
"position: fixed; left: {}px; top: {}px; z-index: 1001;",
|
||||
props.x, props.y
|
||||
x, y
|
||||
);
|
||||
|
||||
let on_delete_click = {
|
||||
|
||||
210
frontend/src/components/create_event_modal_v2.rs
Normal file
210
frontend/src/components/create_event_modal_v2.rs
Normal file
@@ -0,0 +1,210 @@
|
||||
use crate::components::event_form::*;
|
||||
use crate::components::create_event_modal::{EventCreationData}; // Use the existing types
|
||||
use crate::components::{EditAction};
|
||||
use crate::models::ical::VEvent;
|
||||
use crate::services::calendar_service::CalendarInfo;
|
||||
use yew::prelude::*;
|
||||
|
||||
#[derive(Properties, PartialEq)]
|
||||
pub struct CreateEventModalProps {
|
||||
pub is_open: bool,
|
||||
pub on_close: Callback<()>,
|
||||
pub on_create: Callback<EventCreationData>,
|
||||
pub available_calendars: Vec<CalendarInfo>,
|
||||
pub selected_date: Option<chrono::NaiveDate>,
|
||||
pub initial_start_time: Option<chrono::NaiveTime>,
|
||||
pub initial_end_time: Option<chrono::NaiveTime>,
|
||||
#[prop_or_default]
|
||||
pub event_to_edit: Option<VEvent>,
|
||||
#[prop_or_default]
|
||||
pub edit_scope: Option<EditAction>,
|
||||
}
|
||||
|
||||
#[function_component(CreateEventModalV2)]
|
||||
pub fn create_event_modal_v2(props: &CreateEventModalProps) -> Html {
|
||||
let active_tab = use_state(|| ModalTab::default());
|
||||
let event_data = use_state(|| EventCreationData::default());
|
||||
|
||||
// Initialize data when modal opens
|
||||
{
|
||||
let event_data = event_data.clone();
|
||||
let is_open = props.is_open;
|
||||
let event_to_edit = props.event_to_edit.clone();
|
||||
let selected_date = props.selected_date;
|
||||
let initial_start_time = props.initial_start_time;
|
||||
let initial_end_time = props.initial_end_time;
|
||||
let edit_scope = props.edit_scope.clone();
|
||||
let available_calendars = props.available_calendars.clone();
|
||||
|
||||
use_effect_with(is_open, move |&is_open| {
|
||||
if is_open {
|
||||
let mut data = if let Some(_event) = &event_to_edit {
|
||||
// TODO: Convert VEvent to EventCreationData
|
||||
EventCreationData::default()
|
||||
} else if let Some(date) = selected_date {
|
||||
let mut data = EventCreationData::default();
|
||||
data.start_date = date;
|
||||
data.end_date = date;
|
||||
if let Some(start_time) = initial_start_time {
|
||||
data.start_time = start_time;
|
||||
}
|
||||
if let Some(end_time) = initial_end_time {
|
||||
data.end_time = end_time;
|
||||
}
|
||||
data
|
||||
} else {
|
||||
EventCreationData::default()
|
||||
};
|
||||
|
||||
// Set default calendar
|
||||
if data.selected_calendar.is_none() && !available_calendars.is_empty() {
|
||||
data.selected_calendar = Some(available_calendars[0].path.clone());
|
||||
}
|
||||
|
||||
// Set edit scope if provided
|
||||
if let Some(scope) = &edit_scope {
|
||||
data.edit_scope = Some(scope.clone());
|
||||
}
|
||||
|
||||
event_data.set(data);
|
||||
}
|
||||
|| ()
|
||||
});
|
||||
}
|
||||
|
||||
if !props.is_open {
|
||||
return html! {};
|
||||
}
|
||||
|
||||
let on_backdrop_click = {
|
||||
let on_close = props.on_close.clone();
|
||||
Callback::from(move |e: MouseEvent| {
|
||||
if e.target() == e.current_target() {
|
||||
on_close.emit(());
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let switch_to_tab = {
|
||||
let active_tab = active_tab.clone();
|
||||
Callback::from(move |tab: ModalTab| {
|
||||
active_tab.set(tab);
|
||||
})
|
||||
};
|
||||
|
||||
let on_save = {
|
||||
let event_data = event_data.clone();
|
||||
let on_create = props.on_create.clone();
|
||||
Callback::from(move |_: MouseEvent| {
|
||||
on_create.emit((*event_data).clone());
|
||||
})
|
||||
};
|
||||
|
||||
let on_close = props.on_close.clone();
|
||||
let on_close_header = on_close.clone();
|
||||
|
||||
let tab_props = TabProps {
|
||||
data: event_data.clone(),
|
||||
available_calendars: props.available_calendars.clone(),
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="modal-backdrop" onclick={on_backdrop_click}>
|
||||
<div class="modal-content create-event-modal">
|
||||
<div class="modal-header">
|
||||
<h3>
|
||||
{if props.event_to_edit.is_some() { "Edit Event" } else { "Create Event" }}
|
||||
</h3>
|
||||
<button class="modal-close" onclick={Callback::from(move |_| on_close_header.emit(()))}>
|
||||
{"×"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-tabs">
|
||||
<div class="tab-navigation">
|
||||
<button
|
||||
class={if *active_tab == ModalTab::BasicDetails { "tab-button active" } else { "tab-button" }}
|
||||
onclick={{
|
||||
let switch_to_tab = switch_to_tab.clone();
|
||||
Callback::from(move |_| switch_to_tab.emit(ModalTab::BasicDetails))
|
||||
}}
|
||||
>
|
||||
{"Basic"}
|
||||
</button>
|
||||
<button
|
||||
class={if *active_tab == ModalTab::Advanced { "tab-button active" } else { "tab-button" }}
|
||||
onclick={{
|
||||
let switch_to_tab = switch_to_tab.clone();
|
||||
Callback::from(move |_| switch_to_tab.emit(ModalTab::Advanced))
|
||||
}}
|
||||
>
|
||||
{"Advanced"}
|
||||
</button>
|
||||
<button
|
||||
class={if *active_tab == ModalTab::People { "tab-button active" } else { "tab-button" }}
|
||||
onclick={{
|
||||
let switch_to_tab = switch_to_tab.clone();
|
||||
Callback::from(move |_| switch_to_tab.emit(ModalTab::People))
|
||||
}}
|
||||
>
|
||||
{"People"}
|
||||
</button>
|
||||
<button
|
||||
class={if *active_tab == ModalTab::Categories { "tab-button active" } else { "tab-button" }}
|
||||
onclick={{
|
||||
let switch_to_tab = switch_to_tab.clone();
|
||||
Callback::from(move |_| switch_to_tab.emit(ModalTab::Categories))
|
||||
}}
|
||||
>
|
||||
{"Categories"}
|
||||
</button>
|
||||
<button
|
||||
class={if *active_tab == ModalTab::Location { "tab-button active" } else { "tab-button" }}
|
||||
onclick={{
|
||||
let switch_to_tab = switch_to_tab.clone();
|
||||
Callback::from(move |_| switch_to_tab.emit(ModalTab::Location))
|
||||
}}
|
||||
>
|
||||
{"Location"}
|
||||
</button>
|
||||
<button
|
||||
class={if *active_tab == ModalTab::Reminders { "tab-button active" } else { "tab-button" }}
|
||||
onclick={{
|
||||
let switch_to_tab = switch_to_tab.clone();
|
||||
Callback::from(move |_| switch_to_tab.emit(ModalTab::Reminders))
|
||||
}}
|
||||
>
|
||||
{"Reminders"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="tab-content">
|
||||
{
|
||||
match *active_tab {
|
||||
ModalTab::BasicDetails => html! { <BasicDetailsTab ..tab_props /> },
|
||||
ModalTab::Advanced => html! { <AdvancedTab ..tab_props /> },
|
||||
ModalTab::People => html! { <PeopleTab ..tab_props /> },
|
||||
ModalTab::Categories => html! { <CategoriesTab ..tab_props /> },
|
||||
ModalTab::Location => html! { <LocationTab ..tab_props /> },
|
||||
ModalTab::Reminders => html! { <RemindersTab ..tab_props /> },
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-secondary" onclick={Callback::from(move |_| on_close.emit(()))}>
|
||||
{"Cancel"}
|
||||
</button>
|
||||
<button class="btn btn-primary" onclick={on_save}>
|
||||
{if props.event_to_edit.is_some() { "Update Event" } else { "Create Event" }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,53 @@ pub fn event_context_menu(props: &EventContextMenuProps) -> Html {
|
||||
return html! {};
|
||||
}
|
||||
|
||||
// Smart positioning to keep menu within viewport
|
||||
let (x, y) = {
|
||||
let mut x = props.x;
|
||||
let mut y = props.y;
|
||||
|
||||
// Try to get actual viewport dimensions
|
||||
if let Some(window) = web_sys::window() {
|
||||
if let (Ok(width), Ok(height)) = (window.inner_width(), window.inner_height()) {
|
||||
if let (Some(w), Some(h)) = (width.as_f64(), height.as_f64()) {
|
||||
let viewport_width = w as i32;
|
||||
let viewport_height = h as i32;
|
||||
|
||||
// More accurate menu dimensions based on actual CSS and content
|
||||
let menu_width = if props.event.as_ref().map_or(false, |e| e.rrule.is_some()) {
|
||||
280 // Recurring: "Edit This and Future Events" is long text + padding
|
||||
} else {
|
||||
180 // Non-recurring: "Edit Event" + "Delete Event" + padding
|
||||
};
|
||||
let menu_height = if props.event.as_ref().map_or(false, |e| e.rrule.is_some()) {
|
||||
200 // 6 items × ~32px per item (12px padding top/bottom + text height + borders)
|
||||
} else {
|
||||
100 // 2 items × ~32px per item + some extra margin
|
||||
};
|
||||
|
||||
// Adjust horizontally if too close to right edge
|
||||
if x + menu_width > viewport_width - 10 {
|
||||
x = x.saturating_sub(menu_width);
|
||||
}
|
||||
|
||||
// Adjust vertically if too close to bottom edge
|
||||
if y + menu_height > viewport_height - 10 {
|
||||
y = y.saturating_sub(menu_height);
|
||||
}
|
||||
|
||||
// Ensure minimum margins from edges
|
||||
x = x.max(5);
|
||||
y = y.max(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(x, y)
|
||||
};
|
||||
|
||||
let style = format!(
|
||||
"position: fixed; left: {}px; top: {}px; z-index: 1001;",
|
||||
props.x, props.y
|
||||
x, y
|
||||
);
|
||||
|
||||
// Check if the event is recurring
|
||||
|
||||
109
frontend/src/components/event_form/advanced.rs
Normal file
109
frontend/src/components/event_form/advanced.rs
Normal file
@@ -0,0 +1,109 @@
|
||||
use super::types::*;
|
||||
use crate::components::create_event_modal::{EventStatus, EventClass};
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::{HtmlInputElement, HtmlSelectElement};
|
||||
use yew::prelude::*;
|
||||
|
||||
#[function_component(AdvancedTab)]
|
||||
pub fn advanced_tab(props: &TabProps) -> Html {
|
||||
let data = &props.data;
|
||||
|
||||
let on_status_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(select) = target.dyn_into::<HtmlSelectElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.status = match select.value().as_str() {
|
||||
"tentative" => EventStatus::Tentative,
|
||||
"cancelled" => EventStatus::Cancelled,
|
||||
_ => EventStatus::Confirmed,
|
||||
};
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_class_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(select) = target.dyn_into::<HtmlSelectElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.class = match select.value().as_str() {
|
||||
"private" => EventClass::Private,
|
||||
"confidential" => EventClass::Confidential,
|
||||
_ => EventClass::Public,
|
||||
};
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_priority_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(select) = target.dyn_into::<HtmlSelectElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
let value = select.value();
|
||||
event_data.priority = if value.is_empty() {
|
||||
None
|
||||
} else {
|
||||
value.parse::<u8>().ok().filter(|&p| p <= 9)
|
||||
};
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="tab-panel">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="event-status">{"Status"}</label>
|
||||
<select
|
||||
id="event-status"
|
||||
class="form-input"
|
||||
onchange={on_status_change}
|
||||
>
|
||||
<option value="confirmed" selected={matches!(data.status, EventStatus::Confirmed)}>{"Confirmed"}</option>
|
||||
<option value="tentative" selected={matches!(data.status, EventStatus::Tentative)}>{"Tentative"}</option>
|
||||
<option value="cancelled" selected={matches!(data.status, EventStatus::Cancelled)}>{"Cancelled"}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="event-class">{"Privacy"}</label>
|
||||
<select
|
||||
id="event-class"
|
||||
class="form-input"
|
||||
onchange={on_class_change}
|
||||
>
|
||||
<option value="public" selected={matches!(data.class, EventClass::Public)}>{"Public"}</option>
|
||||
<option value="private" selected={matches!(data.class, EventClass::Private)}>{"Private"}</option>
|
||||
<option value="confidential" selected={matches!(data.class, EventClass::Confidential)}>{"Confidential"}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="event-priority">{"Priority"}</label>
|
||||
<select
|
||||
id="event-priority"
|
||||
class="form-input"
|
||||
onchange={on_priority_change}
|
||||
>
|
||||
<option value="" selected={data.priority.is_none()}>{"Not set"}</option>
|
||||
<option value="1" selected={data.priority == Some(1)}>{"High"}</option>
|
||||
<option value="5" selected={data.priority == Some(5)}>{"Medium"}</option>
|
||||
<option value="9" selected={data.priority == Some(9)}>{"Low"}</option>
|
||||
</select>
|
||||
<p class="form-help-text">{"Set the importance level for this event."}</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
730
frontend/src/components/event_form/basic_details.rs
Normal file
730
frontend/src/components/event_form/basic_details.rs
Normal file
@@ -0,0 +1,730 @@
|
||||
use super::types::*;
|
||||
use crate::components::create_event_modal::{EventStatus, EventClass, RecurrenceType, ReminderType};
|
||||
use chrono::{Datelike, NaiveDate};
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::{HtmlInputElement, HtmlSelectElement, HtmlTextAreaElement};
|
||||
use yew::prelude::*;
|
||||
|
||||
#[function_component(BasicDetailsTab)]
|
||||
pub fn basic_details_tab(props: &TabProps) -> Html {
|
||||
let data = &props.data;
|
||||
|
||||
// Event handlers
|
||||
let on_title_input = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: InputEvent| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(input) = target.dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.title = input.value();
|
||||
if !event_data.changed_fields.contains(&"title".to_string()) {
|
||||
event_data.changed_fields.push("title".to_string());
|
||||
}
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_description_input = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: InputEvent| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(textarea) = target.dyn_into::<HtmlTextAreaElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.description = textarea.value();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_calendar_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(select) = target.dyn_into::<HtmlSelectElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
let value = select.value();
|
||||
let new_calendar = if value.is_empty() { None } else { Some(value) };
|
||||
if event_data.selected_calendar != new_calendar {
|
||||
event_data.selected_calendar = new_calendar;
|
||||
if !event_data.changed_fields.contains(&"selected_calendar".to_string()) {
|
||||
event_data.changed_fields.push("selected_calendar".to_string());
|
||||
}
|
||||
}
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_all_day_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(input) = target.dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.all_day = input.checked();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_recurrence_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(select) = target.dyn_into::<HtmlSelectElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.recurrence = match select.value().as_str() {
|
||||
"daily" => RecurrenceType::Daily,
|
||||
"weekly" => RecurrenceType::Weekly,
|
||||
"monthly" => RecurrenceType::Monthly,
|
||||
"yearly" => RecurrenceType::Yearly,
|
||||
_ => RecurrenceType::None,
|
||||
};
|
||||
// Reset recurrence-related fields when changing type
|
||||
event_data.recurrence_days = vec![false; 7];
|
||||
event_data.recurrence_interval = 1;
|
||||
event_data.recurrence_until = None;
|
||||
event_data.recurrence_count = None;
|
||||
event_data.monthly_by_day = None;
|
||||
event_data.monthly_by_monthday = None;
|
||||
event_data.yearly_by_month = vec![false; 12];
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_reminder_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(select) = target.dyn_into::<HtmlSelectElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.reminder = match select.value().as_str() {
|
||||
"15min" => ReminderType::Minutes15,
|
||||
"30min" => ReminderType::Minutes30,
|
||||
"1hour" => ReminderType::Hour1,
|
||||
"1day" => ReminderType::Day1,
|
||||
"2days" => ReminderType::Days2,
|
||||
"1week" => ReminderType::Week1,
|
||||
_ => ReminderType::None,
|
||||
};
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_recurrence_interval_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
if let Ok(interval) = input.value().parse::<u32>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.recurrence_interval = interval.max(1);
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_recurrence_until_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
if input.value().is_empty() {
|
||||
event_data.recurrence_until = None;
|
||||
} else if let Ok(date) = NaiveDate::parse_from_str(&input.value(), "%Y-%m-%d") {
|
||||
event_data.recurrence_until = Some(date);
|
||||
}
|
||||
data.set(event_data);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_recurrence_count_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
if input.value().is_empty() {
|
||||
event_data.recurrence_count = None;
|
||||
} else if let Ok(count) = input.value().parse::<u32>() {
|
||||
event_data.recurrence_count = Some(count.max(1));
|
||||
}
|
||||
data.set(event_data);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_monthly_by_monthday_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
if input.value().is_empty() {
|
||||
event_data.monthly_by_monthday = None;
|
||||
} else if let Ok(day) = input.value().parse::<u8>() {
|
||||
if day >= 1 && day <= 31 {
|
||||
event_data.monthly_by_monthday = Some(day);
|
||||
event_data.monthly_by_day = None; // Clear the other option
|
||||
}
|
||||
}
|
||||
data.set(event_data);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_monthly_by_day_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(select) = e.target_dyn_into::<HtmlSelectElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
if select.value().is_empty() || select.value() == "none" {
|
||||
event_data.monthly_by_day = None;
|
||||
} else {
|
||||
event_data.monthly_by_day = Some(select.value());
|
||||
event_data.monthly_by_monthday = None; // Clear the other option
|
||||
}
|
||||
data.set(event_data);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_weekday_change = {
|
||||
let data = data.clone();
|
||||
move |day_index: usize| {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
if day_index < event_data.recurrence_days.len() {
|
||||
event_data.recurrence_days[day_index] = input.checked();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
let on_yearly_month_change = {
|
||||
let data = data.clone();
|
||||
move |month_index: usize| {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
if month_index < event_data.yearly_by_month.len() {
|
||||
event_data.yearly_by_month[month_index] = input.checked();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
let on_start_date_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
if let Ok(date) = NaiveDate::parse_from_str(&input.value(), "%Y-%m-%d") {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.start_date = date;
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_start_time_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
if let Ok(time) = chrono::NaiveTime::parse_from_str(&input.value(), "%H:%M") {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.start_time = time;
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_end_date_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
if let Ok(date) = NaiveDate::parse_from_str(&input.value(), "%Y-%m-%d") {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.end_date = date;
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_end_time_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(input) = e.target_dyn_into::<HtmlInputElement>() {
|
||||
if let Ok(time) = chrono::NaiveTime::parse_from_str(&input.value(), "%H:%M") {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.end_time = time;
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_location_input = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: InputEvent| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(input) = target.dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.location = input.value();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="tab-panel">
|
||||
<div class="form-group">
|
||||
<label for="event-title">{"Event Title *"}</label>
|
||||
<input
|
||||
type="text"
|
||||
id="event-title"
|
||||
class="form-input"
|
||||
value={data.title.clone()}
|
||||
oninput={on_title_input}
|
||||
placeholder="Add a title"
|
||||
required=true
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="event-description">{"Description"}</label>
|
||||
<textarea
|
||||
id="event-description"
|
||||
class="form-input"
|
||||
value={data.description.clone()}
|
||||
oninput={on_description_input}
|
||||
placeholder="Add a description"
|
||||
rows="3"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="event-calendar">{"Calendar"}</label>
|
||||
<select
|
||||
id="event-calendar"
|
||||
class="form-input"
|
||||
onchange={on_calendar_change}
|
||||
>
|
||||
<option value="">{"Select Calendar"}</option>
|
||||
{
|
||||
props.available_calendars.iter().map(|calendar| {
|
||||
html! {
|
||||
<option
|
||||
key={calendar.path.clone()}
|
||||
value={calendar.path.clone()}
|
||||
selected={data.selected_calendar.as_ref() == Some(&calendar.path)}
|
||||
>
|
||||
{&calendar.display_name}
|
||||
</option>
|
||||
}
|
||||
}).collect::<Html>()
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="checkbox-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={data.all_day}
|
||||
onchange={on_all_day_change}
|
||||
/>
|
||||
{" All Day"}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="event-recurrence-basic">{"Repeat"}</label>
|
||||
<select
|
||||
id="event-recurrence-basic"
|
||||
class="form-input"
|
||||
onchange={on_recurrence_change}
|
||||
>
|
||||
<option value="none" selected={matches!(data.recurrence, RecurrenceType::None)}>{"Does not repeat"}</option>
|
||||
<option value="daily" selected={matches!(data.recurrence, RecurrenceType::Daily)}>{"Daily"}</option>
|
||||
<option value="weekly" selected={matches!(data.recurrence, RecurrenceType::Weekly)}>{"Weekly"}</option>
|
||||
<option value="monthly" selected={matches!(data.recurrence, RecurrenceType::Monthly)}>{"Monthly"}</option>
|
||||
<option value="yearly" selected={matches!(data.recurrence, RecurrenceType::Yearly)}>{"Yearly"}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="event-reminder-basic">{"Reminder"}</label>
|
||||
<select
|
||||
id="event-reminder-basic"
|
||||
class="form-input"
|
||||
onchange={on_reminder_change}
|
||||
>
|
||||
<option value="none" selected={matches!(data.reminder, ReminderType::None)}>{"None"}</option>
|
||||
<option value="15min" selected={matches!(data.reminder, ReminderType::Minutes15)}>{"15 minutes before"}</option>
|
||||
<option value="30min" selected={matches!(data.reminder, ReminderType::Minutes30)}>{"30 minutes before"}</option>
|
||||
<option value="1hour" selected={matches!(data.reminder, ReminderType::Hour1)}>{"1 hour before"}</option>
|
||||
<option value="1day" selected={matches!(data.reminder, ReminderType::Day1)}>{"1 day before"}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
// RECURRENCE OPTIONS GO RIGHT HERE - directly below repeat/reminder!
|
||||
if matches!(data.recurrence, RecurrenceType::Weekly) {
|
||||
<div class="form-group">
|
||||
<label>{"Repeat on"}</label>
|
||||
<div class="weekday-selection">
|
||||
{
|
||||
["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, day)| {
|
||||
let day_checked = data.recurrence_days.get(i).cloned().unwrap_or(false);
|
||||
let on_change = on_weekday_change(i);
|
||||
html! {
|
||||
<label key={i} class="weekday-checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={day_checked}
|
||||
onchange={on_change}
|
||||
/>
|
||||
<span class="weekday-label">{day}</span>
|
||||
</label>
|
||||
}
|
||||
})
|
||||
.collect::<Html>()
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
if !matches!(data.recurrence, RecurrenceType::None) {
|
||||
<div class="recurrence-options">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="recurrence-interval">{"Every"}</label>
|
||||
<div class="interval-input">
|
||||
<input
|
||||
id="recurrence-interval"
|
||||
type="number"
|
||||
class="form-input"
|
||||
value={data.recurrence_interval.to_string()}
|
||||
min="1"
|
||||
max="999"
|
||||
onchange={on_recurrence_interval_change}
|
||||
/>
|
||||
<span class="interval-unit">
|
||||
{match data.recurrence {
|
||||
RecurrenceType::Daily => if data.recurrence_interval == 1 { "day" } else { "days" },
|
||||
RecurrenceType::Weekly => if data.recurrence_interval == 1 { "week" } else { "weeks" },
|
||||
RecurrenceType::Monthly => if data.recurrence_interval == 1 { "month" } else { "months" },
|
||||
RecurrenceType::Yearly => if data.recurrence_interval == 1 { "year" } else { "years" },
|
||||
RecurrenceType::None => "",
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>{"Ends"}</label>
|
||||
<div class="end-options">
|
||||
<div class="end-option">
|
||||
<label class="radio-label">
|
||||
<input
|
||||
type="radio"
|
||||
name="recurrence-end"
|
||||
value="never"
|
||||
checked={data.recurrence_until.is_none() && data.recurrence_count.is_none()}
|
||||
onchange={{
|
||||
let data = data.clone();
|
||||
Callback::from(move |_| {
|
||||
let mut new_data = (*data).clone();
|
||||
new_data.recurrence_until = None;
|
||||
new_data.recurrence_count = None;
|
||||
data.set(new_data);
|
||||
})
|
||||
}}
|
||||
/>
|
||||
{"Never"}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="end-option">
|
||||
<label class="radio-label">
|
||||
<input
|
||||
type="radio"
|
||||
name="recurrence-end"
|
||||
value="until"
|
||||
checked={data.recurrence_until.is_some()}
|
||||
onchange={{
|
||||
let data = data.clone();
|
||||
Callback::from(move |_| {
|
||||
let mut new_data = (*data).clone();
|
||||
new_data.recurrence_count = None;
|
||||
new_data.recurrence_until = Some(new_data.start_date);
|
||||
data.set(new_data);
|
||||
})
|
||||
}}
|
||||
/>
|
||||
{"Until"}
|
||||
</label>
|
||||
<input
|
||||
type="date"
|
||||
class="form-input"
|
||||
value={data.recurrence_until.map(|d| d.format("%Y-%m-%d").to_string()).unwrap_or_default()}
|
||||
onchange={on_recurrence_until_change}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="end-option">
|
||||
<label class="radio-label">
|
||||
<input
|
||||
type="radio"
|
||||
name="recurrence-end"
|
||||
value="count"
|
||||
checked={data.recurrence_count.is_some()}
|
||||
onchange={{
|
||||
let data = data.clone();
|
||||
Callback::from(move |_| {
|
||||
let mut new_data = (*data).clone();
|
||||
new_data.recurrence_until = None;
|
||||
new_data.recurrence_count = Some(10); // Default count
|
||||
data.set(new_data);
|
||||
})
|
||||
}}
|
||||
/>
|
||||
{"After"}
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
class="form-input count-input"
|
||||
value={data.recurrence_count.map(|c| c.to_string()).unwrap_or_default()}
|
||||
min="1"
|
||||
max="999"
|
||||
placeholder="1"
|
||||
onchange={on_recurrence_count_change}
|
||||
/>
|
||||
<span class="count-unit">{"occurrences"}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
// Monthly specific options
|
||||
if matches!(data.recurrence, RecurrenceType::Monthly) {
|
||||
<div class="form-group">
|
||||
<label>{"Repeat by"}</label>
|
||||
<div class="monthly-options">
|
||||
<div class="monthly-option">
|
||||
<label class="radio-label">
|
||||
<input
|
||||
type="radio"
|
||||
name="monthly-type"
|
||||
checked={data.monthly_by_monthday.is_some()}
|
||||
onchange={{
|
||||
let data = data.clone();
|
||||
Callback::from(move |_| {
|
||||
let mut new_data = (*data).clone();
|
||||
new_data.monthly_by_day = None;
|
||||
new_data.monthly_by_monthday = Some(new_data.start_date.day() as u8);
|
||||
data.set(new_data);
|
||||
})
|
||||
}}
|
||||
/>
|
||||
{"Day of month:"}
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
class="form-input day-input"
|
||||
value={data.monthly_by_monthday.map(|d| d.to_string()).unwrap_or_else(|| data.start_date.day().to_string())}
|
||||
min="1"
|
||||
max="31"
|
||||
onchange={on_monthly_by_monthday_change}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="monthly-option">
|
||||
<label class="radio-label">
|
||||
<input
|
||||
type="radio"
|
||||
name="monthly-type"
|
||||
checked={data.monthly_by_day.is_some()}
|
||||
onchange={{
|
||||
let data = data.clone();
|
||||
Callback::from(move |_| {
|
||||
let mut new_data = (*data).clone();
|
||||
new_data.monthly_by_monthday = None;
|
||||
new_data.monthly_by_day = Some("1MO".to_string()); // Default to first Monday
|
||||
data.set(new_data);
|
||||
})
|
||||
}}
|
||||
/>
|
||||
{"Day of week:"}
|
||||
</label>
|
||||
<select
|
||||
class="form-input"
|
||||
value={data.monthly_by_day.clone().unwrap_or_default()}
|
||||
onchange={on_monthly_by_day_change}
|
||||
>
|
||||
<option value="none">{"Select..."}</option>
|
||||
<option value="1MO">{"First Monday"}</option>
|
||||
<option value="1TU">{"First Tuesday"}</option>
|
||||
<option value="1WE">{"First Wednesday"}</option>
|
||||
<option value="1TH">{"First Thursday"}</option>
|
||||
<option value="1FR">{"First Friday"}</option>
|
||||
<option value="1SA">{"First Saturday"}</option>
|
||||
<option value="1SU">{"First Sunday"}</option>
|
||||
<option value="2MO">{"Second Monday"}</option>
|
||||
<option value="2TU">{"Second Tuesday"}</option>
|
||||
<option value="2WE">{"Second Wednesday"}</option>
|
||||
<option value="2TH">{"Second Thursday"}</option>
|
||||
<option value="2FR">{"Second Friday"}</option>
|
||||
<option value="2SA">{"Second Saturday"}</option>
|
||||
<option value="2SU">{"Second Sunday"}</option>
|
||||
<option value="3MO">{"Third Monday"}</option>
|
||||
<option value="3TU">{"Third Tuesday"}</option>
|
||||
<option value="3WE">{"Third Wednesday"}</option>
|
||||
<option value="3TH">{"Third Thursday"}</option>
|
||||
<option value="3FR">{"Third Friday"}</option>
|
||||
<option value="3SA">{"Third Saturday"}</option>
|
||||
<option value="3SU">{"Third Sunday"}</option>
|
||||
<option value="4MO">{"Fourth Monday"}</option>
|
||||
<option value="4TU">{"Fourth Tuesday"}</option>
|
||||
<option value="4WE">{"Fourth Wednesday"}</option>
|
||||
<option value="4TH">{"Fourth Thursday"}</option>
|
||||
<option value="4FR">{"Fourth Friday"}</option>
|
||||
<option value="4SA">{"Fourth Saturday"}</option>
|
||||
<option value="4SU">{"Fourth Sunday"}</option>
|
||||
<option value="-1MO">{"Last Monday"}</option>
|
||||
<option value="-1TU">{"Last Tuesday"}</option>
|
||||
<option value="-1WE">{"Last Wednesday"}</option>
|
||||
<option value="-1TH">{"Last Thursday"}</option>
|
||||
<option value="-1FR">{"Last Friday"}</option>
|
||||
<option value="-1SA">{"Last Saturday"}</option>
|
||||
<option value="-1SU">{"Last Sunday"}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
// Yearly specific options
|
||||
if matches!(data.recurrence, RecurrenceType::Yearly) {
|
||||
<div class="form-group">
|
||||
<label>{"Repeat in months"}</label>
|
||||
<div class="yearly-months">
|
||||
{
|
||||
["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, month)| {
|
||||
let month_checked = data.yearly_by_month.get(i).cloned().unwrap_or(false);
|
||||
let on_change = on_yearly_month_change(i);
|
||||
html! {
|
||||
<label key={i} class="month-checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={month_checked}
|
||||
onchange={on_change}
|
||||
/>
|
||||
<span class="month-label">{month}</span>
|
||||
</label>
|
||||
}
|
||||
})
|
||||
.collect::<Html>()
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
// Date and time fields go here AFTER recurrence options
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="start-date">{"Start Date *"}</label>
|
||||
<input
|
||||
type="date"
|
||||
id="start-date"
|
||||
class="form-input"
|
||||
value={data.start_date.format("%Y-%m-%d").to_string()}
|
||||
onchange={on_start_date_change}
|
||||
required=true
|
||||
/>
|
||||
</div>
|
||||
|
||||
if !data.all_day {
|
||||
<div class="form-group">
|
||||
<label for="start-time">{"Start Time"}</label>
|
||||
<input
|
||||
type="time"
|
||||
id="start-time"
|
||||
class="form-input"
|
||||
value={data.start_time.format("%H:%M").to_string()}
|
||||
onchange={on_start_time_change}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="end-date">{"End Date *"}</label>
|
||||
<input
|
||||
type="date"
|
||||
id="end-date"
|
||||
class="form-input"
|
||||
value={data.end_date.format("%Y-%m-%d").to_string()}
|
||||
onchange={on_end_date_change}
|
||||
required=true
|
||||
/>
|
||||
</div>
|
||||
|
||||
if !data.all_day {
|
||||
<div class="form-group">
|
||||
<label for="end-time">{"End Time"}</label>
|
||||
<input
|
||||
type="time"
|
||||
id="end-time"
|
||||
class="form-input"
|
||||
value={data.end_time.format("%H:%M").to_string()}
|
||||
onchange={on_end_time_change}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="event-location">{"Location"}</label>
|
||||
<input
|
||||
type="text"
|
||||
id="event-location"
|
||||
class="form-input"
|
||||
value={data.location.clone()}
|
||||
oninput={on_location_input}
|
||||
placeholder="Enter event location"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
98
frontend/src/components/event_form/categories.rs
Normal file
98
frontend/src/components/event_form/categories.rs
Normal file
@@ -0,0 +1,98 @@
|
||||
use super::types::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::HtmlInputElement;
|
||||
use yew::prelude::*;
|
||||
|
||||
#[function_component(CategoriesTab)]
|
||||
pub fn categories_tab(props: &TabProps) -> Html {
|
||||
let data = &props.data;
|
||||
|
||||
let on_categories_input = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: InputEvent| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(input) = target.dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.categories = input.value();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let add_category = {
|
||||
let data = data.clone();
|
||||
move |category: &str| {
|
||||
let data = data.clone();
|
||||
let category = category.to_string();
|
||||
Callback::from(move |_| {
|
||||
let mut event_data = (*data).clone();
|
||||
if event_data.categories.is_empty() {
|
||||
event_data.categories = category.clone();
|
||||
} else {
|
||||
event_data.categories = format!("{}, {}", event_data.categories, category);
|
||||
}
|
||||
data.set(event_data);
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="tab-panel">
|
||||
<div class="form-group">
|
||||
<label for="event-categories">{"Categories"}</label>
|
||||
<input
|
||||
type="text"
|
||||
id="event-categories"
|
||||
class="form-input"
|
||||
value={data.categories.clone()}
|
||||
oninput={on_categories_input}
|
||||
placeholder="work, meeting, personal, project, urgent"
|
||||
/>
|
||||
<p class="form-help-text">{"Enter categories separated by commas to help organize and filter your events"}</p>
|
||||
</div>
|
||||
|
||||
<div class="categories-suggestions">
|
||||
<h5>{"Common Categories"}</h5>
|
||||
<div class="category-tags">
|
||||
<button type="button" class="category-tag" onclick={add_category("work")}>{"work"}</button>
|
||||
<button type="button" class="category-tag" onclick={add_category("meeting")}>{"meeting"}</button>
|
||||
<button type="button" class="category-tag" onclick={add_category("personal")}>{"personal"}</button>
|
||||
<button type="button" class="category-tag" onclick={add_category("project")}>{"project"}</button>
|
||||
<button type="button" class="category-tag" onclick={add_category("urgent")}>{"urgent"}</button>
|
||||
<button type="button" class="category-tag" onclick={add_category("social")}>{"social"}</button>
|
||||
<button type="button" class="category-tag" onclick={add_category("travel")}>{"travel"}</button>
|
||||
<button type="button" class="category-tag" onclick={add_category("health")}>{"health"}</button>
|
||||
</div>
|
||||
<p class="form-help-text">{"Click to add these common categories to your event"}</p>
|
||||
</div>
|
||||
|
||||
<div class="categories-info">
|
||||
<h5>{"Event Organization & Filtering"}</h5>
|
||||
<ul>
|
||||
<li>{"Categories help organize events in calendar views"}</li>
|
||||
<li>{"Filter events by category to focus on specific types"}</li>
|
||||
<li>{"Categories are searchable and can be used for reporting"}</li>
|
||||
<li>{"Multiple categories per event are fully supported"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="categories-examples">
|
||||
<h6>{"Category Usage Examples"}</h6>
|
||||
<div class="category-example">
|
||||
<strong>{"Work Events:"}</strong>
|
||||
<span>{"work, meeting, project, urgent, deadline"}</span>
|
||||
</div>
|
||||
<div class="category-example">
|
||||
<strong>{"Personal Events:"}</strong>
|
||||
<span>{"personal, family, health, social, travel"}</span>
|
||||
</div>
|
||||
<div class="category-example">
|
||||
<strong>{"Mixed Events:"}</strong>
|
||||
<span>{"work, travel, client, important"}</span>
|
||||
</div>
|
||||
<p class="form-help-text">{"Categories follow RFC 5545 CATEGORIES property standards"}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
118
frontend/src/components/event_form/location.rs
Normal file
118
frontend/src/components/event_form/location.rs
Normal file
@@ -0,0 +1,118 @@
|
||||
use super::types::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::HtmlInputElement;
|
||||
use yew::prelude::*;
|
||||
|
||||
#[function_component(LocationTab)]
|
||||
pub fn location_tab(props: &TabProps) -> Html {
|
||||
let data = &props.data;
|
||||
|
||||
let on_location_input = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: InputEvent| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(input) = target.dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.location = input.value();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let set_location = {
|
||||
let data = data.clone();
|
||||
move |location: &str| {
|
||||
let data = data.clone();
|
||||
let location = location.to_string();
|
||||
Callback::from(move |_| {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.location = location.clone();
|
||||
data.set(event_data);
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="tab-panel">
|
||||
<div class="form-group">
|
||||
<label for="event-location-detailed">{"Event Location"}</label>
|
||||
<input
|
||||
type="text"
|
||||
id="event-location-detailed"
|
||||
class="form-input"
|
||||
value={data.location.clone()}
|
||||
oninput={on_location_input}
|
||||
placeholder="Conference Room A, 123 Main St, City, State 12345"
|
||||
/>
|
||||
<p class="form-help-text">{"Enter the full address or location description for the event"}</p>
|
||||
</div>
|
||||
|
||||
<div class="location-suggestions">
|
||||
<h5>{"Common Locations"}</h5>
|
||||
<div class="location-tags">
|
||||
<button type="button" class="location-tag" onclick={set_location("Conference Room")}>{"Conference Room"}</button>
|
||||
<button type="button" class="location-tag" onclick={set_location("Online Meeting")}>{"Online Meeting"}</button>
|
||||
<button type="button" class="location-tag" onclick={set_location("Main Office")}>{"Main Office"}</button>
|
||||
<button type="button" class="location-tag" onclick={set_location("Client Site")}>{"Client Site"}</button>
|
||||
<button type="button" class="location-tag" onclick={set_location("Home Office")}>{"Home Office"}</button>
|
||||
<button type="button" class="location-tag" onclick={set_location("Remote")}>{"Remote"}</button>
|
||||
</div>
|
||||
<p class="form-help-text">{"Click to quickly set common location types"}</p>
|
||||
</div>
|
||||
|
||||
<div class="location-info">
|
||||
<h5>{"Location Features & Integration"}</h5>
|
||||
<ul>
|
||||
<li>{"Location information is included in calendar invitations"}</li>
|
||||
<li>{"Supports both physical addresses and virtual meeting links"}</li>
|
||||
<li>{"Compatible with mapping and navigation applications"}</li>
|
||||
<li>{"Room booking integration available for enterprise setups"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="geo-section">
|
||||
<h6>{"Geographic Coordinates (Advanced)"}</h6>
|
||||
<p>{"Future versions will support:"}</p>
|
||||
<div class="geo-features">
|
||||
<div class="geo-item">
|
||||
<strong>{"GPS Coordinates:"}</strong>
|
||||
<span>{"Precise latitude/longitude positioning"}</span>
|
||||
</div>
|
||||
<div class="geo-item">
|
||||
<strong>{"Map Integration:"}</strong>
|
||||
<span>{"Embedded maps in event details"}</span>
|
||||
</div>
|
||||
<div class="geo-item">
|
||||
<strong>{"Travel Time:"}</strong>
|
||||
<span>{"Automatic travel time calculation"}</span>
|
||||
</div>
|
||||
<div class="geo-item">
|
||||
<strong>{"Proximity Alerts:"}</strong>
|
||||
<span>{"Location-based notifications"}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="form-help-text">{"Advanced geographic features will be implemented in future releases"}</p>
|
||||
</div>
|
||||
|
||||
<div class="virtual-meeting-section">
|
||||
<h6>{"Virtual Meeting Integration"}</h6>
|
||||
<div class="meeting-platforms">
|
||||
<div class="platform-item">
|
||||
<strong>{"Video Conferencing:"}</strong>
|
||||
<span>{"Zoom, Teams, Google Meet links"}</span>
|
||||
</div>
|
||||
<div class="platform-item">
|
||||
<strong>{"Phone Conference:"}</strong>
|
||||
<span>{"Dial-in numbers and access codes"}</span>
|
||||
</div>
|
||||
<div class="platform-item">
|
||||
<strong>{"Webinar Links:"}</strong>
|
||||
<span>{"Live streaming and presentation URLs"}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="form-help-text">{"Paste meeting links directly in the location field for virtual events"}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
16
frontend/src/components/event_form/mod.rs
Normal file
16
frontend/src/components/event_form/mod.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
// Event form components module
|
||||
pub mod types;
|
||||
pub mod basic_details;
|
||||
pub mod advanced;
|
||||
pub mod people;
|
||||
pub mod categories;
|
||||
pub mod location;
|
||||
pub mod reminders;
|
||||
|
||||
pub use types::*;
|
||||
pub use basic_details::BasicDetailsTab;
|
||||
pub use advanced::AdvancedTab;
|
||||
pub use people::PeopleTab;
|
||||
pub use categories::CategoriesTab;
|
||||
pub use location::LocationTab;
|
||||
pub use reminders::RemindersTab;
|
||||
103
frontend/src/components/event_form/people.rs
Normal file
103
frontend/src/components/event_form/people.rs
Normal file
@@ -0,0 +1,103 @@
|
||||
use super::types::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::{HtmlInputElement, HtmlTextAreaElement};
|
||||
use yew::prelude::*;
|
||||
|
||||
#[function_component(PeopleTab)]
|
||||
pub fn people_tab(props: &TabProps) -> Html {
|
||||
let data = &props.data;
|
||||
|
||||
let on_organizer_input = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: InputEvent| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(input) = target.dyn_into::<HtmlInputElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.organizer = input.value();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let on_attendees_input = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: InputEvent| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(textarea) = target.dyn_into::<HtmlTextAreaElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.attendees = textarea.value();
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="tab-panel">
|
||||
<div class="form-group">
|
||||
<label for="event-organizer">{"Organizer"}</label>
|
||||
<input
|
||||
type="email"
|
||||
id="event-organizer"
|
||||
class="form-input"
|
||||
value={data.organizer.clone()}
|
||||
oninput={on_organizer_input}
|
||||
placeholder="organizer@example.com"
|
||||
/>
|
||||
<p class="form-help-text">{"Email address of the person organizing this event"}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="event-attendees">{"Attendees"}</label>
|
||||
<textarea
|
||||
id="event-attendees"
|
||||
class="form-input"
|
||||
value={data.attendees.clone()}
|
||||
oninput={on_attendees_input}
|
||||
placeholder="attendee1@example.com, attendee2@example.com, attendee3@example.com"
|
||||
rows="4"
|
||||
></textarea>
|
||||
<p class="form-help-text">{"Enter attendee email addresses separated by commas"}</p>
|
||||
</div>
|
||||
|
||||
<div class="people-info">
|
||||
<h5>{"Invitation & Response Management"}</h5>
|
||||
<ul>
|
||||
<li>{"Invitations are sent automatically when the event is saved"}</li>
|
||||
<li>{"Attendees can respond with Accept, Decline, or Tentative"}</li>
|
||||
<li>{"Response tracking follows RFC 5545 PARTSTAT standards"}</li>
|
||||
<li>{"Delegation and role management available after event creation"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="people-validation">
|
||||
<h6>{"Email Validation"}</h6>
|
||||
<p>{"Email addresses will be validated when you save the event. Invalid emails will be highlighted and must be corrected before proceeding."}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="attendee-roles-preview">
|
||||
<h5>{"Advanced Attendee Features"}</h5>
|
||||
<div class="role-examples">
|
||||
<div class="role-item">
|
||||
<strong>{"Required Participant:"}</strong>
|
||||
<span>{"Must attend for meeting to proceed"}</span>
|
||||
</div>
|
||||
<div class="role-item">
|
||||
<strong>{"Optional Participant:"}</strong>
|
||||
<span>{"Attendance welcome but not required"}</span>
|
||||
</div>
|
||||
<div class="role-item">
|
||||
<strong>{"Resource:"}</strong>
|
||||
<span>{"Meeting room, equipment, or facility"}</span>
|
||||
</div>
|
||||
<div class="role-item">
|
||||
<strong>{"Non-Participant:"}</strong>
|
||||
<span>{"For information only"}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="form-help-text">{"Advanced role assignment and RSVP management will be available in future versions"}</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
100
frontend/src/components/event_form/reminders.rs
Normal file
100
frontend/src/components/event_form/reminders.rs
Normal file
@@ -0,0 +1,100 @@
|
||||
use super::types::*;
|
||||
use crate::components::create_event_modal::ReminderType;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::HtmlSelectElement;
|
||||
use yew::prelude::*;
|
||||
|
||||
#[function_component(RemindersTab)]
|
||||
pub fn reminders_tab(props: &TabProps) -> Html {
|
||||
let data = &props.data;
|
||||
|
||||
let on_reminder_change = {
|
||||
let data = data.clone();
|
||||
Callback::from(move |e: Event| {
|
||||
if let Some(target) = e.target() {
|
||||
if let Ok(select) = target.dyn_into::<HtmlSelectElement>() {
|
||||
let mut event_data = (*data).clone();
|
||||
event_data.reminder = match select.value().as_str() {
|
||||
"15min" => ReminderType::Minutes15,
|
||||
"30min" => ReminderType::Minutes30,
|
||||
"1hour" => ReminderType::Hour1,
|
||||
"1day" => ReminderType::Day1,
|
||||
"2days" => ReminderType::Days2,
|
||||
"1week" => ReminderType::Week1,
|
||||
_ => ReminderType::None,
|
||||
};
|
||||
data.set(event_data);
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
html! {
|
||||
<div class="tab-panel">
|
||||
<div class="form-group">
|
||||
<label for="event-reminder-main">{"Primary Reminder"}</label>
|
||||
<select
|
||||
id="event-reminder-main"
|
||||
class="form-input"
|
||||
onchange={on_reminder_change}
|
||||
>
|
||||
<option value="none" selected={matches!(data.reminder, ReminderType::None)}>{"No reminder"}</option>
|
||||
<option value="15min" selected={matches!(data.reminder, ReminderType::Minutes15)}>{"15 minutes before"}</option>
|
||||
<option value="30min" selected={matches!(data.reminder, ReminderType::Minutes30)}>{"30 minutes before"}</option>
|
||||
<option value="1hour" selected={matches!(data.reminder, ReminderType::Hour1)}>{"1 hour before"}</option>
|
||||
<option value="1day" selected={matches!(data.reminder, ReminderType::Day1)}>{"1 day before"}</option>
|
||||
<option value="2days" selected={matches!(data.reminder, ReminderType::Days2)}>{"2 days before"}</option>
|
||||
<option value="1week" selected={matches!(data.reminder, ReminderType::Week1)}>{"1 week before"}</option>
|
||||
</select>
|
||||
<p class="form-help-text">{"Choose when you'd like to be reminded about this event"}</p>
|
||||
</div>
|
||||
|
||||
<div class="reminder-types">
|
||||
<h5>{"Reminder & Alarm Types"}</h5>
|
||||
<div class="alarm-examples">
|
||||
<div class="alarm-type">
|
||||
<strong>{"Display Alarm"}</strong>
|
||||
<p>{"Pop-up notification on your device"}</p>
|
||||
</div>
|
||||
<div class="alarm-type">
|
||||
<strong>{"Email Reminder"}</strong>
|
||||
<p>{"Email notification sent to your address"}</p>
|
||||
</div>
|
||||
<div class="alarm-type">
|
||||
<strong>{"Audio Alert"}</strong>
|
||||
<p>{"Sound notification with custom audio"}</p>
|
||||
</div>
|
||||
<div class="alarm-type">
|
||||
<strong>{"SMS/Text"}</strong>
|
||||
<p>{"Text message reminder (enterprise feature)"}</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="form-help-text">{"Multiple alarm types follow RFC 5545 VALARM standards"}</p>
|
||||
</div>
|
||||
|
||||
<div class="reminder-info">
|
||||
<h5>{"Advanced Reminder Features"}</h5>
|
||||
<ul>
|
||||
<li>{"Multiple reminders per event with different timing"}</li>
|
||||
<li>{"Custom reminder messages and descriptions"}</li>
|
||||
<li>{"Recurring reminders for recurring events"}</li>
|
||||
<li>{"Snooze and dismiss functionality"}</li>
|
||||
<li>{"Integration with system notifications"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="attachments-section">
|
||||
<h6>{"File Attachments & Documents"}</h6>
|
||||
<p>{"Future attachment features will include:"}</p>
|
||||
<ul>
|
||||
<li>{"Drag-and-drop file uploads"}</li>
|
||||
<li>{"Document preview and thumbnails"}</li>
|
||||
<li>{"Cloud storage integration (Google Drive, OneDrive)"}</li>
|
||||
<li>{"Version control for updated documents"}</li>
|
||||
<li>{"Shared access permissions for attendees"}</li>
|
||||
</ul>
|
||||
<p class="form-help-text">{"Attachment functionality will be implemented in a future release."}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
180
frontend/src/components/event_form/types.rs
Normal file
180
frontend/src/components/event_form/types.rs
Normal file
@@ -0,0 +1,180 @@
|
||||
use crate::models::ical::VEvent;
|
||||
use crate::services::calendar_service::CalendarInfo;
|
||||
use chrono::{Datelike, Local, NaiveDate, NaiveTime, TimeZone, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yew::prelude::*;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum EventStatus {
|
||||
Confirmed,
|
||||
Tentative,
|
||||
Cancelled,
|
||||
}
|
||||
|
||||
impl Default for EventStatus {
|
||||
fn default() -> Self {
|
||||
EventStatus::Confirmed
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum EventClass {
|
||||
Public,
|
||||
Private,
|
||||
Confidential,
|
||||
}
|
||||
|
||||
impl Default for EventClass {
|
||||
fn default() -> Self {
|
||||
EventClass::Public
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum ReminderType {
|
||||
None,
|
||||
Minutes15,
|
||||
Minutes30,
|
||||
Hour1,
|
||||
Day1,
|
||||
Days2,
|
||||
Week1,
|
||||
}
|
||||
|
||||
impl Default for ReminderType {
|
||||
fn default() -> Self {
|
||||
ReminderType::None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum RecurrenceType {
|
||||
None,
|
||||
Daily,
|
||||
Weekly,
|
||||
Monthly,
|
||||
Yearly,
|
||||
}
|
||||
|
||||
impl Default for RecurrenceType {
|
||||
fn default() -> Self {
|
||||
RecurrenceType::None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum ModalTab {
|
||||
BasicDetails,
|
||||
Advanced,
|
||||
People,
|
||||
Categories,
|
||||
Location,
|
||||
Reminders,
|
||||
}
|
||||
|
||||
impl Default for ModalTab {
|
||||
fn default() -> Self {
|
||||
ModalTab::BasicDetails
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub enum EditAction {
|
||||
ThisOnly,
|
||||
ThisAndFuture,
|
||||
AllInSeries,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct EventCreationData {
|
||||
// Basic event info
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub location: String,
|
||||
pub all_day: bool,
|
||||
|
||||
// Timing
|
||||
pub start_date: NaiveDate,
|
||||
pub end_date: NaiveDate,
|
||||
pub start_time: NaiveTime,
|
||||
pub end_time: NaiveTime,
|
||||
|
||||
// Classification
|
||||
pub status: EventStatus,
|
||||
pub class: EventClass,
|
||||
pub priority: Option<u8>,
|
||||
|
||||
// People
|
||||
pub organizer: String,
|
||||
pub attendees: String,
|
||||
|
||||
// Categorization
|
||||
pub categories: String,
|
||||
|
||||
// Reminders
|
||||
pub reminder: ReminderType,
|
||||
|
||||
// Recurrence
|
||||
pub recurrence: RecurrenceType,
|
||||
pub recurrence_interval: u32,
|
||||
pub recurrence_until: Option<NaiveDate>,
|
||||
pub recurrence_count: Option<u32>,
|
||||
pub recurrence_days: Vec<bool>, // [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
|
||||
|
||||
// Advanced recurrence
|
||||
pub monthly_by_day: Option<String>, // e.g., "1MO" for first Monday
|
||||
pub monthly_by_monthday: Option<u8>, // e.g., 15 for 15th day of month
|
||||
pub yearly_by_month: Vec<bool>, // [Jan, Feb, Mar, ...]
|
||||
|
||||
// Calendar selection
|
||||
pub selected_calendar: Option<String>,
|
||||
|
||||
// Edit tracking (for recurring events)
|
||||
pub edit_scope: Option<EditAction>,
|
||||
pub changed_fields: Vec<String>,
|
||||
}
|
||||
|
||||
impl Default for EventCreationData {
|
||||
fn default() -> Self {
|
||||
let now_local = Local::now();
|
||||
let start_date = now_local.date_naive();
|
||||
let start_time = NaiveTime::from_hms_opt(9, 0, 0).unwrap_or_default();
|
||||
let end_time = NaiveTime::from_hms_opt(10, 0, 0).unwrap_or_default();
|
||||
|
||||
Self {
|
||||
title: String::new(),
|
||||
description: String::new(),
|
||||
location: String::new(),
|
||||
all_day: false,
|
||||
start_date,
|
||||
end_date: start_date,
|
||||
start_time,
|
||||
end_time,
|
||||
status: EventStatus::default(),
|
||||
class: EventClass::default(),
|
||||
priority: None,
|
||||
organizer: String::new(),
|
||||
attendees: String::new(),
|
||||
categories: String::new(),
|
||||
reminder: ReminderType::default(),
|
||||
recurrence: RecurrenceType::default(),
|
||||
recurrence_interval: 1,
|
||||
recurrence_until: None,
|
||||
recurrence_count: None,
|
||||
recurrence_days: vec![false; 7],
|
||||
monthly_by_day: None,
|
||||
monthly_by_monthday: None,
|
||||
yearly_by_month: vec![false; 12],
|
||||
selected_calendar: None,
|
||||
edit_scope: None,
|
||||
changed_fields: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Common props for all tab components
|
||||
#[derive(Properties, PartialEq)]
|
||||
pub struct TabProps {
|
||||
pub data: UseStateHandle<crate::components::create_event_modal::EventCreationData>,
|
||||
pub available_calendars: Vec<CalendarInfo>,
|
||||
}
|
||||
@@ -63,7 +63,7 @@ pub fn EventModal(props: &EventModalProps) -> Html {
|
||||
html! {
|
||||
<div class="event-detail">
|
||||
<strong>{"End:"}</strong>
|
||||
<span>{format_datetime(end, event.all_day)}</span>
|
||||
<span>{format_datetime_end(end, event.all_day)}</span>
|
||||
</div>
|
||||
}
|
||||
} else {
|
||||
@@ -221,6 +221,17 @@ fn format_datetime(dt: &DateTime<Utc>, all_day: bool) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn format_datetime_end(dt: &DateTime<Utc>, all_day: bool) -> String {
|
||||
if all_day {
|
||||
// For all-day events, subtract one day from end date for display
|
||||
// RFC-5545 uses exclusive end dates, but users expect inclusive display
|
||||
let display_date = *dt - chrono::Duration::days(1);
|
||||
display_date.format("%B %d, %Y").to_string()
|
||||
} else {
|
||||
dt.format("%B %d, %Y at %I:%M %p").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn format_recurrence_rule(rrule: &str) -> String {
|
||||
// Basic parsing of RRULE to display user-friendly text
|
||||
if rrule.contains("FREQ=DAILY") {
|
||||
|
||||
@@ -5,7 +5,9 @@ pub mod calendar_list_item;
|
||||
pub mod context_menu;
|
||||
pub mod create_calendar_modal;
|
||||
pub mod create_event_modal;
|
||||
pub mod create_event_modal_v2;
|
||||
pub mod event_context_menu;
|
||||
pub mod event_form;
|
||||
pub mod event_modal;
|
||||
pub mod login;
|
||||
pub mod month_view;
|
||||
@@ -23,6 +25,11 @@ pub use create_calendar_modal::CreateCalendarModal;
|
||||
pub use create_event_modal::{
|
||||
CreateEventModal, EventClass, EventCreationData, EventStatus, RecurrenceType, ReminderType,
|
||||
};
|
||||
pub use create_event_modal_v2::CreateEventModalV2;
|
||||
pub use event_form::{
|
||||
EventClass as EventFormClass, EventCreationData as EventFormData, EventStatus as EventFormStatus,
|
||||
RecurrenceType as EventFormRecurrenceType, ReminderType as EventFormReminderType,
|
||||
};
|
||||
pub use event_context_menu::{DeleteAction, EditAction, EventContextMenu};
|
||||
pub use event_modal::EventModal;
|
||||
pub use login::Login;
|
||||
|
||||
@@ -347,11 +347,26 @@ pub fn week_view(props: &WeekViewProps) -> Html {
|
||||
})
|
||||
};
|
||||
|
||||
let oncontextmenu = {
|
||||
if let Some(callback) = &props.on_event_context_menu {
|
||||
let callback = callback.clone();
|
||||
let event = (*event).clone();
|
||||
Some(Callback::from(move |e: web_sys::MouseEvent| {
|
||||
e.prevent_default();
|
||||
e.stop_propagation(); // Prevent calendar context menu from also triggering
|
||||
callback.emit((e, event.clone()));
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
html! {
|
||||
<div
|
||||
class="all-day-event"
|
||||
style={format!("background-color: {}", event_color)}
|
||||
{onclick}
|
||||
{oncontextmenu}
|
||||
>
|
||||
<span class="all-day-event-title">
|
||||
{event.summary.as_ref().unwrap_or(&"Untitled".to_string())}
|
||||
|
||||
@@ -439,9 +439,17 @@ impl CalendarService {
|
||||
let mut occurrence_event = base_event.clone();
|
||||
occurrence_event.dtstart = occurrence_datetime;
|
||||
occurrence_event.dtstamp = chrono::Utc::now(); // Update DTSTAMP for each occurrence
|
||||
|
||||
|
||||
if let Some(end) = base_event.dtend {
|
||||
occurrence_event.dtend = Some(end + Duration::days(days_diff));
|
||||
if let Some(base_end) = base_event.dtend {
|
||||
if base_event.all_day {
|
||||
// For all-day events, maintain the RFC-5545 end date pattern
|
||||
// End date should always be exactly one day after start date
|
||||
occurrence_event.dtend = Some(occurrence_datetime + Duration::days(1));
|
||||
} else {
|
||||
// For timed events, preserve the original duration
|
||||
occurrence_event.dtend = Some(base_end + Duration::days(days_diff));
|
||||
}
|
||||
}
|
||||
|
||||
occurrences.push(occurrence_event);
|
||||
|
||||
Reference in New Issue
Block a user