[ANGULAR] Want to set up Minimum and Maximum date for the calendar.
Posted: Wed Aug 14, 2024 1:13 am
by maushami
I'm working on configuring the Calendar to restrict users to a specific date range, preventing navigation outside of this range using both the date picker and the previous/next buttons.
I've set the MaxDate and MinDate in the calendar configuration and included these settings in the <bryntum-calendar>, but it hasn't worked as expected. Additionally, setting the agenda view results in an error. I have attached a screenshot of the error for your reference.
Is there an alternative method to achieve this functionality?
Re: [ANGULAR] Want to set up Minimum and Maximum date for the calendar.
Posted: Wed Aug 14, 2024 6:11 am
by mats
Can you please share your code as a small test case so we can inspect it?
Re: [ANGULAR] Want to set up Minimum and Maximum date for the calendar.
Posted: Wed Aug 14, 2024 7:33 am
by Animal
Thanks for the report. This should work. It's a bit of a mystery. Will will investigate this bug.
Re: [ANGULAR] Want to set up Minimum and Maximum date for the calendar.
Posted: Wed Aug 14, 2024 8:29 am
by Animal
Try configuring your AgendaView with the following as a property:
afterStartDateSet : function(startDate, oldStartDate) {
const
me = this,
{ refreshCount } = me,
incomingEndDate = me.hasConfig('endDate') && me.peekConfig('endDate');
// If we are bounded by an endDate configuration, but are not in the process of being passed
// a new endDate (unless we are at configure time), keep the end date synced with current duration.
if (me.hasConfig('endDate') && (!incomingEndDate || me.isConfiguring)) {
const duration = DateHelper.diff(oldStartDate || startDate, me.endDate, 'day');
me.endDate = DateHelper.add(startDate, duration, 'day');
}
// If that changed the end date, the updater will have done a refresh.
// If there was no change to the endDate, so no refresh, we have to refresh here.
if (!me.isConfiguring && !incomingEndDate && me.refreshCount === refreshCount) {
me._cellMap?.clear();
me.refresh();
me.triggerRangeChange(startDate, me.endDate);
}
}
Let us know if that fixes your issue.
Re: [ANGULAR] Want to set up Minimum and Maximum date for the calendar.
Re: [ANGULAR] Want to set up Minimum and Maximum date for the calendar.
Posted: Wed Aug 14, 2024 1:59 pm
by Animal
So in the following case:
Screenshot 2024-08-14 at 13.53.28.png (300.34 KiB) Viewed 238 times
The minDate is 1 Oct 2020 We are going back to the previous week, and that goes from 27 Sep to 3 Oct.
A little bit will be outside the Calendar range. I propose that the validation specifies that a new navigation range is valid if any of it is within the Calendar's min/max range.
So this navigation will work in my fix branch. It doesn't in 6.0
Re: [ANGULAR] Want to set up Minimum and Maximum date for the calendar.
Posted: Tue Aug 20, 2024 2:11 am
by maushami
The afterStartDateSet function is not in the AgendaViewConfig Model. Can you please explain more about how I can configure it in AgendaView?
Is this function only available in versions higher than 6.05?
Re: [ANGULAR] Want to set up Minimum and Maximum date for the calendar.
Posted: Tue Aug 20, 2024 9:22 am
by Animal
This will be fixed in 6.0.5 which will be out very soon.