From 8145924b37670905de5999ce66a3b1c367270994 Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Tue, 30 Jun 2026 09:07:01 +0200 Subject: [PATCH 1/3] Add clear button to calendar drawer --- app/qml/form/components/MMCalendarDrawer.qml | 20 +++++++++++++++++++ app/qml/form/editors/MMFormCalendarEditor.qml | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/app/qml/form/components/MMCalendarDrawer.qml b/app/qml/form/components/MMCalendarDrawer.qml index 5e804dfae..0134574df 100644 --- a/app/qml/form/components/MMCalendarDrawer.qml +++ b/app/qml/form/components/MMCalendarDrawer.qml @@ -24,11 +24,31 @@ MMComponents.MMDrawer { property bool showSeconds: false signal primaryButtonClicked + signal clearButtonClicked dim: true drawerHeader.title: root.title + drawerHeader.topLeftItemContent: [ + MMComponents.MMButton { + text: qsTr("Clear") + type: MMComponents.MMButton.Types.Tertiary + size: MMComponents.MMButton.Sizes.Small + + anchors { + left: parent.left + leftMargin: __style.pageMargins + __style.safeAreaLeft + verticalCenter: parent.verticalCenter + } + + onClicked: { + root.clearButtonClicked() + root.close() + } + } + ] + drawerContent: Item { width: parent.width height: scrollView.height diff --git a/app/qml/form/editors/MMFormCalendarEditor.qml b/app/qml/form/editors/MMFormCalendarEditor.qml index 12632ac49..d63e1d705 100644 --- a/app/qml/form/editors/MMFormCalendarEditor.qml +++ b/app/qml/form/editors/MMFormCalendarEditor.qml @@ -105,6 +105,10 @@ MMPrivateComponents.MMBaseSingleLineInput { root.newDateSelected( dateTime ) } + onClearButtonClicked: { + root.editorValueChanged( root._fieldValue, true ) + } + onClosed: dateTimeDrawerLoader.active = false Component.onCompleted: open() From d76002c4353bf1972322148d7ba1a847cfcc0659 Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Tue, 30 Jun 2026 16:09:15 +0200 Subject: [PATCH 2/3] Fix clearing calendar field causing runtime error --- app/qml/form/editors/MMFormCalendarEditor.qml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/qml/form/editors/MMFormCalendarEditor.qml b/app/qml/form/editors/MMFormCalendarEditor.qml index d63e1d705..916a0143a 100644 --- a/app/qml/form/editors/MMFormCalendarEditor.qml +++ b/app/qml/form/editors/MMFormCalendarEditor.qml @@ -96,7 +96,7 @@ MMPrivateComponents.MMBaseSingleLineInput { id: dateTimeDrawer title: root._fieldTitle - dateTime: root._fieldValueIsNull || root._fieldHasMixedValues ? new Date() : dateTransformer.toJsDate( root._fieldValue ) + dateTime: root.hasValidFieldValue() ? new Date() : dateTransformer.toJsDate( root._fieldValue ) hasDatePicker: root.includesDate hasTimePicker: root.includesTime showSeconds: root.showSeconds @@ -126,6 +126,13 @@ MMPrivateComponents.MMBaseSingleLineInput { } } + function hasValidFieldValue() { + return root._fieldValueIsNull + || root._fieldHasMixedValues + || root._fieldValue === undefined + || root._fieldValue === null + } + QtObject { id: dateTransformer // When changing this function, test with various timezones! From a5552f802f39823d61b563405afa9b3f786642c7 Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Tue, 30 Jun 2026 17:29:17 +0200 Subject: [PATCH 3/3] Add hide calendar clear button for empty values feature --- app/qml/form/components/MMCalendarDrawer.qml | 16 ++++++---------- app/qml/form/editors/MMFormCalendarEditor.qml | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/qml/form/components/MMCalendarDrawer.qml b/app/qml/form/components/MMCalendarDrawer.qml index 0134574df..d06a756c0 100644 --- a/app/qml/form/components/MMCalendarDrawer.qml +++ b/app/qml/form/components/MMCalendarDrawer.qml @@ -22,6 +22,7 @@ MMComponents.MMDrawer { property alias hasDatePicker: dateTimePicker.hasDatePicker property alias hasTimePicker: dateTimePicker.hasTimePicker property bool showSeconds: false + property bool fieldValueIsNull: true signal primaryButtonClicked signal clearButtonClicked @@ -30,24 +31,19 @@ MMComponents.MMDrawer { drawerHeader.title: root.title - drawerHeader.topLeftItemContent: [ + drawerHeader.topLeftItem.visible: !root.fieldValueIsNull + drawerHeader.topLeftItemContent: MMComponents.MMButton { text: qsTr("Clear") - type: MMComponents.MMButton.Types.Tertiary - size: MMComponents.MMButton.Sizes.Small - - anchors { - left: parent.left - leftMargin: __style.pageMargins + __style.safeAreaLeft - verticalCenter: parent.verticalCenter - } + type: MMButton.Types.Tertiary + fontColor: __style.darkGreyColor + fontColorHover: __style.nightColor onClicked: { root.clearButtonClicked() root.close() } } - ] drawerContent: Item { width: parent.width diff --git a/app/qml/form/editors/MMFormCalendarEditor.qml b/app/qml/form/editors/MMFormCalendarEditor.qml index 916a0143a..fb1025f94 100644 --- a/app/qml/form/editors/MMFormCalendarEditor.qml +++ b/app/qml/form/editors/MMFormCalendarEditor.qml @@ -100,6 +100,7 @@ MMPrivateComponents.MMBaseSingleLineInput { hasDatePicker: root.includesDate hasTimePicker: root.includesTime showSeconds: root.showSeconds + fieldValueIsNull: root._fieldValueIsNull onPrimaryButtonClicked: { root.newDateSelected( dateTime )