-
Notifications
You must be signed in to change notification settings - Fork 80
Feature/clear button for calendar drawers #4572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,13 +22,29 @@ MMComponents.MMDrawer { | |
| property alias hasDatePicker: dateTimePicker.hasDatePicker | ||
| property alias hasTimePicker: dateTimePicker.hasTimePicker | ||
| property bool showSeconds: false | ||
| property bool fieldValueIsNull: true | ||
|
|
||
| signal primaryButtonClicked | ||
| signal clearButtonClicked | ||
|
Comment on lines
27
to
+28
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe at this point we can have just one signal which says user finished picking the value
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that now this was mentioned in the ticket to create it |
||
|
|
||
| dim: true | ||
|
|
||
| drawerHeader.title: root.title | ||
|
|
||
| drawerHeader.topLeftItem.visible: !root.fieldValueIsNull | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. visibility based on dateTime value |
||
| drawerHeader.topLeftItemContent: | ||
| MMComponents.MMButton { | ||
| text: qsTr("Clear") | ||
| type: MMButton.Types.Tertiary | ||
| fontColor: __style.darkGreyColor | ||
| fontColorHover: __style.nightColor | ||
|
|
||
| onClicked: { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change the the value to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or empty |
||
| root.clearButtonClicked() | ||
| root.close() | ||
| } | ||
| } | ||
|
|
||
| drawerContent: Item { | ||
| width: parent.width | ||
| height: scrollView.height | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| fieldValueIsNull: root._fieldValueIsNull | ||
|
|
||
| onPrimaryButtonClicked: { | ||
| root.newDateSelected( dateTime ) | ||
| } | ||
|
|
||
| onClearButtonClicked: { | ||
| root.editorValueChanged( root._fieldValue, true ) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currently the actual value doesn't change we just flag it as null no? |
||
| } | ||
|
|
||
| onClosed: dateTimeDrawerLoader.active = false | ||
|
|
||
| Component.onCompleted: open() | ||
|
|
@@ -122,6 +127,13 @@ MMPrivateComponents.MMBaseSingleLineInput { | |
| } | ||
| } | ||
|
|
||
| function hasValidFieldValue() { | ||
| return root._fieldValueIsNull | ||
| || root._fieldHasMixedValues | ||
| || root._fieldValue === undefined | ||
| || root._fieldValue === null | ||
|
Comment on lines
+133
to
+134
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the future this can be replaced with |
||
| } | ||
|
|
||
| QtObject { | ||
| id: dateTransformer | ||
| // When changing this function, test with various timezones! | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to have another property just set the value to null