- Better granularity calculations using number of weeks & view

- Clicking sidebox calendar no longer changes view
- Fixed header links to different day (broken in some views) & got clickable week numbers working
This commit is contained in:
Nathan Gray 2015-09-02 22:40:38 +00:00
parent 31a23f0dbd
commit ed6948a9f2
6 changed files with 44 additions and 10 deletions

View File

@ -2458,8 +2458,13 @@ app.classes.calendar = AppJS.extend(
{ {
return state.days ? parseInt(state.days) === 7 : parseInt(egw.preference('days_in_weekview','calendar')) == 7; return state.days ? parseInt(state.days) === 7 : parseInt(egw.preference('days_in_weekview','calendar')) == 7;
}, },
/**
* How big or small are the displayed time chunks?
* We automatically scale the user's preference based on how many rows / calendars are shown.
*/
granularity: function(state) { granularity: function(state) {
return parseInt(egw.preference('interval','calendar')) || 30; return Math.min(240,(state.owner.length <= (egw.config('calview_no_consolidate','phpgwapi') || 5) ? state.owner.length : 1)
* (parseInt(egw.preference('interval','calendar')) || 30));
}, },
extend: function(sub) extend: function(sub)
{ {
@ -2609,7 +2614,7 @@ jQuery.extend(app.classes.calendar,{
return d; return d;
}, },
granularity: function(state) { granularity: function(state) {
return (state.owner.length || 1) * app.calendar.View.granularity.call(this, state); return (parseInt(egw.preference('multiple_weeks','calendar')) || 3) * app.calendar.View.granularity.call(this, state);
} }
}), }),
month: app.classes.calendar.prototype.View.extend({ month: app.classes.calendar.prototype.View.extend({

View File

@ -491,6 +491,9 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
this.gridHeader this.gridHeader
.css('height', rowHeight+'%') .css('height', rowHeight+'%')
.text(this.options.label) .text(this.options.label)
.attr('data-date', this.options.start_date)
.attr('data-owner', this.options.owner)
.append(this.owner.getDOMNode())
.appendTo(this.div); .appendTo(this.div);
// the hour rows // the hour rows
@ -1062,6 +1065,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
{ {
this.owner.options.application = 'home-accounts' this.owner.options.application = 'home-accounts'
this.owner.set_value(typeof _owner == "string" || typeof _owner == "number" ? _owner : jQuery.extend([],_owner)); this.owner.set_value(typeof _owner == "string" || typeof _owner == "number" ? _owner : jQuery.extend([],_owner));
$j(this.getDOMNode(this.owner)).prepend(this.owner.getDOMNode());
} }
this.options.owner = _owner;//this.owner.getValue(); this.options.owner = _owner;//this.owner.getValue();
@ -1220,6 +1224,10 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
} }
return result; return result;
} }
else if (this.gridHeader.is(_ev.target) && _ev.target.dataset)
{
app.calendar.update_state(jQuery.extend({view: 'week'},_ev.target.dataset));
}
else if (_ev.target.dataset.date) else if (_ev.target.dataset.date)
{ {
// Default handler to open a new event at the selected time // Default handler to open a new event at the selected time

View File

@ -230,7 +230,9 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
border-right: 1px solid silver; border-right: 1px solid silver;
height: 16px; height: 16px;
line-height: 16px; line-height: 16px;
z-index: 30; }
.calendar_calDayColHeader {
z-index:30;
} }
.calendar_calDayColHeader img { .calendar_calDayColHeader img {
vertical-align: middle; vertical-align: middle;
@ -292,6 +294,16 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
.calendar_calGridHeader{ .calendar_calGridHeader{
text-align: left; text-align: left;
padding-left: 3px; padding-left: 3px;
z-index: 29;
}
#calendar-view_view tbody.ui-sortable {
cursor: default;
}
#calendar-view_view tbody.ui-sortable .calendar_calGridHeader {
cursor: ns-resize;
}
#calendar-view_view tbody.ui-sortable-disabled .calendar_calGridHeader {
cursor: pointer;
} }
/* contains (multiple) events's /* contains (multiple) events's

View File

@ -14,7 +14,6 @@ Egroupware
<overlay> <overlay>
<template id="calendar.sidebox"> <template id="calendar.sidebox">
<vbox parent_node="calendar-et2_target"> <vbox parent_node="calendar-et2_target">
<description label="eTemplate"/>
<grid id="buttons" width="100%"> <grid id="buttons" width="100%">
<columns> <columns>
<column/> <column/>
@ -27,7 +26,7 @@ Egroupware
</columns> </columns>
<rows><row width="100%"> <rows><row width="100%">
<buttononly align="center" class="sideboxstar" id="add" onclick="egw.open(null,'calendar','add');" image="new" label="Add"/> <buttononly align="center" class="sideboxstar" id="add" onclick="egw.open(null,'calendar','add');" image="new" label="Add"/>
<buttononly align="center" class="sideboxstar" id="day" image="today" label="Today" onclick="var formatDate = new Date(); app.calendar.update_state({view:'day',date:new Date(formatDate.valueOf() - formatDate.getTimezoneOffset() * 60 * 1000)});"/> <buttononly align="center" class="sideboxstar" id="day" image="today" label="Today" onclick="app.calendar.update_state({view:'day'});"/>
<buttononly align="center" class="sideboxstar" id="week" image="week" label="Weekview" onclick="app.calendar.update_state({view:'week'});"/> <buttononly align="center" class="sideboxstar" id="week" image="week" label="Weekview" onclick="app.calendar.update_state({view:'week'});"/>
<buttononly align="center" class="sideboxstar" id="weekN" image="multiweek" label="Multiple week view" onclick="app.calendar.update_state({view:'weekN'});"/> <buttononly align="center" class="sideboxstar" id="weekN" image="multiweek" label="Multiple week view" onclick="app.calendar.update_state({view:'weekN'});"/>
<buttononly align="center" class="sideboxstar" id="month" image="month" label="Month view" onclick="app.calendar.update_state({view:'month'});"/> <buttononly align="center" class="sideboxstar" id="month" image="month" label="Month view" onclick="app.calendar.update_state({view:'month'});"/>
@ -38,7 +37,7 @@ Egroupware
</grid> </grid>
<select id="view" class="et2_fullWidth" onchange="app.calendar.update_state(JSON.parse(widget.getValue()));"/> <select id="view" class="et2_fullWidth" onchange="app.calendar.update_state(JSON.parse(widget.getValue()));"/>
<textbox id="keywords" class="et2_fullWidth" blur="Search" onchange="app.calendar.update_state({keywords: widget.getValue()});"/> <textbox id="keywords" class="et2_fullWidth" blur="Search" onchange="app.calendar.update_state({keywords: widget.getValue()});"/>
<date id="date" class="et2_fullWidth" inline="true" onchange="app.calendar.update_state({date:widget.getValue(),view:'day'});"/> <date id="date" class="et2_fullWidth" inline="true" onchange="app.calendar.update_state({date:widget.getValue()});"/>
<textbox type="hidden" id="first"/> <textbox type="hidden" id="first"/>
<textbox type="hidden" id="last"/> <textbox type="hidden" id="last"/>
<hbox width="100%"> <hbox width="100%">

View File

@ -11,7 +11,7 @@
* @package calendar * @package calendar
* @version $Id$ * @version $Id$
*/ */
/* $Id: app.css 53459 2015-08-24 17:28:19Z nathangray $ */ /* $Id: app.css 53462 2015-08-25 00:00:45Z nathangray $ */
/*Media print classes*/ /*Media print classes*/
@media print { @media print {
.th td, .th td,
@ -242,6 +242,8 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
border-right: 1px solid silver; border-right: 1px solid silver;
height: 16px; height: 16px;
line-height: 16px; line-height: 16px;
}
.calendar_calDayColHeader {
z-index: 30; z-index: 30;
} }
.calendar_calDayColHeader img { .calendar_calDayColHeader img {
@ -304,6 +306,16 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
.calendar_calGridHeader { .calendar_calGridHeader {
text-align: left; text-align: left;
padding-left: 3px; padding-left: 3px;
z-index: 29;
}
#calendar-view_view tbody.ui-sortable {
cursor: default;
}
#calendar-view_view tbody.ui-sortable .calendar_calGridHeader {
cursor: ns-resize;
}
#calendar-view_view tbody.ui-sortable-disabled .calendar_calGridHeader {
cursor: pointer;
} }
/* contains (multiple) events's /* contains (multiple) events's
*/ */
@ -1518,7 +1530,6 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
border-right: 1px solid silver; border-right: 1px solid silver;
height: 16px; height: 16px;
line-height: 12px; line-height: 12px;
z-index: 30;
} }
.calendar_calDayColHeader a img, .calendar_calDayColHeader a img,
.calendar_calGridHeader a img { .calendar_calGridHeader a img {

View File

@ -860,7 +860,6 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
border-right: 1px solid silver; border-right: 1px solid silver;
.dimension_height_s; .dimension_height_s;
line-height: 12px; line-height: 12px;
z-index: 30;
a { a {
img { img {