-
Notifications
You must be signed in to change notification settings - Fork 84
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,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 | ||
|
|
||
| dim: true | ||
|
|
||
| drawerHeader.title: root.title | ||
| drawerHeader.topLeftItem.visible: !root.showClearButton | ||
|
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. 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: { | ||
|
xkello marked this conversation as resolved.
|
||
| root.clearButtonClicked() | ||
| root.close() | ||
| } | ||
| } | ||
|
|
||
| drawerContent: Item { | ||
| width: parent.width | ||
|
|
||
|
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. can you as well purge the |
| 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 | ||||||
| showClearButton: root._fieldValueIsNull | ||||||
|
|
||||||
| onPrimaryButtonClicked: { | ||||||
| root.newDateSelected( dateTime ) | ||||||
| } | ||||||
|
|
||||||
| onClearButtonClicked: { | ||||||
| root.editorValueChanged( undefined, 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. is there a reason we can't use null? If not then let's prefer using null |
||||||
| } | ||||||
|
|
||||||
| onClosed: dateTimeDrawerLoader.active = false | ||||||
|
|
||||||
| Component.onCompleted: open() | ||||||
|
|
@@ -122,6 +127,12 @@ MMPrivateComponents.MMBaseSingleLineInput { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| function hasValidFieldValue() { | ||||||
|
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. It would make more sense to call it invalid values |
||||||
| return root._fieldValueIsNull | ||||||
| || root._fieldHasMixedValues | ||||||
| || (root._fieldValue ?? null) === null | ||||||
|
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.
Suggested change
this should be the same |
||||||
| } | ||||||
|
|
||||||
| QtObject { | ||||||
| id: dateTransformer | ||||||
| // When changing this function, test with various timezones! | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.