Drag and Drop Fullcalendar

0

The documentation of fullcalendar is well summarized and I'm having trouble coding Drag and Drop. Could anyone give a light on how to start this function?

eventDrop:function(event, delta, revertFunc) {
   alert('ok');
}

I'm still developing the code, but the above call does not run when I roll the calendar.

    
asked by anonymous 19.01.2018 / 18:39

1 answer

0

I do not know if this is the case, but I hope it helps. I use fullcalendar by primeng in an Angular project. For the event in question I call a function:

(onEventDrop)="reschedule($event)"

And my role:

    reschedule(event) {

      if ((addHours(event.event.start._d, 3).getTime() > addHours(new Date(), 1).getTime())) { //
        if (this.notHaveConflicts(addHours(event.event.start._d, 3), addHours(event.event.end._d, 3), event.event.id)) {
          // console.log('nao');

          this.event = event.event;
          this.event.startdb = this.dateToStringDB(addHours(event.event.start._d, 3));
          this.event.enddb = this.dateToStringDB(addHours(event.event.end._d, 3));
          this.event.status = 3;
          this.event.cancel_reason = result.reason;
          delete this.event.source;

          // console.log(this.event);

          this.toggle_events = this._eventsService.updateEvent(this.event).subscribe(
            response => {
              if (response.return) {
                // evento atualizado
              } else {
                // erro no banco/API
                event.revertFunc();
              }
            },
            err => {
              // erro no banco
              event.revertFunc();
            }
          );

          this.reRender();

        } else {
          // teve conflito
          event.revertFunc();
        }
      } else {
        event.revertFunc();
        this._toastrService.error(this._translateService.instant('Agenda.IntervalError'),
          this._translateService.instant('Error.Err'));
      }
    }

In this project, the event is between 2 people, so I check the schedules in the API, if they collide, I call the function:

revertFunc();

And my event returns to the exact place where it was. The fullcalendar itself already holds the previous location to go back, so in my case it was just call it that worked! = D

I hope I have helped!

    
19.01.2018 / 20:26