Unplanned
Last Updated: 15 Mar 2022 16:26 by Lewis
Annabel
Created on: 04 Jun 2021 14:12
Category: Scheduler
Type: Feature Request
10
Differentiate "edit current occurrence" and "edit the series" in the RecurrenceDialog

I have a scheduler, and am using a custom Edit handler. I need to support recurrence, and editing recurring events. When the use double-clicks on a recurring event, there is a dialog that asks whether they would like to edit the occurrence or the entire series.

I want to be able to capture the results of this dialog. `SchedulerEditEventArgs` doesn't include any attributes that track this.

 

===========

ADMIN EDIT

===========

The implementation of this enhancement could be covered by either including the corresponding attributes in the SchedulerEditEventArgs or by exposing a Template for the RecurrenceDialog.

Note: You may also check the Ability to directly edit an occurence or the series, without the prompt asking you to choose feature request as the implementation of both features will most likely be covered in one release.

1 comment
Lewis
Posted on: 15 Mar 2022 16:26

This is an older ticket but I ran into this same issue and found a work around that might work for you. I took idea from the post listed in the Admin notes. (https://feedback.telerik.com/blazor/1502395-ability-to-directly-edit-an-occurence-or-the-series-without-the-prompt-asking-you-to-choose) and changed it to work off of the default Cancel handler.

 

So what happens is the window will prompt to edit occurrence or series, then when the user makes a selection, the Edit Handler will capture the default meeting info (this seems to always be the series), then the default edit window will popup for a split second and a javascript function will automatically hit the cancel button. Then the cancel handler event args actually grab the correct start/end times. I compare that appointment to the default one. If the default appointment had a recurrence but the cancelled appointment didn't, then I know someone was trying to edit an occurrence and create an exception. I build the correct appointment object with the start/end and recurrenceId fields as needed and then open my custom editor with that info.

 

Example:

<script suppress-error="BL9992">
    function clickSchedulerPromptButton(btnIndex) {
        setTimeout(function () {
            var buttons = document.querySelectorAll(".k-dialog-content .k-form-buttons button");
            if (buttons && buttons.length >= btnIndex) {
                var chosenButton = buttons[btnIndex];
                chosenButton.click();
            }
        }, 100);
    }
</script>

 

public async void EditHandler(SchedulerEditEventArgs args)
        {
            var item = args.Item as MeetingViewModel;
            IsNew = args.IsNew;

            if (!args.IsNew) // an edit operation, otherwise - an insert operation
            {
                DefaultMeeting = item.ShallowCopy();
            }
            else
            {                
                DefaultMeeting = new MeetingViewModel() { Start = args.Start, End = args.End, IsAllDay = args.IsAllDay };
            }
            int btnIndexToClick = 1;

            await _jsInterop.InvokeVoidAsync("clickSchedulerPromptButton", btnIndexToClick);
        }

public async void CancelDefaultEdit(SchedulerCancelEventArgs args)
        {
            var item = args.Item as MeetingViewModel;
            if (!IsNew) // an edit operation, otherwise - an insert operation
            {
                CurrentMeeting = item.ShallowCopy();
            }
            else
            {
                CurrentMeeting = DefaultMeeting;
            }

           // If True then user was trying to create an exception. Every other instance will be False.

            if(!string.IsNullOrWhiteSpace(DefaultMeeting.Recurrence) && string.IsNullOrWhiteSpace(CurrentMeeting.Recurrence))
            {
                CurrentMeeting.MasterRecurrenceId = item.Id;
                CurrentMeeting.Recurrence = null;
                CurrentMeeting.RecurrenceExceptions?.Clear();
                CurrentMeeting.Id = 0;
            }
            CustomEditFormShown = true;
            await InvokeAsync(StateHasChanged);
        }