diff --git a/calendar/js/app.js b/calendar/js/app.js index 1d9e2b5271..bf5385cbab 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1456,13 +1456,37 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( _action.menu_context && _action.menu_context.event ) { - // Context menu has position information - var date = _events[0].iface.getWidget()._get_time_from_position(_action.menu_context.event.offsetX, _action.menu_context.event.offsetY); + // Non-row space in planner + // Context menu has position information, but target is not what we expact + var target = jQuery('.calendar_plannerGrid',_action.menu_context.event.currentTarget); + var y = _action.menu_context.event.pageY - target.offset().top; + var x = _action.menu_context.event.pageX - target.offset().left; + var date = _events[0].iface.getWidget()._get_time_from_position(x, y); if(date) { context.start = date.toJSON(); } } + else if (_events[0].iface.getWidget() && _events[0].iface.getWidget().instanceOf(et2_calendar_planner_row)) + { + // Empty space on a planner row + var widget = _events[0].iface.getWidget(); + var parent = widget.getParent(); + if(parent.options.group_by == 'month') + { + var date = parent._get_time_from_position(_action.menu_context.event.clientX, _action.menu_context.event.clientY); + } + else + { + var date = parent._get_time_from_position(_action.menu_context.event.offsetX, _action.menu_context.event.offsetY); + } + if(date) + { + context.start = date.toJSON(); + } + jQuery.extend(context, widget.getDOMNode().dataset); + + } else if (_events[0].iface.getWidget() && _events[0].iface.getWidget().instanceOf(et2_valueWidget)) { // Able to extract something from the widget diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index eb28b48f19..217a17794f 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -2211,7 +2211,9 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e var interval = egw.preference('interval','calendar') || 30; // Relative horizontal position, as a percentage - var rel_x = Math.min(x / jQuery('.calendar_eventRows',this.div).width(),1); + var width = 0; + jQuery('.calendar_eventRows',this.div).each(function() {width = Math.max(width,jQuery(this).width());}); + var rel_x = Math.min(x / width,1); // Relative time, in minutes from start var rel_time = 0; diff --git a/calendar/js/et2_widget_planner_row.js b/calendar/js/et2_widget_planner_row.js index 6f4f87747f..7e713bb8b1 100644 --- a/calendar/js/et2_widget_planner_row.js +++ b/calendar/js/et2_widget_planner_row.js @@ -76,7 +76,9 @@ var et2_calendar_planner_row = (function(){ "use strict"; return et2_valueWidget this.set_label(this.options.label); this._draw(); - this._link_actions([]); + // Actions are set on the parent, so we need to explicitly get in here + // and get ours + this._link_actions(this._parent.options.actions || []); return true; }, @@ -306,11 +308,14 @@ var et2_calendar_planner_row = (function(){ "use strict"; return et2_valueWidget _get_action_links: function(actions) { var action_links = []; - // TODO: determine which actions are allowed without an action (empty actions) + + // Only these actions are allowed without a selection (empty actions) + var empty_actions = ['add']; + for(var i in actions) { var action = actions[i]; - if(action.type == 'drop') + if(empty_actions.indexOf(action.id) !== -1 || action.type == 'drop') { action_links.push(typeof action.id != 'undefined' ? action.id : i); }