Add create/modify button when creating/editing a task

This commit is contained in:
Vyn 2024-10-17 14:38:55 +02:00
parent e2b0c1ac74
commit 3650ddaccc
6 changed files with 69 additions and 39 deletions

View file

@ -1,6 +1,6 @@
import { Backend, TaskData } from "../Backend.slint";
import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Palette } from "@selenite";
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@selenite";
import { NewTaskData, SaveTaskData } from "../Backend.slint";
export component TaskEdit inherits VerticalLayout {
@ -16,9 +16,20 @@ export component TaskEdit inherits VerticalLayout {
}
callback accepted(SaveTaskData);
if !should-show : Rectangle {}
if should-show : Rectangle {
function modify() {
root.accepted({
id: task.id,
sourceId: task.sourceId,
title: newTaskTitleInput.text,
scheduled: taskDateInput.date.year != 0,
date: taskDateInput.date
});
}
background: Palette.background;
border-radius: 8px;
VerticalLayout {
@ -27,16 +38,7 @@ export component TaskEdit inherits VerticalLayout {
newTaskTitleInput := VTextInput {
text: root.task.title;
accepted => {
root.accepted({
id: task.id,
sourceId: task.sourceId,
title: newTaskTitleInput.text,
scheduled: taskDateInput.date.year != 0,
date: taskDateInput.date
});
}
accepted => { modify() }
}
HorizontalLayout {
alignment: start;
@ -45,6 +47,12 @@ export component TaskEdit inherits VerticalLayout {
date: task.date;
enabled: true;
}
VButton {
text: "Modify";
icon-svg: Svg.correct;
icon-colorize: greenyellow;
clicked => { modify() }
}
}
}
}