-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create a readonly contactdetails
Signed-off-by: greta <gretadoci@gmail.com> Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
- Loading branch information
Showing
7 changed files
with
434 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Contacts\Event; | ||
|
||
use OCP\EventDispatcher\Event; | ||
|
||
class LoadContactsOcaApiEvent extends Event { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Contacts\Listener; | ||
|
||
use OCA\Contacts\AppInfo\Application; | ||
use OCA\Contacts\Event\LoadContactsOcaApiEvent; | ||
use OCP\AppFramework\Services\IInitialState; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\Util; | ||
|
||
class LoadContactsOcaApi implements IEventListener { | ||
public function __construct( | ||
private IInitialState $initialState, | ||
) { | ||
} | ||
|
||
public function handle(Event $event): void { | ||
if (!($event instanceof LoadContactsOcaApiEvent)) { | ||
return; | ||
} | ||
|
||
// TODO: do we need to provide more initial state? | ||
$this->initialState->provideInitialState('supportedNetworks', []); | ||
Util::addScript(Application::APP_ID, 'contacts-oca'); | ||
Util::addStyle(Application::APP_ID, 'contacts-oca'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* 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' | ||
|
||
import { mountContactDetails } from './oca/mountContactDetails.js' | ||
|
||
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<object>} Mounted Vue instance (vm) | ||
*/ | ||
async mountContactDetails(el, contactEmailAddress) { | ||
return mountContactDetails(el, contactEmailAddress) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<object>} | ||
*/ | ||
export 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 | ||
} |
Oops, something went wrong.