Add a 'days with events' preference (default 3, range 1-7) that drives the upcoming events widget, and extend the fetch window to 8 days so the largest window can populate. Add a Calendar settings pane (moved under Integrations) that lists the connected CalDAV/ICS sources in a two-column grid with add/edit/remove, and remove calendars from Manage Integrations. Turn the modal service into a stack so add/edit forms open on top of the settings dialog, with one dialog per level, per-entry title ids, and a softened stacked backdrop. Move CALENDAR_ACTOR into its own config module to break the calendar/caldav/ics import cycle.
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
import Service from '@ember/service';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
// Holds the open modals as a stack. `open` pushes (so a form can sit on top of
|
|
// the settings dialog), `replace` swaps the top, and `close`/`finished` pop.
|
|
// Descriptors keep their identity so callers can compare them.
|
|
export default class ModalService extends Service {
|
|
@tracked stack = [];
|
|
|
|
get current() {
|
|
return this.stack.at(-1) ?? null;
|
|
}
|
|
|
|
open(descriptor) {
|
|
this.stack = [...this.stack, descriptor];
|
|
}
|
|
|
|
replace(descriptor) {
|
|
if (this.stack.length === 0) {
|
|
this.open(descriptor);
|
|
return;
|
|
}
|
|
|
|
this.stack = [...this.stack.slice(0, -1), descriptor];
|
|
}
|
|
|
|
close() {
|
|
this.stack = this.stack.slice(0, -1);
|
|
}
|
|
|
|
// Called when a dialog fires its `close` event. Removes that exact entry so
|
|
// closing a lower dialog does not pop a higher one. Idempotent.
|
|
finished(descriptor) {
|
|
if (!descriptor) {
|
|
this.stack = [];
|
|
return;
|
|
}
|
|
|
|
this.stack = this.stack.filter((entry) => entry !== descriptor);
|
|
}
|
|
}
|