Event display:

- Always respect granularity in multiweek view, number of users selected doesn't matter
- Reduce multiweek options to 2 or 3
- Fix start of day positioning when there are several all day non-blocking events
- Try to work with CSS transitions and sizes a little better
This commit is contained in:
Nathan Gray 2015-11-12 01:01:21 +00:00
parent bddf7ab28b
commit 28d4ebe407
6 changed files with 68 additions and 23 deletions

View File

@ -162,7 +162,7 @@ class calendar_hooks
$times[$i] = $GLOBALS['egw']->common->formattime($i,'00'); $times[$i] = $GLOBALS['egw']->common->formattime($i,'00');
} }
for ($i = 2; $i <= 9; ++$i) for ($i = 2; $i <= 3; ++$i)
{ {
$muliple_weeks[$i.' weeks'] = lang('%1 weeks',$i); $muliple_weeks[$i.' weeks'] = lang('%1 weeks',$i);
} }

View File

@ -520,6 +520,7 @@ app.classes.calendar = AppJS.extend(
original.css("height",original.height() + "px"); original.css("height",original.height() + "px");
cloned.css("height",original.height() + "px"); cloned.css("height",original.height() + "px");
} }
var original_size = {height: wrapper.parent().css('height'), width: wrapper.parent().css('width')};
wrapper.parent().css({overflow:'hidden', height:original.outerHeight()+"px", width:original.outerWidth() + "px"}); wrapper.parent().css({overflow:'hidden', height:original.outerHeight()+"px", width:original.outerWidth() + "px"});
wrapper.height(direction == "up" || direction == "down" ? 2 * original.outerHeight() : original.outerHeight()); wrapper.height(direction == "up" || direction == "down" ? 2 * original.outerHeight() : original.outerHeight());
wrapper.width(direction == "left" || direction == "right" ? 2 * original.outerWidth() : original.outerWidth()); wrapper.width(direction == "left" || direction == "right" ? 2 * original.outerWidth() : original.outerWidth());
@ -579,7 +580,7 @@ app.classes.calendar = AppJS.extend(
wrapper wrapper
.removeClass("calendar_slide") .removeClass("calendar_slide")
.css({"transform": '',height: '', width:'',overflow:''}); .css({"transform": '',height: '', width:'',overflow:''});
wrapper.parent().css({overflow: '', width: '', height: ''}); wrapper.parent().css({overflow: '', width: original_size.width, height: original_size.height});
original.css("display",""); original.css("display","");
wrapper[0].offsetHeight; wrapper[0].offsetHeight;
wrapper.css({ wrapper.css({
@ -3053,7 +3054,8 @@ jQuery.extend(app.classes.calendar,{
return d; return d;
}, },
granularity: function(state) { granularity: function(state) {
return (parseInt(egw.preference('multiple_weeks','calendar')) || 3) * app.calendar.View.granularity.call(this, state); // Does not care how many users you select
return parseInt(egw.preference('interval','calendar')) || 30;
} }
}), }),
month: app.classes.calendar.prototype.View.extend({ month: app.classes.calendar.prototype.View.extend({

View File

@ -674,13 +674,21 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM],
var height = 0; var height = 0;
if(columns[c][i].options.value.whole_day_on_top) if(columns[c][i].options.value.whole_day_on_top)
{ {
columns[c][i].div if(!this.all_day.has(columns[c][i].div).length)
.appendTo(this.all_day); {
columns[c][i].div
.appendTo(this.all_day);
this._parent._resizeTimes();
}
continue; continue;
} }
else else
{ {
columns[c][i].div.appendTo(this.div); if(this.all_day.has(columns[c][i].div).length)
{
columns[c][i].div.appendTo(this.div);
this._parent._resizeTimes();
}
top = this._time_to_position(columns[c][i].options.value.start_m,whole_day_counter); top = this._time_to_position(columns[c][i].options.value.start_m,whole_day_counter);
height = this._time_to_position(columns[c][i].options.value.end_m,whole_day_counter)-top; height = this._time_to_position(columns[c][i].options.value.end_m,whole_day_counter)-top;
} }

View File

@ -131,8 +131,8 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this._actionObject = null; this._actionObject = null;
// Update daywise caches // Update daywise caches
var new_cache_id = app.classes.calendar._daywise_cache_id(event.date,this.options.owner); var new_cache_id = app.classes.calendar._daywise_cache_id(event.date,this._parent.options.owner);
var old_cache_id = app.classes.calendar._daywise_cache_id(this.options.value.date,this.options.owner); var old_cache_id = app.classes.calendar._daywise_cache_id(this.options.value.date,this._parent.options.owner);
var new_daywise = egw.dataGetUIDdata(new_cache_id); var new_daywise = egw.dataGetUIDdata(new_cache_id);
var old_daywise = egw.dataGetUIDdata(old_cache_id); var old_daywise = egw.dataGetUIDdata(old_cache_id);
new_daywise = new_daywise ? new_daywise.data : []; new_daywise = new_daywise ? new_daywise.data : [];

View File

@ -103,7 +103,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
// Headers // Headers
this.gridHeader = $j(document.createElement("div")) this.gridHeader = $j(document.createElement("div"))
.addClass("calendar_calGridHeader et2_link") .addClass("calendar_calGridHeader")
.appendTo(this.div); .appendTo(this.div);
this.dayHeader = $j(document.createElement("div")) this.dayHeader = $j(document.createElement("div"))
.appendTo(this.gridHeader); .appendTo(this.gridHeader);
@ -482,6 +482,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
} }
this.widget._drawDays(); this.widget._drawDays();
this.widget._resizeTimes();
if(this.trigger) if(this.trigger)
{ {
this.widget.change(); this.widget.change();
@ -557,8 +558,8 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
var wd_end = 60*this.options.day_end; var wd_end = 60*this.options.day_end;
var granularity = this.options.granularity; var granularity = this.options.granularity;
var totalDisplayMinutes = wd_end - wd_start; var totalDisplayMinutes = wd_end - wd_start;
var rowsToDisplay = (totalDisplayMinutes + 60)/granularity; var rowsToDisplay = Math.ceil((totalDisplayMinutes+60)/granularity);
this.gridHeader this.gridHeader
.empty() .empty()
.attr('data-date', this.options.start_date) .attr('data-date', this.options.start_date)
@ -569,10 +570,10 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
.appendTo(this.div); .appendTo(this.div);
// Max with 45 avoids problems when it's not shown // Max with 45 avoids problems when it's not shown
var header_height = Math.max(this.gridHeader.height(), 45); var header_height = Math.max(this.gridHeader.outerHeight(true), 45);
this.scrolling this.scrolling
.css('height', (this.options.height - header_height)+'px') .css('height', (this.div.innerHeight() - header_height)+'px')
.appendTo(this.div) .appendTo(this.div)
.empty() .empty()
.off().on('scroll', jQuery.proxy(this._scroll, this)); .off().on('scroll', jQuery.proxy(this._scroll, this));
@ -580,7 +581,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
// Percent // Percent
var rowHeight = (100/rowsToDisplay).toFixed(1); var rowHeight = (100/rowsToDisplay).toFixed(1);
// Pixels // Pixels
this.rowHeight = this.div.height() / rowsToDisplay; this.rowHeight = this.scrolling.height() / rowsToDisplay;
// the hour rows // the hour rows
var show = { var show = {
@ -616,13 +617,35 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
// Set heights in pixels for scrolling // Set heights in pixels for scrolling
this.scrolling this.scrolling
.append('<div class="calendar_calTimeLabels" style="height: ' +(this.rowHeight*i)+'px" >' + html + '</div>'); .append('<div class="calendar_calTimeLabels">' + html + '</div>');
this.days.css('height', (this.rowHeight*i)+'px'); this.days.css('height', (this.rowHeight*i)+'px');
// Scroll to start of day // Scroll to start of day
this.scrolling.scrollTop(this._top_time); this.scrolling.scrollTop(this._top_time);
}, },
_resizeTimes: function() {
var wd_start = 60*this.options.day_start;
var wd_end = 60*this.options.day_end;
var totalDisplayMinutes = wd_end - wd_start;
var rowsToDisplay = Math.ceil((totalDisplayMinutes+60)/this.options.granularity);
this.scrolling
.css('height', (this.options.height - this.gridHeader.outerHeight(true))+'px');
var new_height = this.scrolling.height() / rowsToDisplay;
if(new_height != this.rowHeight)
{
this.rowHeight = new_height;
var rows = $j('.calendar_calTimeRow',this.scrolling).height(this.rowHeight);
this.days.css('height', (this.rowHeight*rows.length)+'px');
// Scroll to start of day
this._top_time = (wd_start * this.rowHeight) / this.options.granularity;
this.scrolling.scrollTop(this._top_time);
}
},
/** /**
* Set up the needed day widgets to correctly display the selected date * Set up the needed day widgets to correctly display the selected date
* range. First we calculate the needed dates, then we create any needed * range. First we calculate the needed dates, then we create any needed
@ -713,8 +736,8 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
// Don't hold on to value any longer, use the data cache for best info // Don't hold on to value any longer, use the data cache for best info
this.value = {}; this.value = {};
// Scroll to start of day // Adjust and scroll to start of day
this.scrolling.scrollTop(this._top_time); this._resizeTimes();
// Handle not fully visible elements // Handle not fully visible elements
this._scroll(); this._scroll();
@ -1507,7 +1530,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
this.div.css('height', this.options.height); this.div.css('height', this.options.height);
// Re-do time grid // Re-do time grid
this._drawGrid() this._drawGrid();
} }
} }
}); });

View File

@ -151,9 +151,9 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
overflow: hidden; overflow: hidden;
/* set via inline style on runtime:
* height: display: flex;
*/ flex-direction: column;
} }
.calendar_calTimeGrid .calendar_calTimeGridScroll { .calendar_calTimeGrid .calendar_calTimeGridScroll {
@ -233,7 +233,7 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
line-height: 16px; line-height: 16px;
} }
.calendar_calDayColHeader { .calendar_calDayColHeader {
display: inline-block; display: table-cell;
position: relative; position: relative;
vertical-align: top; vertical-align: top;
border-right: 1px solid silver; border-right: 1px solid silver;
@ -289,8 +289,15 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
.calendar_calDayColAllDay { .calendar_calDayColAllDay {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row;
align-items:flex-start;
width: 100%; width: 100%;
height: 100% height: 100%;
min-height: 3em;
}
.calendar_calDayColAllDay > .calendar_calEventBodySmall {
white-space: nowrap;
} }
.calendar_calGridHeader > div { .calendar_calGridHeader > div {
position: relative; position: relative;
@ -360,6 +367,7 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
z-index: 29; z-index: 29;
border-bottom: 1px solid silver; border-bottom: 1px solid silver;
min-height: 45px; min-height: 45px;
flex: 0 0 auto;
} }
#calendar-view_view tbody.ui-sortable { #calendar-view_view tbody.ui-sortable {
cursor: default; cursor: default;
@ -464,6 +472,9 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
/* This determines how many per line */ /* This determines how many per line */
flex: 1 1 20em; flex: 1 1 20em;
} }
.calendar_calDayColHeader .calendar_calEvent .calendar_calEventBody {
white-space: nowrap;
}
.calendar_calEventTooltip{ .calendar_calEventTooltip{
border-radius: 6px; border-radius: 6px;
-moz-border-radius: 6px; -moz-border-radius: 6px;
@ -496,6 +507,7 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
right: 0px; right: 0px;
padding-left: 2px; padding-left: 2px;
min-height: 1em; min-height: 1em;
overflow: hidden;
/* set via inline style on runtime /* set via inline style on runtime
* background-color: depending on category * background-color: depending on category
* color: white || black depending on cat; * color: white || black depending on cat;