2024-08-16 21:35:12 +02:00
|
|
|
import { Date, ComboBox } from "std-widgets.slint";
|
|
|
|
import { VTextInput, VButton, VDatePicker, VText, Palette } from "@vynui";
|
|
|
|
import { Backend } from "../Backend.slint";
|
|
|
|
|
|
|
|
export struct NewTaskData {
|
|
|
|
sourceId: int,
|
|
|
|
eventId: int,
|
|
|
|
title: string,
|
|
|
|
date: Date
|
|
|
|
}
|
|
|
|
|
|
|
|
export struct SaveTaskData {
|
|
|
|
sourceId: int,
|
|
|
|
id: int,
|
|
|
|
title: string,
|
|
|
|
date: Date,
|
|
|
|
}
|
|
|
|
|
2024-09-02 11:52:06 +02:00
|
|
|
export component TaskWindow inherits Window {
|
2024-08-16 21:35:12 +02:00
|
|
|
title: "Mirai - " + (taskId == -1 ? "New task" : "Edit task");
|
|
|
|
min-width: 100px;
|
|
|
|
max-width: 1920px;
|
|
|
|
preferred-width: 512px;
|
|
|
|
min-height: 100px;
|
|
|
|
max-height: 4000px;
|
|
|
|
default-font-size: 16px;
|
|
|
|
background: Palette.background;
|
|
|
|
|
|
|
|
in-out property<int> taskId: -1;
|
|
|
|
in-out property<int> eventId: -1;
|
|
|
|
in-out property<Date> taskDate <=> taskDateInput.date;
|
|
|
|
in-out property<string> taskTitle <=> taskTitleInput.text;
|
2024-09-02 11:52:06 +02:00
|
|
|
in-out property<int> taskSourceIndex <=> sourceInput.current-index;
|
2024-08-16 21:35:12 +02:00
|
|
|
|
|
|
|
callback create(NewTaskData);
|
|
|
|
callback save(SaveTaskData);
|
|
|
|
|
|
|
|
VerticalLayout {
|
|
|
|
padding: 16px;
|
|
|
|
spacing: 8px;
|
|
|
|
VText {
|
|
|
|
text: taskId == -1 ? "New task" : "Edit task";
|
|
|
|
}
|
|
|
|
|
2024-09-02 11:52:06 +02:00
|
|
|
sourceInput := ComboBox {
|
|
|
|
model: Backend.sources;
|
2024-08-16 21:35:12 +02:00
|
|
|
enabled: taskId == -1 && eventId == -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
taskTitleInput := VTextInput {
|
|
|
|
label: "Content";
|
|
|
|
wrap: word-wrap;
|
|
|
|
accepted => { button.clicked() }
|
|
|
|
}
|
|
|
|
|
|
|
|
taskDateInput := VDatePicker {
|
|
|
|
label: "Date";
|
|
|
|
enabled: eventId == -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
button := VButton {
|
|
|
|
text: taskId == -1 ? "Create" : "Save";
|
|
|
|
clicked => {
|
|
|
|
if (taskId == -1) {
|
|
|
|
create({
|
2024-09-02 11:52:06 +02:00
|
|
|
sourceId: taskSourceIndex,
|
2024-08-16 21:35:12 +02:00
|
|
|
eventId: eventId,
|
|
|
|
title: taskTitle,
|
|
|
|
date: taskDate,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
save({
|
2024-09-02 11:52:06 +02:00
|
|
|
sourceId: taskSourceIndex,
|
2024-08-16 21:35:12 +02:00
|
|
|
id: taskId,
|
|
|
|
title: taskTitle,
|
|
|
|
date: taskDate,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export { Backend }
|