-
Notifications
You must be signed in to change notification settings - Fork 303
Expand file tree
/
Copy pathreference.js
More file actions
54 lines (46 loc) · 1.74 KB
/
reference.js
File metadata and controls
54 lines (46 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { getRequestToken } from '@nextcloud/auth'
import { translate, translatePlural } from '@nextcloud/l10n'
import { linkTo } from '@nextcloud/router'
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { NcCustomPickerRenderResult, registerWidget } from '@nextcloud/vue/functions/registerReference'
import '../css/calendar.scss'
__webpack_nonce__ = btoa(getRequestToken())
__webpack_public_path__ = linkTo('calendar', 'js/') // eslint-disable-line
// eslint-disable-next-line no-unused-vars
registerWidget('calendar_widget', async (el, { richObjectType, richObject, accessible, interactive }) => {
const { default: Vue } = await import('vue')
const { default: Calendar } = await import('./views/Calendar.vue')
const { createPinia, PiniaVuePlugin } = await import('pinia')
Vue.use(PiniaVuePlugin)
const pinia = createPinia()
Vue.prototype.$t = translate
Vue.prototype.$n = translatePlural
Vue.mixin({ methods: { t, n } })
const Widget = Vue.extend(Calendar)
const vueElement = new Widget({
pinia,
propsData: {
isWidget: true,
isPublic: richObject.isPublic,
referenceToken: richObject?.token,
url: richObject.url,
},
}).$mount(el)
return new NcCustomPickerRenderResult(vueElement.$el, vueElement)
}, (el, renderResult) => {
renderResult.object.$destroy()
}, true)
registerWidget('calendar_event', async (el, { richObject }) => {
const { createApp } = await import('vue')
const { default: EventReferenceWidget } = await import('./views/EventReferenceWidget.vue')
const app = createApp(EventReferenceWidget, {
richObject,
})
app.mount(el)
return new NcCustomPickerRenderResult(el, app)
}, (el, renderResult) => {
renderResult.object.$destroy()
})