Allow to move event date/time selection when clicking on the free-busy grid

This commit is contained in:
Thomas Bruederli 2011-07-29 10:19:26 +02:00
parent 92b98ef2ec
commit 8b8142db53
3 changed files with 36 additions and 12 deletions

View file

@ -506,7 +506,7 @@ class calendar extends rcube_plugin
$success = $reload = $got_msg = false;
// read old event data in order to find changes
if ($event['_notify'])
if ($event['_notify'] && $action != 'new')
$old = $this->driver->get_event($event);
switch ($action) {
@ -588,7 +588,7 @@ class calendar extends rcube_plugin
$event = $this->driver->get_event($event);
// only notify if data really changed (TODO: do diff check on client already)
if (self::event_diff($event, $old)) {
if (!$old || self::event_diff($event, $old)) {
if ($this->notify_attendees($event, $old) < 0)
$this->rc->output->show_message('calendar.errornotifying', 'error');
}
@ -1388,7 +1388,7 @@ class calendar extends rcube_plugin
foreach ($fblist as $slot) {
list($from, $to, $type) = $slot;
if ($from <= $end && $to > $start) {
if ($from < $end && $to > $start) {
$status = isset($type) && $fbtypemap[$type] ? $fbtypemap[$type] : 'BUSY';
break;
}
@ -1441,7 +1441,7 @@ class calendar extends rcube_plugin
$t = $t_end;
}
echo json_encode(array('email' => $email, 'start' => intval($start), 'interval' => $interval, 'slots' => $slots));
echo json_encode(array('email' => $email, 'start' => intval($start), 'end' => intval($t_end), 'interval' => $interval, 'slots' => $slots));
exit;
}

View file

@ -371,7 +371,7 @@ function rcube_calendar_ui(settings)
var allday = $('#edit-allday').get(0);
var notify = $('#edit-attendees-donotify').get(0);
var invite = $('#edit-attendees-invite').get(0);
notify.checked = invite.checked = true; // enable notification by default
notify.checked = false, invite.checked = true;
if (event.allDay) {
starttime.val("00:00").hide();
@ -464,11 +464,13 @@ function rcube_calendar_ui(settings)
if (calendar.attendees && event.attendees) {
for (var j=0; j < event.attendees.length; j++)
add_attendee(event.attendees[j], true);
$('#edit-attendees-notify').show();
if (event.attendees.length > 1 || event.attendees[0].email != settings.event_owner.email) {
notify.checked = invite.checked = true; // enable notification by default
}
}
else
$('#edit-attendees-notify').hide();
$('#edit-attendees-notify')[(notify.checked?'show':'hide')]();
$('#edit-attendee-schedule')[(calendar.freebusy?'show':'hide')]();
// attachments
@ -763,7 +765,7 @@ function rcube_calendar_ui(settings)
// set css class according to working hours
css = is_weekend(curdate) || (freebusy_ui.interval <= 60 && !is_workinghour(curdate)) ? 'offhours' : 'workinghours';
times_row += '<td class="' + css + '">' + Q($.fullCalendar.formatDate(curdate, settings['time_format'])) + '</td>';
times_row += '<td class="' + css + '" id="t-' + Math.floor(t/1000) + '">' + Q($.fullCalendar.formatDate(curdate, settings['time_format'])) + '</td>';
slots_row += '<td class="' + css + ' unknown">&nbsp;</td>';
t += freebusy_ui.interval * 60000;
@ -783,6 +785,24 @@ function rcube_calendar_ui(settings)
table.children('thead').html(dates_row + times_row);
table.children('tbody').html(times_html);
// initialize event handlers on grid
if (!freebusy_ui.grid_events) {
freebusy_ui.grid_events = true;
table.children('thead').click(function(e){
// move event to the clicked date/time
if (e.target.id && e.target.id.match(/t-(\d+)/)) {
var newstart = new Date(RegExp.$1 * 1000);
// set time to 00:00
if (me.selected_event.allDay) {
newstart.setMinutes(0);
newstart.setHours(0);
}
update_freebusy_dates(newstart, new Date(newstart.getTime() + freebusy_ui.startdate.data('duration') * 1000));
render_freebusy_overlay();
}
})
}
// if we have loaded free-busy data, show it
if (!freebusy_ui.loading) {
if (date2unixtime(freebusy_ui.start) < freebusy_data.start || date2unixtime(freebusy_ui.end) > freebusy_data.end || freebusy_ui.interval != freebusy_data.interval) {
@ -958,7 +978,7 @@ function rcube_calendar_ui(settings)
var freebusy_find_slot = function(dir)
{
var event = me.selected_event,
eventstart = date2unixtime(event.start), // calculate with unitimes
eventstart = date2unixtime(event.start), // calculate with unixtimes
eventend = date2unixtime(event.end),
duration = eventend - eventstart,
sinterval = freebusy_data.interval * 60,
@ -992,7 +1012,7 @@ function rcube_calendar_ui(settings)
// check freebusy data for all attendees
for (var i=0; i < event_attendees.length; i++) {
if ((email = event_attendees[i].email) && freebusy_data[email][slot] > 1) {
if (event_attendees[i].role != 'OPT-PARTICIPANT' && (email = event_attendees[i].email) && freebusy_data[email] && freebusy_data[email][slot] > 1) {
candidatestart = candidateend = false;
break;
}

View file

@ -727,6 +727,10 @@ td.topalign {
text-align: center;
}
#schedule-freebusy-times tr.times td {
cursor: pointer;
}
#schedule-event-time {
position: absolute;
border: 2px solid #333;