feat(calendar): Add double click to calendar create events

This commit is contained in:
smizrahi
2024-01-09 14:10:05 +01:00
parent 930a06e520
commit 68398d2086
2 changed files with 31 additions and 0 deletions

View File

@@ -66,6 +66,7 @@
// Update the component being dragged
$rootScope.$on('calendar:dragend', updateComponentFromGhost);
$rootScope.$on('calendar:doubleclick', updateComponentFromGhost);
$scope.$on('$destroy', function() {
// Deregister hotkeys

View File

@@ -34,6 +34,7 @@
// Start dragging on mousedown
element.on('mousedown', onDragDetect);
element.on('dblclick', onDoubleClick);
// Deregister listeners when removing the element from the DOM
scope.$on('$destroy', function() {
@@ -218,6 +219,35 @@
});
}
function onDoubleClick(ev) {
var block, pointerHandler, startDate, newData, newComponent;
startDate = calendarDayCtrl.dayString.parseDate(Preferences.$mdDateLocaleProvider, '%Y-%m-%e');
newData = {
type: 'appointment',
pid: Calendar.$defaultCalendar(),
summary: l('New Event'),
startDate: startDate,
isAllDay: 1
};
newComponent = new Component(newData);
block = {
component: newComponent,
dayNumber: calendarDayCtrl.dayNumber,
length: 0
};
block.component.blocks = [block];
pointerHandler = new SOGoEventDragPointerHandler('double-click');
pointerHandler.initFromBlock(block);
// Update Component.$ghost
Component.$ghost.pointerHandler = pointerHandler;
Component.$ghost.component = block.component;
$rootScope.$emit('calendar:doubleclick');
}
/**
* SOGoCoordinates
*/