From cd74ebc1b838dc63ff528693c8212c4192211916 Mon Sep 17 00:00:00 2001 From: greta Date: Wed, 23 Oct 2024 14:42:39 +0200 Subject: [PATCH 1/2] feat: create a readonly contactdetails Signed-off-by: greta --- src/components/ReadOnlyContactDetails.vue | 443 ++++++++++++++++++++++ 1 file changed, 443 insertions(+) create mode 100644 src/components/ReadOnlyContactDetails.vue diff --git a/src/components/ReadOnlyContactDetails.vue b/src/components/ReadOnlyContactDetails.vue new file mode 100644 index 000000000..da3cfe340 --- /dev/null +++ b/src/components/ReadOnlyContactDetails.vue @@ -0,0 +1,443 @@ + + + + + + + From a09618304d1f648da5d6b6b2f474b1be6442a856 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Wed, 30 Oct 2024 13:39:09 +0100 Subject: [PATCH 2/2] fixup! feat: create a readonly contactdetails --- lib/AppInfo/Application.php | 3 + lib/Event/LoadContactsOcaApiEvent.php | 15 ++ lib/Listener/LoadContactsOcaApi.php | 34 +++ src/oca.js | 26 +++ src/oca/mountContactDetails.js | 48 +++++ .../ReadOnlyContactDetails.vue | 196 ++++++++---------- vite.config.js | 1 + 7 files changed, 218 insertions(+), 105 deletions(-) create mode 100644 lib/Event/LoadContactsOcaApiEvent.php create mode 100644 lib/Listener/LoadContactsOcaApi.php create mode 100644 src/oca.js create mode 100644 src/oca/mountContactDetails.js rename src/{components => views}/ReadOnlyContactDetails.vue (69%) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 31f0f19a4..aebba7b70 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -6,7 +6,9 @@ namespace OCA\Contacts\AppInfo; use OCA\Contacts\Dav\PatchPlugin; +use OCA\Contacts\Event\LoadContactsOcaApiEvent; use OCA\Contacts\Listener\LoadContactsFilesActions; +use OCA\Contacts\Listener\LoadContactsOcaApi; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; @@ -28,6 +30,7 @@ public function __construct() { public function register(IRegistrationContext $context): void { $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadContactsFilesActions::class); + $context->registerEventListener(LoadContactsOcaApiEvent::class, LoadContactsOcaApi::class); } public function boot(IBootContext $context): void { diff --git a/lib/Event/LoadContactsOcaApiEvent.php b/lib/Event/LoadContactsOcaApiEvent.php new file mode 100644 index 000000000..4418c45c0 --- /dev/null +++ b/lib/Event/LoadContactsOcaApiEvent.php @@ -0,0 +1,15 @@ +initialState->provideInitialState('supportedNetworks', []); + Util::addScript(Application::APP_ID, 'contacts-oca'); + } +} diff --git a/src/oca.js b/src/oca.js new file mode 100644 index 000000000..6bc360184 --- /dev/null +++ b/src/oca.js @@ -0,0 +1,26 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +// eslint-disable-next-line import/no-unresolved, n/no-missing-import +import 'vite/modulepreload-polyfill' + +// Global scss sheets +import './css/contacts.scss' + +// Dialogs css +import '@nextcloud/dialogs/style.css' + +window.OCA ??= {} +window.OCA.Contacts = { + /** + * @param {HTMLElement} el Html element to mount the component at + * @param {string} contactEmailAddress Email address of the contact whose details to display + * @return {Promise} Mounted Vue instance (vm) + */ + async mountContactDetails(el, contactEmailAddress) { + const { mountContactDetails } = await import('./oca/mountContactDetails.js') + return mountContactDetails(el, contactEmailAddress) + }, +} diff --git a/src/oca/mountContactDetails.js b/src/oca/mountContactDetails.js new file mode 100644 index 000000000..091a9ab51 --- /dev/null +++ b/src/oca/mountContactDetails.js @@ -0,0 +1,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} + */ +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 +} diff --git a/src/components/ReadOnlyContactDetails.vue b/src/views/ReadOnlyContactDetails.vue similarity index 69% rename from src/components/ReadOnlyContactDetails.vue rename to src/views/ReadOnlyContactDetails.vue index da3cfe340..7af32bad3 100644 --- a/src/components/ReadOnlyContactDetails.vue +++ b/src/views/ReadOnlyContactDetails.vue @@ -4,55 +4,54 @@ -->