Some checks failed
Build and Push Docker Image / docker (push) Failing after 1m7s
Moved event fetching logic from CalendarView to Calendar component to properly use the visible date range instead of hardcoded current month. The Calendar component already tracks the current visible date through navigation, so events now load correctly for August and other months when navigating. Changes: - Calendar component now manages its own events state and fetching - Event fetching responds to current_date changes from navigation - CalendarView simplified to just render Calendar component - Fixed cargo fmt/clippy formatting across codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
123 lines
4.0 KiB
Rust
123 lines
4.0 KiB
Rust
use crate::models::ical::VEvent;
|
|
use web_sys::MouseEvent;
|
|
use yew::prelude::*;
|
|
|
|
#[derive(Clone, PartialEq, Debug)]
|
|
pub enum DeleteAction {
|
|
DeleteThis,
|
|
DeleteFollowing,
|
|
DeleteSeries,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Debug)]
|
|
pub enum EditAction {
|
|
EditThis,
|
|
EditFuture,
|
|
EditAll,
|
|
}
|
|
|
|
#[derive(Properties, PartialEq)]
|
|
pub struct EventContextMenuProps {
|
|
pub is_open: bool,
|
|
pub x: i32,
|
|
pub y: i32,
|
|
pub event: Option<VEvent>,
|
|
pub on_edit: Callback<EditAction>,
|
|
pub on_delete: Callback<DeleteAction>,
|
|
pub on_close: Callback<()>,
|
|
}
|
|
|
|
#[function_component(EventContextMenu)]
|
|
pub fn event_context_menu(props: &EventContextMenuProps) -> Html {
|
|
let menu_ref = use_node_ref();
|
|
|
|
if !props.is_open {
|
|
return html! {};
|
|
}
|
|
|
|
let style = format!(
|
|
"position: fixed; left: {}px; top: {}px; z-index: 1001;",
|
|
props.x, props.y
|
|
);
|
|
|
|
// Check if the event is recurring
|
|
let is_recurring = props
|
|
.event
|
|
.as_ref()
|
|
.map(|event| event.rrule.is_some())
|
|
.unwrap_or(false);
|
|
|
|
let create_edit_callback = |action: EditAction| {
|
|
let on_edit = props.on_edit.clone();
|
|
let on_close = props.on_close.clone();
|
|
Callback::from(move |_: MouseEvent| {
|
|
on_edit.emit(action.clone());
|
|
on_close.emit(());
|
|
})
|
|
};
|
|
|
|
let create_delete_callback = |action: DeleteAction| {
|
|
let on_delete = props.on_delete.clone();
|
|
let on_close = props.on_close.clone();
|
|
Callback::from(move |_: MouseEvent| {
|
|
on_delete.emit(action.clone());
|
|
on_close.emit(());
|
|
})
|
|
};
|
|
|
|
html! {
|
|
<div
|
|
ref={menu_ref}
|
|
class="context-menu"
|
|
style={style}
|
|
>
|
|
{
|
|
if is_recurring {
|
|
html! {
|
|
<>
|
|
<div class="context-menu-item" onclick={create_edit_callback(EditAction::EditThis)}>
|
|
{"Edit This Event"}
|
|
</div>
|
|
<div class="context-menu-item" onclick={create_edit_callback(EditAction::EditFuture)}>
|
|
{"Edit This and Future Events"}
|
|
</div>
|
|
<div class="context-menu-item" onclick={create_edit_callback(EditAction::EditAll)}>
|
|
{"Edit All Events in Series"}
|
|
</div>
|
|
</>
|
|
}
|
|
} else {
|
|
html! {
|
|
<div class="context-menu-item" onclick={create_edit_callback(EditAction::EditThis)}>
|
|
{"Edit Event"}
|
|
</div>
|
|
}
|
|
}
|
|
}
|
|
{
|
|
if is_recurring {
|
|
html! {
|
|
<>
|
|
<div class="context-menu-item context-menu-delete" onclick={create_delete_callback(DeleteAction::DeleteThis)}>
|
|
{"Delete This Event"}
|
|
</div>
|
|
<div class="context-menu-item context-menu-delete" onclick={create_delete_callback(DeleteAction::DeleteFollowing)}>
|
|
{"Delete Following Events"}
|
|
</div>
|
|
<div class="context-menu-item context-menu-delete" onclick={create_delete_callback(DeleteAction::DeleteSeries)}>
|
|
{"Delete Entire Series"}
|
|
</div>
|
|
</>
|
|
}
|
|
} else {
|
|
html! {
|
|
<div class="context-menu-item context-menu-delete" onclick={create_delete_callback(DeleteAction::DeleteThis)}>
|
|
{"Delete Event"}
|
|
</div>
|
|
}
|
|
}
|
|
}
|
|
</div>
|
|
}
|
|
}
|