Our powerful JS Calendar component


Post 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?

Attachments
maxDate-agenda.png
maxDate-agenda.png (98.92 KiB) Viewed 261 times

Post by mats »

Can you please share your code as a small test case so we can inspect it?


Post by Animal »

Thanks for the report. This should work. It's a bit of a mystery. Will will investigate this bug.


Post 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.


Post by Animal »

Here is a ticket to get this sealed up: https://github.com/bryntum/support/issues/9811


Post by Animal »

So in the following case:

Screenshot 2024-08-14 at 13.53.28.png
Screenshot 2024-08-14 at 13.53.28.png (300.34 KiB) Viewed 225 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


Post 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?


Post by Animal »

This will be fixed in 6.0.5 which will be out very soon.


Post Reply