2024-04-10 16:53:18 +02:00
|
|
|
/*
|
|
|
|
* Mirai. Copyright (C) 2024 Vyn
|
|
|
|
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
|
|
|
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Window
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import Mirai
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: form
|
|
|
|
property var taskToEdit
|
|
|
|
property int taskToEditIndex
|
|
|
|
spacing: 6
|
|
|
|
signal confirmed
|
|
|
|
|
|
|
|
onTaskToEditChanged: {
|
2024-04-11 11:42:13 +02:00
|
|
|
newTodoContent.text = taskToEdit?.rawFormat ?? "- [ ] "
|
2024-04-10 16:53:18 +02:00
|
|
|
newTodoDate.text = taskToEdit?.date ?? ""
|
|
|
|
}
|
|
|
|
|
|
|
|
AppText {
|
|
|
|
text: "New task"
|
|
|
|
}
|
|
|
|
|
|
|
|
AppLineEdit {
|
|
|
|
id: newTodoContent
|
|
|
|
Layout.fillWidth: true
|
|
|
|
placeholderText: "Enter your new task..."
|
2024-04-11 11:42:13 +02:00
|
|
|
text: taskToEdit?.rawFormat ?? ""
|
2024-04-10 16:53:18 +02:00
|
|
|
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
if (newTodoContent.text == "") {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (taskToEdit && taskToEditIndex !== undefined) {
|
2024-04-11 11:42:13 +02:00
|
|
|
backend.updateTodoFromRawFormat(taskToEditIndex, newTodoContent.text, newTodoDate.text)
|
2024-04-10 16:53:18 +02:00
|
|
|
} else {
|
2024-04-11 11:42:13 +02:00
|
|
|
backend.addTodoFromRawFormat(newTodoContent.text, newTodoDate.text)
|
2024-04-10 16:53:18 +02:00
|
|
|
}
|
|
|
|
form.confirmed()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DateField {
|
|
|
|
id: newTodoDate
|
|
|
|
text: taskToEdit?.date ?? ""
|
|
|
|
textFieldComponent.placeholderText: "No date"
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|