Skip to content

Commit

Permalink
feat(calendar): Add double click to calendar create events
Browse files Browse the repository at this point in the history
  • Loading branch information
WoodySlum committed Jan 9, 2024
1 parent 930a06e commit 68398d2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 68398d2

Please sign in to comment.