Skip to content

Add onSubtractTime and onAddTime hooks #508

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

Merged
merged 4 commits into from
Feb 12, 2018
Merged

Add onSubtractTime and onAddTime hooks #508

merged 4 commits into from
Feb 12, 2018

Conversation

DaanDD
Copy link
Contributor

@DaanDD DaanDD commented Feb 7, 2018

Description

Implement hooks for onSubtractTime and onAddTime.

Motivation and Context

This could be used to dynamically load selectable dates for each month.

Checklist

[ ] I have added tests covering my changes
[x] All new and existing tests pass
[x] My changes required the documentation to be updated
  [x] I have updated the documentation accordingly
  [x] I have updated the TypeScript 1.8 type definitions accordingly
  [x] I have updated the TypeScript 2.0+ type definitions accordingly

I have ran build but it seems to have updated more than only my changes in the dist folder.

@simeg
Copy link
Collaborator

simeg commented Feb 7, 2018

Hi @DaanDD and thanks for contributing! Your code is changing a critical part of the component but you didn't write any tests. I would like to see some tests that verifies that it's working as you want it to work.

Also, no need to update the dist files. We do that when we release a new version, please remove them from your PR. Thanks!

@DaanDD
Copy link
Contributor Author

DaanDD commented Feb 8, 2018

Hello, thanks for the feedback! I have removed the dist files and added some tests.

DateTime.d.ts Outdated
Callback trigger when the user navigates to the next month, year or group of years.
The callback receives the amount and type ('month', 'year') as parameters.
*/
onAddTime?: (amount: number, type: string) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These name has time in them, but they are triggered for "months, year or group of years". It might be confusing for the user since the component has a time mode.

Naming is hard for these triggers, onSubtractMonthsOrYears is more correct but it's long.

What are your thoughts?

Copy link
Contributor Author

@DaanDD DaanDD Feb 9, 2018

Choose a reason for hiding this comment

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

onSubtractMonthsOrYears seems a bit long, maybe something like onNavigateBack and onNavigateForward?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that better, because navigating time doesn't really make sense. Let's go with that, what do you say?

@@ -1062,6 +1062,64 @@ describe('Datetime', () => {

});

describe('onSubtractTime', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You are testing onAddTime here and onSubtractTime in the next describe(), a mixup :)

@DaanDD
Copy link
Contributor Author

DaanDD commented Feb 12, 2018

@simeg I have changed the hook names. onSubtractTime and onAddTime are now called onNavigateBack and onNavigateForward

@simeg
Copy link
Collaborator

simeg commented Feb 12, 2018

Looks good 👍 Thanks for contributing!

@simeg simeg merged commit d40f6d8 into arqex:master Feb 12, 2018
@laddhadhiraj
Copy link

I am trying to call "onNavigateBack" and "onNavigateForward" both are not working. "onViewModeChange" is working well.

<Datetime input={false} timeFormat={false} onChange={this.updateDate.bind(this)} renderDay={ this.renderDay } onViewModeChange={this.dateViewMode.bind(this)} onNavigateBack={this.dateNavigate.bind(this)} onNavigateForward={this.dateNavigate.bind(this)}/>

@laddhadhiraj
Copy link

It worked for me If I install this package like npm install --save YouCanBookMe/react-datetime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants