From ed6948a9f23a88dd2e0af75c3920ab27d9277529 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 2 Sep 2015 22:40:38 +0000 Subject: [PATCH] - 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 --- calendar/js/app.js | 9 +++++++-- calendar/js/et2_widget_timegrid.js | 10 +++++++++- calendar/templates/default/app.css | 14 +++++++++++++- calendar/templates/default/sidebox.xet | 5 ++--- calendar/templates/pixelegg/app.css | 15 +++++++++++++-- calendar/templates/pixelegg/app.less | 1 - 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index 3c85d5c0ba..4182fdc46b 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -2458,8 +2458,13 @@ app.classes.calendar = AppJS.extend( { 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) { - 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) { @@ -2609,7 +2614,7 @@ jQuery.extend(app.classes.calendar,{ return d; }, 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({ diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index ff878f411b..36d3131242 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -491,6 +491,9 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz this.gridHeader .css('height', rowHeight+'%') .text(this.options.label) + .attr('data-date', this.options.start_date) + .attr('data-owner', this.options.owner) + .append(this.owner.getDOMNode()) .appendTo(this.div); // the hour rows @@ -1035,7 +1038,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz var old = this.options.owner || 0; this.owner.set_label(''); this.div.removeClass('calendar_TimeGridNoLabel'); - + if(typeof _owner == 'string' && isNaN(_owner)) { switch(_owner[0]) @@ -1062,6 +1065,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz { this.owner.options.application = 'home-accounts' 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(); @@ -1220,6 +1224,10 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz } 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) { // Default handler to open a new event at the selected time diff --git a/calendar/templates/default/app.css b/calendar/templates/default/app.css index 1e2533b601..ec69003bfa 100644 --- a/calendar/templates/default/app.css +++ b/calendar/templates/default/app.css @@ -230,7 +230,9 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget border-right: 1px solid silver; height: 16px; line-height: 16px; - z-index: 30; +} +.calendar_calDayColHeader { + z-index:30; } .calendar_calDayColHeader img { vertical-align: middle; @@ -292,6 +294,16 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget .calendar_calGridHeader{ text-align: left; 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 diff --git a/calendar/templates/default/sidebox.xet b/calendar/templates/default/sidebox.xet index 7dcf56aa80..630d7c0eba 100644 --- a/calendar/templates/default/sidebox.xet +++ b/calendar/templates/default/sidebox.xet @@ -14,7 +14,6 @@ Egroupware