Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/qml/form/components/MMCalendarDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,27 @@ MMComponents.MMDrawer {
property alias hasDatePicker: dateTimePicker.hasDatePicker
property alias hasTimePicker: dateTimePicker.hasTimePicker
property bool showSeconds: false
property bool showClearButton: true

signal primaryButtonClicked
signal clearButtonClicked
Comment thread
xkello marked this conversation as resolved.

dim: true

drawerHeader.title: root.title
drawerHeader.topLeftItem.visible: !root.showClearButton

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the logic of visibility is opposite to the naming of the variable, it should match

drawerHeader.topLeftItemContent:
MMComponents.MMButton {
text: qsTr("Clear")
type: MMButton.Types.Tertiary
fontColor: __style.darkGreyColor
fontColorHover: __style.nightColor

onClicked: {
Comment thread
xkello marked this conversation as resolved.
root.clearButtonClicked()
root.close()
}
}

drawerContent: Item {
width: parent.width
Expand Down
13 changes: 12 additions & 1 deletion app/qml/form/editors/MMFormCalendarEditor.qml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you as well purge the openCalendar() method only keep forceActiveFocus() and then from openPicker() take the contents and put everything in openCalendar(). Remove openPicker()

Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,20 @@ 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
showClearButton: root._fieldValueIsNull

onPrimaryButtonClicked: {
root.newDateSelected( dateTime )
}

onClearButtonClicked: {
root.editorValueChanged( undefined, true )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason we can't use null? If not then let's prefer using null

}

onClosed: dateTimeDrawerLoader.active = false

Component.onCompleted: open()
Expand All @@ -122,6 +127,12 @@ MMPrivateComponents.MMBaseSingleLineInput {
}
}

function hasValidFieldValue() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make more sense to call it invalid values

return root._fieldValueIsNull
|| root._fieldHasMixedValues
|| (root._fieldValue ?? null) === null

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|| (root._fieldValue ?? null) === null
|| root._fieldValue ?? true

this should be the same

}

QtObject {
id: dateTransformer
// When changing this function, test with various timezones!
Expand Down
Loading