From 3ea15bf95c24294fad09a30ccdf1afbcab2d83d4 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 9 Mar 2016 18:10:43 +0000 Subject: [PATCH] Add some missed cases for adding new events: - click on day in month view - context menu with no specific time (month view) - fix all day non-blocking in header no longer created a new event --- calendar/js/app.js | 13 ++++++++++++- calendar/js/et2_widget_daycol.js | 2 +- calendar/js/et2_widget_timegrid.js | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index c792694e4d..0460210a5f 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1322,7 +1322,7 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( // Get a little smarter with the context if(!extra) { - var context = {} + var context = {}; if(egw.dataGetUIDdata(_events[0].id) && egw.dataGetUIDdata(_events[0].id).data) { // Found data in global cache @@ -1337,6 +1337,17 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( _events[0].iface.getWidget().options.value || {} extra = {}; } + // Try to pull whatever we can from the event + else if (jQuery.isEmptyObject(context) && _action.menu_context && (_action.menu_context.event.target)) + { + var target = _action.menu_context.event.target; + while(target != null && target.parentNode && jQuery.isEmptyObject(target.dataset)) + { + target = target.parentNode; + } + + context = extra = target.dataset; + } if(context.date) extra.date = context.date; if(context.app) extra.app = context.app; if(context.app_id) extra.app_id = context.app_id; diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index 00abb86cd0..6916ed0fc0 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -1012,7 +1012,7 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte return false; } // Header, but not the hidden event indicators that are in there - else if (this.header.has(_ev.target).length && !$j('.hiddenEventBefore',this.header).has(_ev.target) || + else if (this.header.has(_ev.target).length && !$j('.hiddenEventBefore',this.header).has(_ev.target).length || this.header.is(_ev.target) ) { diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 6b3e6a1e87..30bb8b1165 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -1643,6 +1643,25 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. } } } + // No time grid, click on a day + else if (this.options.granularity === 0 && + ($j(_ev.target).hasClass('event_wrapper') || $j(_ev.target).hasClass('.calendar_calDayCol')) + ) + { + // Default handler to open a new event at the selected time + var target = $j(_ev.target).hasClass('event_wrapper') ? _ev.target.parentNode : _ev.target; + var options = { + date: target.dataset.date || this.options.date, + hour: target.dataset.hour || this._parent.options.day_start, + minute: target.dataset.minute || 0 + }; + if (this.options.owner != app.calendar.state.owner) + { + options.owner = this.options.owner; + } + this.egw().open(null, 'calendar', 'add', options, '_blank'); + return false; + } }, /**