Fix/improve free time slot selection
This commit is contained in:
parent
d4c686faa7
commit
2cefdc3343
4 changed files with 36 additions and 26 deletions
|
@ -626,6 +626,7 @@ function rcube_calendar_ui(settings)
|
|||
if (allday.checked) {
|
||||
starttime.val("00:00").hide();
|
||||
endtime.val("23:59").hide();
|
||||
event.allDay = true;
|
||||
}
|
||||
|
||||
// read attendee roles from drop-downs
|
||||
|
@ -642,7 +643,7 @@ function rcube_calendar_ui(settings)
|
|||
|
||||
freebusy_data = {};
|
||||
freebusy_ui.loading = 1; // prevent render_freebusy_grid() to load data yet
|
||||
freebusy_ui.numdays = allday.checked ? 7 : 1;
|
||||
freebusy_ui.numdays = allday.checked ? 7 : Math.ceil(duration * 2 / 86400);
|
||||
freebusy_ui.interval = allday.checked ? 360 : 60;
|
||||
freebusy_ui.start = fb_start;
|
||||
freebusy_ui.end = new Date(freebusy_ui.start.getTime() + 86400000 * freebusy_ui.numdays);
|
||||
|
@ -780,7 +781,7 @@ function rcube_calendar_ui(settings)
|
|||
else {
|
||||
var table = $('#schedule-freebusy-times'),
|
||||
width = 0,
|
||||
pos = { top:table.children('thead').height(), left:-1 },
|
||||
pos = { top:table.children('thead').height(), left:0 },
|
||||
eventstart = date2unixtime(me.selected_event.start),
|
||||
eventend = date2unixtime(me.selected_event.end),
|
||||
slotstart = date2unixtime(freebusy_ui.start),
|
||||
|
@ -808,7 +809,7 @@ function rcube_calendar_ui(settings)
|
|||
width = table.width() - pos.left;
|
||||
|
||||
// overlay is visible
|
||||
if (width > 0 && pos.left >= 0)
|
||||
if (width > 0)
|
||||
overlay.css({ width: (width-5)+'px', height:(table.children('tbody').height() - 4)+'px', left:pos.left+'px', top:pos.top+'px' }).show();
|
||||
else
|
||||
overlay.hide();
|
||||
|
@ -886,12 +887,13 @@ function rcube_calendar_ui(settings)
|
|||
eventend = date2unixtime(event.end),
|
||||
duration = eventend - eventstart,
|
||||
sinterval = freebusy_data.interval * 60,
|
||||
intvlslots = event.allDay ? 4 : 1,
|
||||
numslots = Math.ceil(duration / sinterval),
|
||||
checkdate, slotend, email, curdate;
|
||||
|
||||
// shift event times to next possible slot
|
||||
eventstart += sinterval * dir;
|
||||
eventend += sinterval * dir;
|
||||
eventstart += sinterval * intvlslots * dir;
|
||||
eventend += sinterval * intvlslots * dir;
|
||||
|
||||
var candidatecount = 0, candidatestart = candidateend = success = false;
|
||||
for (var slot = dir > 0 ? freebusy_data.start : freebusy_data.end - sinterval; (dir > 0 && slot < freebusy_data.end) || (dir < 0 && slot >= freebusy_data.start); slot += sinterval * dir) {
|
||||
|
@ -915,15 +917,17 @@ 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) {
|
||||
candidatestart = false;
|
||||
candidatecount = 0;
|
||||
candidatestart = candidateend = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// occupied slot
|
||||
if (!candidatestart)
|
||||
if (!candidatestart) {
|
||||
slot += Math.max(0, intvlslots - candidatecount - 1) * sinterval * dir;
|
||||
candidatecount = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// set candidate end to slot end time
|
||||
candidatecount++;
|
||||
|
@ -975,6 +979,7 @@ function rcube_calendar_ui(settings)
|
|||
{
|
||||
if (me.selected_event) {
|
||||
var allday = $('#edit-allday').get(0);
|
||||
me.selected_event.allDay = allday.checked;
|
||||
me.selected_event.start = parse_datetime(allday.checked ? '00:00' : $('#edit-starttime').val(), $('#edit-startdate').val());
|
||||
me.selected_event.end = parse_datetime(allday.checked ? '23:59' : $('#edit-endtime').val(), $('#edit-enddate').val());
|
||||
if (event_attendees)
|
||||
|
|
|
@ -100,7 +100,7 @@ $labels['availtentative'] = 'Tentative';
|
|||
$labels['availoutofoffice'] = 'Out of Office';
|
||||
$labels['scheduletime'] = 'Available times';
|
||||
$labels['sendnotifications'] = 'Send notifications';
|
||||
$labels['onlyworkinghours'] = 'Show only working hours';
|
||||
$labels['onlyworkinghours'] = 'Only working hours';
|
||||
$labels['prevslot'] = 'Previous Slot';
|
||||
$labels['nextslot'] = 'Next Slot';
|
||||
$labels['noslotfound'] = 'Unable to find a free time slot';
|
||||
|
|
|
@ -731,7 +731,7 @@ td.topalign {
|
|||
|
||||
#eventfreebusy .schedule-options {
|
||||
position: relative;
|
||||
margin-bottom: 2em;
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
#eventfreebusy .schedule-buttons {
|
||||
|
@ -741,7 +741,7 @@ td.topalign {
|
|||
}
|
||||
|
||||
#eventfreebusy .schedule-find-buttons {
|
||||
padding-top:1em;
|
||||
padding-bottom:0.5em;
|
||||
}
|
||||
|
||||
#eventfreebusy .schedule-find-buttons button {
|
||||
|
|
|
@ -188,13 +188,13 @@
|
|||
<roundcube:object name="plugin.attendees_freebusy_table" id="attendees-freebusy-table" cellspacing="0" cellpadding="0" border="0" />
|
||||
|
||||
<div class="schedule-options">
|
||||
<label><input type="checkbox" id="schedule-freebusy-wokinghours" value="1" /><roundcube:label name="calendar.onlyworkinghours" /></label>
|
||||
|
||||
<div class="schedule-buttons">
|
||||
<button id="shedule-freebusy-prev" title="<roundcube:label name='previouspage' />">◄</button><button id="shedule-freebusy-next" title="<roundcube:label name='nextpage' />">►</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="float:left; width:30em">
|
||||
<div style="float:left; width:28em">
|
||||
<div class="form-section">
|
||||
<label for="schedule-startdate"><roundcube:label name="calendar.start" /></label>
|
||||
<input type="text" name="startdate" size="10" id="schedule-startdate" disabled="true" />
|
||||
|
@ -206,10 +206,15 @@
|
|||
<input type="text" name="endtime" size="6" id="schedule-endtime" disabled="true" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="schedule-find-buttons" style="float:left">
|
||||
<div style="float:left">
|
||||
<div class="schedule-find-buttons">
|
||||
<button id="shedule-find-prev">◄ <roundcube:label name="calendar.prevslot" /></button>
|
||||
<button id="shedule-find-next"><roundcube:label name="calendar.nextslot" /> ►</button>
|
||||
</div>
|
||||
<div class="schedule-options">
|
||||
<label><input type="checkbox" id="schedule-freebusy-wokinghours" value="1" /><roundcube:label name="calendar.onlyworkinghours" /></label>
|
||||
</div>
|
||||
</div>
|
||||
<br style="clear:both;" />
|
||||
|
||||
<roundcube:include file="/templates/freebusylegend.html" />
|
||||
|
|
Loading…
Add table
Reference in a new issue