Skip to content

Commit 771b6da

Browse files
committed
Handle clicks on calendar entries
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 9e95155 commit 771b6da

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

lib/Listeners/BeforeTemplateRenderedListener.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@
2929
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
3030
use OCP\EventDispatcher\Event;
3131
use OCP\EventDispatcher\IEventListener;
32+
use OCP\IRequest;
3233
use OCP\Util;
3334

3435
class BeforeTemplateRenderedListener implements IEventListener {
36+
private $request;
37+
38+
public function __construct(IRequest $request) {
39+
$this->request = $request;
40+
}
41+
3542
public function handle(Event $event): void {
3643
if (!($event instanceof BeforeTemplateRenderedEvent)) {
3744
return;
@@ -41,5 +48,9 @@ public function handle(Event $event): void {
4148
return;
4249
}
4350
Util::addStyle('deck', 'deck');
51+
52+
if (strpos($this->request->getPathInfo(), '/apps/calendar') === 0) {
53+
Util::addScript('deck', 'calendar');
54+
}
4455
}
4556
}

src/init-calendar.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
3+
*
4+
* @author Julius Härtl <jus@bitgrid.net>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
import { subscribe } from '@nextcloud/event-bus'
24+
import { generateUrl } from '@nextcloud/router'
25+
26+
subscribe('calendar:handle-todo-click', ({ calendarId, taskId }) => {
27+
const deckAppPrefix = 'app-generated--deck--board-'
28+
if (calendarId.startsWith(deckAppPrefix)) {
29+
const board = calendarId.substr(deckAppPrefix.length)
30+
const card = taskId.substr('card-'.length).replace('.ics', '')
31+
console.debug('[deck] Clicked task matches deck calendar pattern')
32+
window.location = generateUrl(`apps/deck/#/board/${board}/card/${card}`)
33+
}
34+
})

webpack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const config = {
66
entry: {
77
collections: path.join(__dirname, 'src', 'init-collections.js'),
88
dashboard: path.join(__dirname, 'src', 'init-dashboard.js'),
9+
calendar: path.join(__dirname, 'src', 'init-calendar.js'),
910
},
1011
output: {
1112
filename: '[name].js',

0 commit comments

Comments
 (0)