Temporarily render new/updated events in calendar while saving is in progress
This commit is contained in:
parent
35169e1d36
commit
9d2e9843e2
3 changed files with 31 additions and 7 deletions
|
@ -526,9 +526,9 @@ class calendar extends rcube_plugin
|
||||||
$event['uid'] = $this->generate_uid();
|
$event['uid'] = $this->generate_uid();
|
||||||
$this->prepare_event($event, $action);
|
$this->prepare_event($event, $action);
|
||||||
if ($success = $this->driver->new_event($event)) {
|
if ($success = $this->driver->new_event($event)) {
|
||||||
$event['id'] = $event['uid'];
|
$event['id'] = $event['uid'];
|
||||||
$this->cleanup_event($event);
|
$this->cleanup_event($event);
|
||||||
}
|
}
|
||||||
$reload = true;
|
$reload = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -619,8 +619,8 @@ class calendar extends rcube_plugin
|
||||||
$this->rc->output->command('plugin.unlock_saving');
|
$this->rc->output->command('plugin.unlock_saving');
|
||||||
|
|
||||||
// FIXME: update a single event object on the client instead of reloading the entire source
|
// FIXME: update a single event object on the client instead of reloading the entire source
|
||||||
if ($success && $reload)
|
if ($reload)
|
||||||
$this->rc->output->command('plugin.reload_calendar', array('source' => $event['calendar']));
|
$this->rc->output->command('plugin.refresh_calendar', array('source' => $event['calendar'], 'refetch' => $success));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1385,6 +1385,19 @@ function rcube_calendar_ui(settings)
|
||||||
{
|
{
|
||||||
me.saving_lock = rcmail.set_busy(true, 'calendar.savingdata');
|
me.saving_lock = rcmail.set_busy(true, 'calendar.savingdata');
|
||||||
rcmail.http_post('event', { action:action, e:data });
|
rcmail.http_post('event', { action:action, e:data });
|
||||||
|
|
||||||
|
// render event temporarily into the calendar
|
||||||
|
if (data.start && data.end) {
|
||||||
|
var event = data.id ? $.extend(fc.fullCalendar('clientEvents', data.id)[0], data) : data;
|
||||||
|
event.start = fromunixtime(data.start);
|
||||||
|
event.end = fromunixtime(data.end);
|
||||||
|
if (data.allday !== undefined)
|
||||||
|
event.allDay = data.allday;
|
||||||
|
event.editable = false;
|
||||||
|
event.temp = true;
|
||||||
|
event.className = 'fc-event-cal-'+data.calendar+' fc-event-temp';
|
||||||
|
fc.fullCalendar(data.id ? 'updateEvent' : 'renderEvent', event);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// mouse-click handler to check if the show dialog is still open and prevent default action
|
// mouse-click handler to check if the show dialog is still open and prevent default action
|
||||||
|
@ -1926,7 +1939,8 @@ function rcube_calendar_ui(settings)
|
||||||
},
|
},
|
||||||
// callback when a specific event is clicked
|
// callback when a specific event is clicked
|
||||||
eventClick: function(event) {
|
eventClick: function(event) {
|
||||||
event_show_dialog(event);
|
if (!event.temp)
|
||||||
|
event_show_dialog(event);
|
||||||
},
|
},
|
||||||
// callback when an event was dragged and finally dropped
|
// callback when an event was dragged and finally dropped
|
||||||
eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc) {
|
eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc) {
|
||||||
|
@ -2227,8 +2241,13 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
|
||||||
rcmail.register_command('reset-search', function(){ cal.reset_quicksearch(); }, true);
|
rcmail.register_command('reset-search', function(){ cal.reset_quicksearch(); }, true);
|
||||||
|
|
||||||
// register callback commands
|
// register callback commands
|
||||||
|
rcmail.addEventListener('plugin.refresh_calendar', function(p){
|
||||||
|
if (p.refetch)
|
||||||
|
$('#calendar').fullCalendar('refetchEvents', cal.calendars[p.source]);
|
||||||
|
// remove temp events
|
||||||
|
$('#calendar').fullCalendar('removeEvents', function(e){ return e.temp; });
|
||||||
|
});
|
||||||
rcmail.addEventListener('plugin.display_alarms', function(alarms){ cal.display_alarms(alarms); });
|
rcmail.addEventListener('plugin.display_alarms', function(alarms){ cal.display_alarms(alarms); });
|
||||||
rcmail.addEventListener('plugin.reload_calendar', function(p){ $('#calendar').fullCalendar('refetchEvents', cal.calendars[p.source]); });
|
|
||||||
rcmail.addEventListener('plugin.destroy_source', function(p){ cal.calendar_destroy_source(p.id); });
|
rcmail.addEventListener('plugin.destroy_source', function(p){ cal.calendar_destroy_source(p.id); });
|
||||||
rcmail.addEventListener('plugin.unlock_saving', function(p){ rcmail.set_busy(false, null, cal.saving_lock); });
|
rcmail.addEventListener('plugin.unlock_saving', function(p){ rcmail.set_busy(false, null, cal.saving_lock); });
|
||||||
|
|
||||||
|
|
|
@ -1077,6 +1077,11 @@ div.fc-event-location {
|
||||||
padding: 0 0.3em;
|
padding: 0 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fc-event-temp {
|
||||||
|
opacity: 0.4;
|
||||||
|
filter: alpha(opacity=40); /* IE8 */
|
||||||
|
}
|
||||||
|
|
||||||
/* Settings section */
|
/* Settings section */
|
||||||
|
|
||||||
fieldset #calendarcategories div {
|
fieldset #calendarcategories div {
|
||||||
|
|
Loading…
Add table
Reference in a new issue