Add Source creation/edition + Add missing edit forms for tasks and events

This commit is contained in:
Vyn 2024-11-01 13:43:45 +01:00
parent f1ac8a42d1
commit a15c23bb21
24 changed files with 358 additions and 205 deletions

View file

@ -1,11 +1,13 @@
import { Backend, TaskData, Event } from "../Backend.slint";
import { ScrollView } from "std-widgets.slint";
import { VCheckBox, VButton, VActionButton, Svg, VTag, VPopupIconMenu, VText, Palette } from "@selenite";
import { VCheckBox, VTextInput, VButton, VActionButton, Svg, VTag, VPopupIconMenu, VText, Palette } from "@selenite";
import { TaskLine } from "./TaskLine.slint";
import { Utils } from "../Utils.slint";
export component EventGroup {
in property<Event> event;
private property <bool> show-add-task: false;
private property <bool> edit-name: false;
eventPopup := VPopupIconMenu {
VActionButton {
@ -13,17 +15,16 @@ export component EventGroup {
icon-colorize: Colors.greenyellow;
icon-size: 1.5rem;
border-radius: 0;
clicked => { Backend.open-new-task-form({
eventSourceId: event.sourceId,
eventId: event.id,
})}
clicked => {
root.show-add-task = true;
}
}
VActionButton {
icon-svg: Svg.pen;
icon-colorize: Colors.grey;
icon-size: 1.5rem;
border-radius: 0;
clicked => { Backend.open-edit-event-form(event.sourceId, event.id) }
clicked => { edit-name = true; }
}
VActionButton {
@ -48,15 +49,14 @@ export component EventGroup {
spacing: 4px;
VText {
text: Utils.time-to-string(event.startsAt);
horizontal-alignment: center;
color: Palette.accent;
}
HorizontalLayout {
alignment: center;
Rectangle {
width: 4px;
width: 2px;
background: Palette.accent;
border-radius: 8px;
}
}
VText {
@ -72,10 +72,24 @@ export component EventGroup {
padding-top: 32px;
padding-bottom: 32px;
padding-right: 0px;
VText {
if !edit-name : VText {
text: event.title;
font-size: 1.1rem;
}
if edit-name : title := VTextInput {
text: event.title;
accepted => {
Backend.save-event({
sourceId: event.sourceId,
id: event.id,
title: title.text,
//date: event.date,
startsAt: event.startsAt,
endsAt: event.endsAt,
});
root.edit-name = false;
}
}
for task[taskIndex] in event.tasks: VerticalLayout {
padding-top: taskIndex == 0 ? 16px : 0px;
padding-bottom: 8px;
@ -85,6 +99,16 @@ export component EventGroup {
task-index: task.id;
}
}
if show-add-task : taskInput := VTextInput {
accepted => {
Backend.create-task({
sourceId: event.sourceId,
eventId: event.id,
title: taskInput.text,
});
root.show-add-task = false;
}
}
}
}