55import { showInfo } from '@nextcloud/dialogs'
66import { emit } from '@nextcloud/event-bus'
77import { translate as t } from '@nextcloud/l10n'
8- import { generateUrl } from '@nextcloud/router'
98import { errorCatchAsync } from '@/fullcalendar/utils/errors.js'
109import useSettingsStore from '@/store/settings.js'
1110import useWidgetStore from '@/store/widget.js'
@@ -28,7 +27,7 @@ import {
2827 */
2928export default function ( router , route , window , isWidget = false , ref = undefined ) {
3029 const widgetStore = useWidgetStore ( )
31- return errorCatchAsync ( function ( { event } ) {
30+ return errorCatchAsync ( function ( { event, jsEvent } ) {
3231 if ( isWidget ) {
3332 widgetStore . setWidgetRef ( { widgetRef : ref . fullCalendar . $el } )
3433 }
@@ -38,7 +37,7 @@ export default function(router, route, window, isWidget = false, ref = undefined
3837 break
3938
4039 case 'VTODO' :
41- handleToDoClick ( event , route , window , isWidget )
40+ handleToDoClick ( event , route , jsEvent , isWidget )
4241 break
4342 }
4443 } , 'eventClick' )
@@ -94,13 +93,14 @@ function handleEventClick(event, router, route, window, isWidget = false) {
9493 *
9594 * @param {EventDef } event FullCalendar event
9695 * @param {object } route The current Vue route
97- * @param {Window } window The window object
96+ * @param {MouseEvent } jsEvent The native click event
9897 * @param {boolean } isWidget Whether the calendar is embedded as a widget
9998 */
100- function handleToDoClick ( event , route , window , isWidget = false ) {
99+ function handleToDoClick ( event , route , jsEvent , isWidget = false ) {
101100 const settingsStore = useSettingsStore ( )
102101
103102 if ( getViewMode ( route . name , isWidget ) !== ViewMode . USER ) {
103+ jsEvent ?. preventDefault ( )
104104 return
105105 }
106106
@@ -111,9 +111,8 @@ function handleToDoClick(event, route, window, isWidget = false) {
111111 emit ( 'calendar:handle-todo-click' , { calendarId, taskId } )
112112
113113 if ( ! settingsStore . tasksEnabled ) {
114+ jsEvent ?. preventDefault ( )
114115 showInfo ( t ( 'calendar' , 'Please ask your administrator to enable the Tasks App.' ) )
115116 return
116117 }
117- const url = `apps/tasks/calendars/${ encodeURIComponent ( calendarId ) } /tasks/${ encodeURIComponent ( taskId ) } `
118- window . open ( generateUrl ( url ) , '_blank' )
119118}
0 commit comments