Fix some bugs in drag to create event

- Firefox opened 2 popups, one for span and one for end time
- Dragging existing events longer or shorter created a new event also
- Did not work in dayview
- Categories from category planner were not set
This commit is contained in:
nathangray 2016-07-01 11:57:06 -06:00
parent a2d1131aa5
commit 0aaca03d89
4 changed files with 71 additions and 8 deletions

View File

@ -1057,6 +1057,9 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte
*/
click: function(_ev)
{
// Drag to create in progress
if(this._parent.drag_create.start !== null) return;
// Click on the title
if (jQuery(_ev.target).hasClass('calendar_calAddEvent'))
{

View File

@ -167,6 +167,21 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
}
},
/**
* If dragging to resize an event, abort drag to create
*
* @param {jQuery.Event} event
* @param {Object} ui
*/
start: function(event, ui)
{
if(planner.drag_create.start)
{
// Abort drag to create, we're dragging to resize
planner._drag_create_end({});
}
},
/**
* Triggered at the end of resizing the calEvent.
*
@ -598,7 +613,7 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
// Get its children immediately
egw.json(
this.getInstanceManager().app+'.etemplate_widget_menupopup.ajax_get_options.etemplate',
'EGroupware\\Api\\Etemplate\\Widget\\Select::ajax_get_options',
['select-cat',',,,calendar,'+cat_id[i]],
function(data) {
labels = labels.concat(data);
@ -1900,16 +1915,17 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
// Find the correct row so we know the parent
var row = event.target.closest('.calendar_plannerRowWidget');
var row_widget = null;
for(var i = 0; i < this._children.length && row; i++)
{
if(this._children[i].div[0] === row)
{
this.drag_create.parent = this._children[i];
// Clear cached events for re-layout
this._children[i]._cached_rows = [];
break;
}
}
return this._drag_create_start({date: time.toJSON()});
return this._drag_create_start(jQuery.extend({},this.drag_create.parent.node.dataset,{date: time.toJSON()}));
},
/**

View File

@ -230,6 +230,21 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.
}
},
/**
* If dragging to resize an event, abort drag to create
*
* @param {jQuery.Event} event
* @param {Object} ui
*/
start: function(event, ui)
{
if(timegrid.drag_create.start)
{
// Abort drag to create, we're dragging to resize
timegrid._drag_create_end({});
}
},
/**
* Triggered at the end of resizing the calEvent.
*
@ -1871,7 +1886,24 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.
if(start.date)
{
// Set parent for event
if(this.daily_owner)
{
// Each 'day' is the same date, different user
// Find the correct row so we know the parent
var col = event.target.closest('.calendar_calDayCol');
for(var i = 0; i < this._children.length && col; i++)
{
if(this._children[i].node === col)
{
this.drag_create.parent = this._children[i];
break;
}
}
}
else
{
this.drag_create.parent = this.getWidgetById(start.date);
}
// Format date
this.date_helper.set_year(start.date.substring(0,4));
@ -1918,6 +1950,8 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.
}
this.gridHover.css('cursor', '');
event.preventDefault();
return this._drag_create_end(end);
},

View File

@ -516,9 +516,16 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend
jQuery.extend(options,this.drag_create.start, end);
delete(options.date);
if (this.options.owner !== app.calendar.state.owner && !options.owner)
// Make sure parent is set, if needed
if (this.drag_create.parent && this.drag_create.parent.options.owner !== app.calendar.state.owner && !options.owner)
{
options.owner = this.options.owner;
options.owner = this.drag_create.parent.options.owner;
}
// Remove empties
for(var key in options)
{
if(!options[key]) delete options[key];
}
this.egw().open(null, 'calendar', 'add', options, '_blank');
@ -540,8 +547,11 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend
this.drag_create.start = null;
this.drag_create.end = null;
this.drag_create.parent = null;
if(this.drag_create.event)
{
this.drag_create.event.destroy();
this.drag_create.event = null;
}
return false;
}