-
Notifications
You must be signed in to change notification settings - Fork 71
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
Allow usage of the calendar for specific periods #32
Conversation
This functionality will be released in the v1.1.0. Given the lot of modifications needed for this feature, I will need a lot of testing from current users to check that there is no regression. I'm open to any remark on the current implementation. |
Codecov Report
@@ Coverage Diff @@
## master #32 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 28 28
Lines 28 28
=========================================
Hits 28 28 Continue to review full report at Codecov.
|
Hi @Paul-DS I tested the functionality in alpha version , is it available in the stable version 1.1 or 1.2 ? |
Hi @Paul-DS, First of all, great calendar! I tried to test this new functionality, but I have troubles with the dataSource. If I use your example code of the dataSource usage it works fine:
Here is my version where "CalendarData" is the Json Object (see example below).
example of the "CalendarData" Json Object:
another option I tried is using a Json Array (CalendarData) as input like this:
.... and then first parse the strings to dates:
.....and then use it like below:
does not give any result in the calendar. |
Would love to use this feature in my application for my client. Be happy to try it out at a minimum and see how things go. I think numberMonthsDisplayed makes a lot of sense and yeah just being able to control which is the first month by setting the date. Sounds great to me. Only thought that may be nice is just being able to control this dynamically. Say the user has the 12 month calendar showing and wants to change to 3 month. If you are able to provide a method where I can call and set those parameters and cause the calendar to re-render that would be slick. But I understand if that could be a lot more work on top of what you are already doing. I'm assuming the settings are in onLoad and are more challenging as a method call. But like other calendars i.e. Google users are able to switch between views, making that seamless is just my suggestion and would be a nice to have. Other than that as long as the dataSource works as expected, which you mentioned, I think that would be all I have. Nice though if the dataSouce re-render of the calendar worked well dynamically as said above. I'll think more. Tag me if you are curious about something I said or if you want to direct me to something to look at and I'll try to help in the code or version available. |
@Paul-DS is there a potential ETA on this by the way? I think my clients would be excited for the flexible partial month(s) view. That kind of ability to flex between either a full calendar year or partial would be ideal for their needs. I've found ways to trigger a re-draw by setting the dataSource dynamically, and if this worked with similar methods on the elements that would be great. Happy to try to help push things forward where I can. |
I was about to put in a request for this kind of a feature as well and then I saw the reference to this PR. I'm calling it a night for now but I may try this out and report back here on my own success. |
I published a new version with some minor modifications. @sarveshraval Did you find any bug while testing this new functionality ? @PieterDJK Your code seems to be working, but the data are displayed in January, and you're opening the calendar in February ( @JJZolper you can now use the Concerning the ETA, I'll wait for about a week to get more feedback, and then publish a new release (2.0.0) with this functionality. Thank you all for your feedback. |
@Paul-DS, thanks for your reaction. I already tried that, my example code was not correct, sorry. function parseStringToDate(dateString) { [{"startDate":"2020-01-01","endDate":"2020-01-01","name":"","color":"#E89E63"},{"startDate":"2020-01-28","endDate":"2020-01-28","name":"O000777","color":"#75D8E7"},{"startDate":"2020-01-29","endDate":"2020-01-29","name":"O000777","color":"#75D8E7"},{"startDate":"2020-02-04","endDate":"2020-02-04","name":"O000777","color":"#75D8E7"},{"startDate":"2020-02-20","endDate":"2020-02-20","name":"O000777","color":"#75D8E7"},{"startDate":"2020-03-03","endDate":"2020-03-03","name":"O000777","color":"#75D8E7"},{"startDate":"2020-03-09","endDate":"2020-03-09","name":"O000777","color":"#75D8E7"},{"startDate":"2020-04-01","endDate":"2020-04-01","name":"","color":"#E97768"},{"startDate":"2020-04-07","endDate":"2020-04-07","name":"O000827","color":"#75D8E7"},{"startDate":"2020-04-27","endDate":"2020-04-27","name":"","color":"#E89E63"},{"startDate":"2020-05-05","endDate":"2020-05-05","name":"","color":"#E89E63"},{"startDate":"2020-05-09","endDate":"2020-05-09","name":"","color":"#E97768"},{"startDate":"2020-05-10","endDate":"2020-05-10","name":"O000828","color":"#75D8E7"},{"startDate":"2020-05-31","endDate":"2020-05-31","name":"","color":"#E89E63"},{"startDate":"2020-06-01","endDate":"2020-06-01","name":"","color":"#E89E63"},{"startDate":"2020-06-03","endDate":"2020-06-03","name":"O000898","color":"#75D8E7"},{"startDate":"2020-06-13","endDate":"2020-06-13","name":"O000899","color":"#75D8E7"},{"startDate":"2020-07-24","endDate":"2020-07-24","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-07-31","endDate":"2020-07-31","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-08-07","endDate":"2020-08-07","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-08-28","endDate":"2020-08-28","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-09-04","endDate":"2020-09-04","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-09-25","endDate":"2020-09-25","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-10-02","endDate":"2020-10-02","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-10-30","endDate":"2020-10-30","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-11-06","endDate":"2020-11-06","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-11-27","endDate":"2020-11-27","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-12-04","endDate":"2020-12-04","name":"1x per week vrijdag","color":"#E97768"},{"startDate":"2020-12-26","endDate":"2020-12-26","name":"","color":"#E89E63"}] The result is an empty calendar of the whole year. |
In my case I also need to change the color of the day or box clicked while using the new methods. I was able to figure out a way to do this in a more complicated way below. The spikesData var contains the data for the entire calendar.
For the time being I'm managing and everything is superb. I change the colors of the objects for the calendar on a per date basis as they click the day. I also set the element itself sometimes if needed. When a redraw occurs from the setNumberMonthsDisplayed() and setStartDate() it requires passing via the data. Even though I was able to workaround things is this something that would be easy to add at some point @Paul-DS? It may be a bit odd to incorporate alongside the other methods but if it is doable it probably would be a good one to do. I'm using the bleeding edge source in this application for the client and I'll update once it's in @ latest. |
Hi @Paul-DS, js-year-calendar/src/ts/js-year-calendar.ts Line 235 in 5e0e89f
could be easy switched to numberMonthsDisplayed: !isNaN(parseInt(opt.numberMonthsDisplayed))
&& opt.numberMonthsDisplayed > 0 ? parseInt(opt.numberMonthsDisplayed) : 12, to allow more than 12 months or try to implement intermediate startDate. |
The feature is available in v2.0.0 |
Hi, @Paul-DS u ok? i have a bug using de calendar with asp net core 5 and vue js <script src="https://unpkg.com/js-year-calendar@latest/dist/js-year-calendar.min.js"></script> <script src="https://unpkg.com/js-year-calendar@latest/locales/js-year-calendar.pt.js"></script> <script> new Calendar('.calendar', { style: 'background', minDate: new Date() }) </script> |
Following the requests for this 2 features:
This PR implement 2 options:
startDate
: Allow to define the first month displayed in the calendarnumberMonthsDisplayed
Allow to define the number of months displayed in the calendarExamples
These options allow you to do the following:
Display a full year starting from a specific month
With parameters:
startDate: new Date(2020, 8, 1)
Result:
Display only X months
With parameters:
numberMonthsDisplayed: 3
Result:
With parameters:
startDate: new Date(2020, 3, 1)
numberMonthsDisplayed: 1
Result:
TODO
dataSource
option to pass thestartDate
andendDate
parametersstartDate
andstartYear
yearChanged
event, thegetYear
/setYear
methods, etc...Breaking changes⚠️
The first parameter of the dataSource function is now
{ year, startDate, endDate }
instead of justyear
.Example:
How to test
Use the
@next
version of the package:npm install js-year-calendar@next
<script src="https://unpkg.com/js-year-calendar@next/dist/js-year-calendar.min.js"></script>
Additional informations
This is an additional feature , so it shouldn't break the current usage of the calendar (using the basic option
startYear
).The
startDate
option override thestartYear
option.The
yearChanged
event, and thegetYear
andsetYear
method are available only if thestartDate
andnumberMonthsDisplayed
options are not used.