Commit 006de4d0 authored by Karel Slaný's avatar Karel Slaný Committed by Martin Straka

CalendarDialogue is member of PageGovService.

parent 50c23090
......@@ -22,7 +22,6 @@
*/
import QtGraphicalEffects 1.0
import QtQml 2.0 // Date
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
......@@ -32,6 +31,8 @@ ScrollableListView {
id: root
delegateHeight: listItemHeight
signal calendarClicked(int index, string dateKey, string dateVal, string dateDescr)
/*
* Return asterisks.
*/
......@@ -52,17 +53,6 @@ ScrollableListView {
enabled: gsUserInput
color: enabled ? datovkaPalette.base : readBgColor
/* Makes date selection easier. */
CalendarDialogue {
id: calendarDialogue
onFinished: {
var locale = Qt.locale()
textField.text = selectedDate.toLocaleDateString(locale, "yyyy-MM-dd")
root.model.setProperty(index, "gsVal", textField.text)
}
}
Item {
anchors.fill: parent
anchors.margins: defaultMargin
......@@ -114,11 +104,7 @@ ScrollableListView {
accessibleName: qsTr("Open calendar")
visible: gsTypeDate
onClicked: {
var locale = Qt.locale()
var today = new Date()
var tomorow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000)
var filledDate = Date.fromLocaleDateString(locale, textField.text, "yyyy-MM-dd")
calendarDialogue.openCalendarDialogue(filledDate, today, "Select date", gsDescr, root.parent)
calendarClicked(index, gsKey, gsVal, gsDescr)
}
}
} // Row
......
......@@ -32,7 +32,9 @@ import cz.nic.mobileDatovka 1.0
Dialog {
id: root
signal finished(date selectedDate)
property var fieldIndex: null
signal finished(int index, date selectedDate)
property int minimumInputSize: parent.width / 2
......@@ -40,7 +42,7 @@ Dialog {
return d instanceof Date && !isNaN(d);
}
function openCalendarDialogue(selDate, maxDate, title, text, parentElement) {
function openCalendarDialogue(index, selDate, maxDate, title, text, parentElement) {
// https://stackoverflow.com/questions/44128131/default-arguments-for-qml-function-gives-syntax-errors
if (parentElement === undefined) {
parentElement = null
......@@ -50,12 +52,13 @@ Dialog {
rootText.text = text
root.open()
if (isValidDate(maxDate)) {
calendar.maximumDate = maxDate
}
root.fieldIndex = index
if (isValidDate(selDate)) {
calendar.selectedDate = selDate
}
if (isValidDate(maxDate)) {
calendar.maximumDate = maxDate
}
if (parentElement === null) {
// root.x = root.parent.width / 2 - width / 2
......@@ -96,6 +99,6 @@ Dialog {
}
} // ColumnLayout
onAccepted: finished(calendar.selectedDate)
onAccepted: finished(fieldIndex, calendar.selectedDate)
// onRejected:
}
......@@ -24,6 +24,7 @@
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import QtQml 2.0 // Date
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.models 1.0
......@@ -59,6 +60,17 @@ Item {
}
}
/* Makes date selection easier. */
CalendarDialogue {
id: calendarDialogue
onFinished: {
var locale = Qt.locale()
var value = selectedDate.toLocaleDateString(locale, "yyyy-MM-dd")
govFormModel.setProperty(index, "gsVal", value)
}
}
PageHeader {
id: headerBar
title: qsTr("Service:") + " " + gsInternId
......@@ -149,6 +161,13 @@ Item {
onCountChanged: {
emptyList.visible = (formList.count === 0)
}
onCalendarClicked: {
var locale = Qt.locale()
var today = new Date()
var tomorow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000)
var filledDate = Date.fromLocaleDateString(locale, dateVal, "yyyy-MM-dd")
calendarDialogue.openCalendarDialogue(index, filledDate, today, "Select date", dateDescr)
}
}
Connections {
target: isds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment