mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-14 20:14:11 +01:00
- Fix drag & drop an event inside a group or consolidated calendar asked to move or invite
- Fix some drag to create bugs throwing errors
This commit is contained in:
parent
4e0fbfad9c
commit
23edb3cc5a
@ -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.
|
||||
*
|
||||
@ -306,6 +321,10 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.
|
||||
.css('top', '').css('left','')
|
||||
.appendTo(ui.helper);
|
||||
ui.helper.width(jQuery(this).width());
|
||||
|
||||
// Cancel drag to create, we're dragging an existing event
|
||||
timegrid.drag_create.start = null;
|
||||
timegrid._drag_create_end();
|
||||
})
|
||||
.on('mousemove', function(event) {
|
||||
timegrid._get_time_from_position(event.clientX, event.clientY);
|
||||
@ -315,7 +334,9 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.
|
||||
{
|
||||
timegrid.gridHover.hide();
|
||||
}
|
||||
});
|
||||
})
|
||||
.on('mousedown', jQuery.proxy(this._mouse_down, this))
|
||||
.on('mouseup', jQuery.proxy(this._mouse_up, this));
|
||||
return true;
|
||||
},
|
||||
|
||||
@ -1762,6 +1783,9 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.
|
||||
{
|
||||
var result = true;
|
||||
|
||||
// Drag to create in progress
|
||||
if(this.drag_create.start !== null) return;
|
||||
|
||||
// Is this click in the event stuff, or in the header?
|
||||
if(_ev.target.dataset.id || jQuery(_ev.target).parents('.calendar_calEvent').length)
|
||||
{
|
||||
@ -1840,6 +1864,110 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Mousedown handler to support drag to create
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
*/
|
||||
_mouse_down: function(event)
|
||||
{
|
||||
var start = jQuery.extend({},this.gridHover[0].dataset);
|
||||
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));
|
||||
this.date_helper.set_month(start.date.substring(4,6));
|
||||
this.date_helper.set_date(start.date.substring(6,8));
|
||||
if(start.hour)
|
||||
{
|
||||
this.date_helper.set_hours(start.hour);
|
||||
}
|
||||
if(start.minute)
|
||||
{
|
||||
this.date_helper.set_minutes(start.minute);
|
||||
}
|
||||
start.date = this.date_helper.get_value();
|
||||
|
||||
this.gridHover.css('cursor', 'ns-resize');
|
||||
|
||||
// Start update
|
||||
var timegrid = this;
|
||||
this.div.on('mousemove.dragcreate', function()
|
||||
{
|
||||
if(timegrid.drag_create.event && timegrid.drag_create.parent && timegrid.drag_create.end)
|
||||
{
|
||||
var end = jQuery.extend({}, timegrid.gridHover[0].dataset);
|
||||
if(end.date)
|
||||
{
|
||||
timegrid.date_helper.set_year(end.date.substring(0,4));
|
||||
timegrid.date_helper.set_month(end.date.substring(4,6));
|
||||
timegrid.date_helper.set_date(end.date.substring(6,8));
|
||||
if(end.hour)
|
||||
{
|
||||
timegrid.date_helper.set_hours(end.hour);
|
||||
}
|
||||
if(end.minute)
|
||||
{
|
||||
timegrid.date_helper.set_minutes(end.minute);
|
||||
}
|
||||
timegrid.drag_create.end.date = timegrid.date_helper.get_value();
|
||||
}
|
||||
timegrid._drag_update_event();
|
||||
}
|
||||
});
|
||||
}
|
||||
return this._drag_create_start(start);
|
||||
},
|
||||
|
||||
/**
|
||||
* Mouseup handler to support drag to create
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
*/
|
||||
_mouse_up: function(event)
|
||||
{
|
||||
var end = jQuery.extend({}, this.gridHover[0].dataset);
|
||||
if(end.date)
|
||||
{
|
||||
this.date_helper.set_year(end.date.substring(0,4));
|
||||
this.date_helper.set_month(end.date.substring(4,6));
|
||||
this.date_helper.set_date(end.date.substring(6,8));
|
||||
if(end.hour)
|
||||
{
|
||||
this.date_helper.set_hours(end.hour);
|
||||
}
|
||||
if(end.minute)
|
||||
{
|
||||
this.date_helper.set_minutes(end.minute);
|
||||
}
|
||||
end.date = this.date_helper.get_value();
|
||||
}
|
||||
this.div.off('mousemove.dragcreate');
|
||||
this.gridHover.css('cursor', '');
|
||||
|
||||
return this._drag_create_end(end);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get time from position for drag and drop
|
||||
*
|
||||
@ -1888,6 +2016,8 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.
|
||||
height: $node.css('padding-bottom')
|
||||
});
|
||||
day = node;
|
||||
this.gridHover
|
||||
.attr('data-non_blocking','true');
|
||||
break;
|
||||
}
|
||||
if($node.hasClass('calendar_calDayCol'))
|
||||
|
@ -57,6 +57,14 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend
|
||||
|
||||
this.loader = jQuery('<div class="egw-loading-prompt-container ui-front loading"></div>');
|
||||
this.update_timer = null;
|
||||
|
||||
// Used to support dragging on empty space to create an event
|
||||
this.drag_create = {
|
||||
start: null,
|
||||
end: null,
|
||||
parent: null,
|
||||
event: null
|
||||
};
|
||||
},
|
||||
|
||||
destroy: function destroy() {
|
||||
|
Loading…
Reference in New Issue
Block a user