Skip to content
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

feat(module:datepicker): support [nzDisabledDate] property in month mode #451

Merged

Conversation

hsuanxyz
Copy link
Member

@hsuanxyz hsuanxyz commented Oct 18, 2017

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #442

What is the new behavior?

preview gif

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 41.242% when pulling 9a58653 on HsuanXyz:feat-datepicker-disabled-4-month into 704aa45 on NG-ZORRO:master.

@@ -334,7 +339,8 @@ export class NzCalendarComponent implements OnInit {
index : i,
name : this._listOfMonthName[ i ],
isCurrentMonth : moment(new Date()).month() === i && date.isSame(new Date(), 'year'),
isSelectedMonth: this._showMonth === i
isSelectedMonth: this._showMonth === i,
disabled : this.nzDisabledDate && this.nzDisabledDate(date.month(i).toDate(), 'month')
Copy link
Member

Choose a reason for hiding this comment

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

why need to add param 'month' here?
should nzDisabledDate function work same for both day and month mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

because can judgment in day mode. the month picker only needs to be accurate to month.
like this

Copy link
Member

Choose a reason for hiding this comment

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

@hsuanxyz but the function works for day mode also works for month mode, is that right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

Copy link
Member

Choose a reason for hiding this comment

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

I just think this design is somewhat redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

Because in the date range demo, if the end of the date part is greater than the start. will be wrongly disabled.
eg: 2017-10-20 20:00 - 2017-11-20 10:00 The end date of October will be disabled

Copy link
Member Author

Choose a reason for hiding this comment

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

this is better?

- disabled : this.nzDisabledDate && this.nzDisabledDate(date.month(i).toDate(), 'month')
+ disabled : this.nzDisabledDate && this.nzDisabledDate(date.month(i).day(0).toDate())

Copy link
Member

Choose a reason for hiding this comment

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

it should not disable the month when the disable function across the month range.

Copy link
Member Author

Choose a reason for hiding this comment

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

agree, thank for you suggestion.

@hsuanxyz hsuanxyz force-pushed the feat-datepicker-disabled-4-month branch from 9a58653 to 4169d1b Compare October 21, 2017 13:20
@hsuanxyz
Copy link
Member Author

@vthinkxie updated, new behavior:
In day mode, disable function does not disable the month picker

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 41.173% when pulling 4169d1b on HsuanXyz:feat-datepicker-disabled-4-month into 4efd6f7 on NG-ZORRO:master.

@vthinkxie vthinkxie merged commit cdc0716 into NG-ZORRO:master Nov 4, 2017
@hsuanxyz hsuanxyz deleted the feat-datepicker-disabled-4-month branch December 6, 2017 11:33
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this pull request Aug 5, 2020
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