summaryrefslogtreecommitdiffstats
path: root/src/oca/mountContactDetails.js
blob: 091a9ab511b3a7c34bb4126f35b34c63447a9d9d (plain)
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
/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import Vue from 'vue'
import ReadOnlyContactDetails from '../views/ReadOnlyContactDetails.vue'
import { createPinia, PiniaVuePlugin } from 'pinia'

/** GLOBAL COMPONENTS AND DIRECTIVE */
import ClickOutside from 'vue-click-outside'
import { Tooltip as VTooltip } from '@nextcloud/vue'

import store from '../store/index.js'
import logger from '../services/logger.js'

/**
 * @param {HTMLElement} el
 * @param {string} contactEmailAddress
 * @return {Promise<object>}
 */
export async function mountContactDetails(el, contactEmailAddress) {
	Vue.use(PiniaVuePlugin)
	const pinia = createPinia()

	// Register global directives
	Vue.directive('ClickOutside', ClickOutside)
	Vue.directive('Tooltip', VTooltip)

	Vue.prototype.t = t
	Vue.prototype.n = n

	Vue.prototype.appName = appName
	Vue.prototype.appVersion = appVersion
	Vue.prototype.logger = logger
	Vue.prototype.OC = window.OC
	Vue.prototype.OCA = window.OCA

	const Component = Vue.extend(ReadOnlyContactDetails)
	const vueElement = new Component({
		pinia,
		store,
		propsData: {
			contactEmailAddress,
		},
	}).$mount(el)
	return vueElement
}