Skip to content

Commit 6861179

Browse files
committed
Implement file reference wiget
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 2892707 commit 6861179

19 files changed

+504
-5
lines changed

apps/files/composer/composer/autoload_classmap.php

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php',
4848
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
4949
'OCA\\Files\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php',
50+
'OCA\\Files\\Listener\\RenderReferenceEventListener' => $baseDir . '/../lib/Listener/RenderReferenceEventListener.php',
5051
'OCA\\Files\\Migration\\Version11301Date20191205150729' => $baseDir . '/../lib/Migration/Version11301Date20191205150729.php',
5152
'OCA\\Files\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
5253
'OCA\\Files\\Search\\FilesSearchProvider' => $baseDir . '/../lib/Search/FilesSearchProvider.php',

apps/files/composer/composer/autoload_static.php

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class ComposerStaticInitFiles
6262
'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
6363
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
6464
'OCA\\Files\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php',
65+
'OCA\\Files\\Listener\\RenderReferenceEventListener' => __DIR__ . '/..' . '/../lib/Listener/RenderReferenceEventListener.php',
6566
'OCA\\Files\\Migration\\Version11301Date20191205150729' => __DIR__ . '/..' . '/../lib/Migration/Version11301Date20191205150729.php',
6667
'OCA\\Files\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
6768
'OCA\\Files\\Search\\FilesSearchProvider' => __DIR__ . '/..' . '/../lib/Search/FilesSearchProvider.php',

apps/files/lib/AppInfo/Application.php

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use OCA\Files\Event\LoadSidebar;
4545
use OCA\Files\Listener\LegacyLoadAdditionalScriptsAdapter;
4646
use OCA\Files\Listener\LoadSidebarListener;
47+
use OCA\Files\Listener\RenderReferenceEventListener;
4748
use OCA\Files\Notification\Notifier;
4849
use OCA\Files\Search\FilesSearchProvider;
4950
use OCA\Files\Service\TagService;
@@ -52,6 +53,7 @@
5253
use OCP\AppFramework\Bootstrap\IBootContext;
5354
use OCP\AppFramework\Bootstrap\IBootstrap;
5455
use OCP\AppFramework\Bootstrap\IRegistrationContext;
56+
use OCP\Collaboration\Reference\RenderReferenceEvent;
5557
use OCP\Collaboration\Resources\IProviderManager;
5658
use OCP\IConfig;
5759
use OCP\IL10N;
@@ -116,6 +118,7 @@ public function register(IRegistrationContext $context): void {
116118

117119
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
118120
$context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class);
121+
$context->registerEventListener(RenderReferenceEvent::class, RenderReferenceEventListener::class);
119122

120123
$context->registerSearchProvider(FilesSearchProvider::class);
121124

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
6+
*
7+
* @author Julius Härtl <jus@bitgrid.net>
8+
*
9+
* @license GNU AGPL version 3 or any later version
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Affero General Public License as
13+
* published by the Free Software Foundation, either version 3 of the
14+
* License, or (at your option) any later version.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*/
24+
25+
namespace OCA\Files\Listener;
26+
27+
use OCP\Collaboration\Reference\RenderReferenceEvent;
28+
use OCP\EventDispatcher\Event;
29+
use OCP\EventDispatcher\IEventListener;
30+
31+
class RenderReferenceEventListener implements IEventListener {
32+
public function handle(Event $event): void {
33+
if (!$event instanceof RenderReferenceEvent) {
34+
return;
35+
}
36+
37+
\OCP\Util::addScript('files', 'reference-files');
38+
}
39+
}

apps/files/src/reference-files.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @copyright Copyright (c) 2022 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+
import Vue from 'vue'
23+
import { translate as t } from '@nextcloud/l10n'
24+
25+
import { registerWidget } from '@nextcloud/vue-richtext'
26+
27+
import FileWidget from './views/ReferenceFileWidget.vue'
28+
29+
Vue.mixin({
30+
methods: {
31+
t,
32+
},
33+
})
34+
35+
registerWidget('file', (el, { richObjectType, richObject, accessible }) => {
36+
const Widget = Vue.extend(FileWidget)
37+
new Widget({
38+
propsData: {
39+
richObjectType,
40+
richObject,
41+
accessible,
42+
},
43+
}).$mount(el)
44+
})

0 commit comments

Comments
 (0)