mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-10 02:45:08 +00:00
fix(calendar(js)): swap start-end dates when delta is negative
When creating an event by drag'n'dropping from bottom to top, the original coordinate become the start date.
This commit is contained in:
@@ -222,16 +222,19 @@
|
||||
|
||||
// Adjust component or create new component through drag'n'drop
|
||||
function updateComponentFromGhost($event) {
|
||||
var component, pointerHandler, coordinates, delta, params, calendarNumber, activeCalendars;
|
||||
var component, pointerHandler, originalCoordinates, coordinates, delta, params, calendarNumber, activeCalendars;
|
||||
|
||||
component = Component.$ghost.component;
|
||||
pointerHandler = Component.$ghost.pointerHandler;
|
||||
|
||||
if (component.isNew) {
|
||||
originalCoordinates = pointerHandler.originalEventCoordinates;
|
||||
coordinates = pointerHandler.currentEventCoordinates;
|
||||
component.summary = '';
|
||||
if (component.isAllDay)
|
||||
coordinates.duration -= 96;
|
||||
if (coordinates.start < originalCoordinates.start)
|
||||
coordinates.duration *= -1;
|
||||
component.setDelta(coordinates.duration * 15);
|
||||
newComponent(null, 'appointment', component)
|
||||
.catch()
|
||||
|
||||
@@ -759,6 +759,13 @@
|
||||
* @param {number} delta - the number of minutes
|
||||
*/
|
||||
Component.prototype.setDelta = function(delta) {
|
||||
if (delta < 0) {
|
||||
var start = new Date(this.start.getTime());
|
||||
start.setMinutes(Math.round(start.getMinutes()/15)*15);
|
||||
start.addMinutes(delta);
|
||||
this.start = start;
|
||||
delta *= -1;
|
||||
}
|
||||
this.delta = delta;
|
||||
this.end = new Date(this.start.getTime());
|
||||
this.end.setMinutes(Math.round(this.end.getMinutes()/15)*15);
|
||||
|
||||
Reference in New Issue
Block a user