-
Notifications
You must be signed in to change notification settings - Fork 19
Add highlighted and disabled classes #66
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
Add highlighted and disabled classes #66
Conversation
073e856
to
7f2c102
Compare
I realised the setters I had written on these classes were pointless, so I removed them. However, if you think we should do some validation on the |
On the first glance it looks pretty neat to me, i will take a deeper look tomorrow and test it out 👍 |
@MrWook - thanks for your improvements which I have now implemented. Cheers! 😄 |
Hi @MrWook, Happy New (calendar) Year!
In an effort to simplify the code, I made the following changes for your consideration:
Created two new classes (DisabledDate.js and HighlightedDate.js) in
utils
to determine whether a particular cell should be disabled and/or highlighted.Both classes expose a
config
property which easily allows us to determine whether a disabled/highlighted configuration exists and if so, whether it hasfrom
,to
,specificDates
,daysOfMonth
,daysOfWeek
,customPredictor
etc. properties. These boolean properties clean up quite a lot of code in other places. e.g.if (!this.disabledDates || !this.disabledDates.to)
becomesif (!this.disabledConfig.has.to)
.The config properties also contain a
to
andfrom
object for easy access to e.g.this.disabledConfig.to.year
as opposed tothis.utils.getFullYear(this.disabledDates.to)
Given that highlighted dates are uniquely relevant to
PickerDay.vue
, I added ahighlightedConfig
computed property ONLY for that component and adisabledConfig
computed property topickerMixin
as it's used in all 3 pickers.To improve readability, I added a
pageMonth
computed property toPickerDay
and apageYear
computed property topickerMixin
. This means we can write e.g.this.pageMonth
instead ofthis.utils.getMonth(this.pageDate)
.Added a
test:debug
script topackage.json
to help with debugging tests via Chrome dev tools.Corrected some December dates in
highlightedDates.spec.js
e.g.new Date(2016, 12, 8)
->new Date(2016, 11, 8)
.Added a test to disabledMonths.spec.js to ensure coverage remains at 100%. This checks that a date's month is disabled when the
to
year is less than the year of the date in question, thereby covering line 112 of DisabledDate.js.Hope this makes sense? Let me know if you have any queries.