Topic: Custom modal in Calendar plugin

ammi pro asked 5 days ago


You added new events and methods to enable creation of custom modals to handle adding or editing events. However, I can't make it work. If I click "add event" button in calendar plug-in, it triggers addEvent1($event), but instead of opening my custom modal CalendarEventComponent it opens standard modal. However, If I click separate button and it triggers addEvent() it opens my custom modal, and it works as expected. What do I need to change in order to use plug-in's "Add Event" button to open custom modal? Thank you.

HTML:

<mdb-calendar [events]="calendarEvents" [readonly]="false" #calendar
  (prev)="onPeriodChange()"
  (next)="onPeriodChange()"
  (eventEdit)="editEvent1($event)"
  (eventAdd)="addEvent1($event)"
  (eventDelete)="deleteEvent1($event)"
></mdb-calendar>

<button  type="button"
      class="btn-outline-primary btn" title="Add event" (click)="addEvent()">
      Add
    </button>

TS:

addEvent1(e: any): void {
    console.log(e);
    const md = this.modalService.open(CalendarEventComponent, {
        modalClass: 'modal-lg',
        data: { scheduleId: 0, calendarType: 1 },
    });

    md.onClose.subscribe(newEvent => {
        console.log(newEvent);
    });
}

addEvent(): void
{
    const calendarType = this.isPublic ? 1 : 0;
    const md = this.modalService.open(CalendarEventComponent, {
        modalClass: 'modal-lg',
        data: { scheduleId: 0, calendarType },
    });

    md.onClose.subscribe( (updatedEvent: CalendarModel) => {
        console.log(newEvent);
    });
}


The events emitted by those outputs are of type MdbCalendarEventAction. If you update the types you will see that those events have 'event' parameter (that holds underlying MdbCalendarEvent object) and preventDefault method that can be used to block the default behavior like in some native JS events.

Here is an example:

  onEventEdit(action: MdbCalendarEventAction): void {
    console.log('Edit action triggered for event:', action.event);
    action.preventDefault();
    this.openCustomModal(action.event, 'edit');
  }

We will add better examples to the documentation because it seems like we forgot to do that after the update.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: MDB5 9.1.0
  • Device: Laptop
  • Browser: Chrome
  • OS: W11
  • Provided sample code: No
  • Provided link: No