2024-08-16 21:35:12 +02:00
|
|
|
import { Date, Time } from "std-widgets.slint";
|
2024-10-29 15:02:46 +01:00
|
|
|
import { CalendarDay } from "components/Calendar.slint";
|
2024-08-16 21:35:12 +02:00
|
|
|
|
2024-10-09 17:07:17 +02:00
|
|
|
export struct NewTaskData {
|
|
|
|
sourceId: int,
|
|
|
|
eventId: int,
|
|
|
|
title: string,
|
|
|
|
scheduled: bool,
|
|
|
|
date: Date
|
|
|
|
}
|
2024-08-16 21:35:12 +02:00
|
|
|
|
2024-10-09 17:07:17 +02:00
|
|
|
export struct SaveTaskData {
|
|
|
|
sourceId: int,
|
|
|
|
id: int,
|
|
|
|
title: string,
|
|
|
|
scheduled: bool,
|
|
|
|
date: Date,
|
|
|
|
}
|
|
|
|
|
|
|
|
export struct NewEventParams {
|
|
|
|
sourceId: int,
|
|
|
|
title: string,
|
|
|
|
date: Date,
|
|
|
|
startsAt: Time,
|
|
|
|
endsAt: Time
|
|
|
|
}
|
|
|
|
|
|
|
|
export struct SaveEventParams {
|
|
|
|
sourceId: int,
|
|
|
|
id: int,
|
|
|
|
title: string,
|
|
|
|
date: Date,
|
|
|
|
startsAt: Time,
|
|
|
|
endsAt: Time
|
|
|
|
}
|
|
|
|
|
2024-11-01 13:43:45 +01:00
|
|
|
export struct AddSourceParam {
|
|
|
|
name: string,
|
|
|
|
type: string,
|
|
|
|
path: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export struct ModifySourceParam {
|
|
|
|
id: int,
|
|
|
|
name: string,
|
|
|
|
path: string
|
|
|
|
}
|
|
|
|
|
2024-10-09 17:07:17 +02:00
|
|
|
export struct Source {
|
2024-11-01 13:43:45 +01:00
|
|
|
id: int,
|
2024-10-09 17:07:17 +02:00
|
|
|
name: string,
|
2024-10-29 15:02:46 +01:00
|
|
|
selected: bool,
|
|
|
|
path: string
|
2024-10-09 17:07:17 +02:00
|
|
|
}
|
2024-08-16 21:35:12 +02:00
|
|
|
|
|
|
|
export struct TaskData {
|
|
|
|
sourceId: int,
|
2024-11-01 13:43:45 +01:00
|
|
|
eventId: int,
|
2024-08-16 21:35:12 +02:00
|
|
|
id: int,
|
|
|
|
title: string,
|
2024-11-01 13:43:45 +01:00
|
|
|
date: Date,
|
2024-08-16 21:35:12 +02:00
|
|
|
checked: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export struct Event {
|
|
|
|
sourceId: int,
|
|
|
|
id: int,
|
|
|
|
title: string,
|
|
|
|
startsAt: Time,
|
|
|
|
endsAt: Time,
|
|
|
|
tasks: [TaskData],
|
|
|
|
}
|
|
|
|
|
|
|
|
export struct Day {
|
|
|
|
sourceId: int,
|
|
|
|
id: int,
|
|
|
|
date: Date,
|
|
|
|
events: [Event],
|
|
|
|
tasks: [TaskData],
|
|
|
|
isLate: bool,
|
2024-10-08 17:05:52 +02:00
|
|
|
isToday: bool,
|
|
|
|
relativeDaysDiff: int
|
2024-08-16 21:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct OpenNewTaskFormParams {
|
|
|
|
eventSourceId: int,
|
|
|
|
eventId: int,
|
|
|
|
}
|
|
|
|
|
|
|
|
export global Backend {
|
2024-10-09 17:07:17 +02:00
|
|
|
in-out property<[Source]> sources-selected;
|
2024-10-15 11:55:39 +02:00
|
|
|
in-out property<int> default-source-index;
|
2024-09-02 11:52:06 +02:00
|
|
|
in-out property<[string]> sources;
|
2024-10-09 17:07:17 +02:00
|
|
|
in-out property<bool> no-source-selected;
|
2024-08-16 21:35:12 +02:00
|
|
|
in-out property<[string]> tags;
|
2024-10-15 16:41:22 +02:00
|
|
|
in-out property<[Day]> days;
|
2024-10-29 15:02:46 +01:00
|
|
|
in-out property<[CalendarDay]> calendar;
|
2024-10-08 16:36:01 +02:00
|
|
|
in-out property<[TaskData]> unscheduled-tasks;
|
2024-08-16 21:35:12 +02:00
|
|
|
|
2024-10-15 16:41:22 +02:00
|
|
|
callback task-clicked(int, int);
|
|
|
|
callback source-clicked(int);
|
|
|
|
callback tag-clicked(int);
|
2024-10-29 15:02:46 +01:00
|
|
|
callback settings-clicked();
|
2024-11-01 13:43:45 +01:00
|
|
|
callback add-source-clicked();
|
|
|
|
callback edit-source-clicked(int);
|
2024-08-16 21:35:12 +02:00
|
|
|
|
2024-10-15 16:41:22 +02:00
|
|
|
callback open-new-task-form(OpenNewTaskFormParams);
|
|
|
|
callback open-edit-task-form(int, int);
|
|
|
|
callback open-new-event-form();
|
|
|
|
callback open-edit-event-form(int, int);
|
|
|
|
callback toggle-show-completed-tasks();
|
|
|
|
callback delete-task-clicked(int, int);
|
|
|
|
callback delete-event-clicked(int, int);
|
2024-08-16 21:35:12 +02:00
|
|
|
|
2024-10-15 16:41:22 +02:00
|
|
|
callback create-task(NewTaskData);
|
|
|
|
callback save-task(SaveTaskData);
|
|
|
|
callback create-event(NewEventParams);
|
|
|
|
callback save-event(SaveEventParams);
|
2024-10-09 17:07:17 +02:00
|
|
|
|
2024-11-01 13:43:45 +01:00
|
|
|
callback add-source(AddSourceParam);
|
|
|
|
callback modify-source(ModifySourceParam);
|
|
|
|
callback delete-source(int);
|
|
|
|
|
|
|
|
// Utils
|
2024-10-15 16:41:22 +02:00
|
|
|
pure callback format-date(Date) -> string;
|
2024-10-29 15:02:46 +01:00
|
|
|
pure callback format-date-relative(Date) -> string;
|
|
|
|
pure callback capitalize-string(string) -> string;
|
2024-08-16 21:35:12 +02:00
|
|
|
}
|