2021-08-07 14:49:14 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
// Copyright © 2021 Hardcore Engineering Inc.
|
2021-12-07 09:05:52 +00:00
|
|
|
//
|
2021-08-07 14:49:14 +00:00
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
2021-12-07 09:05:52 +00:00
|
|
|
//
|
2021-08-07 14:49:14 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
2021-12-07 09:05:52 +00:00
|
|
|
//
|
2021-08-07 14:49:14 +00:00
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
2022-01-21 09:05:55 +00:00
|
|
|
import { Contact, formatName } from '@anticrm/contact'
|
|
|
|
import { Class, Client, Ref } from '@anticrm/core'
|
|
|
|
import { Resources } from '@anticrm/platform'
|
|
|
|
import { Avatar, ObjectSearchResult, UserInfo } from '@anticrm/presentation'
|
2022-01-31 09:06:30 +00:00
|
|
|
import Channels from './components/Channels.svelte'
|
2022-02-22 09:09:13 +00:00
|
|
|
import ChannelsEditor from './components/ChannelsEditor.svelte'
|
2021-08-31 10:42:40 +00:00
|
|
|
import ChannelsPresenter from './components/ChannelsPresenter.svelte'
|
2022-02-07 09:03:14 +00:00
|
|
|
import ChannelsView from './components/ChannelsView.svelte'
|
2022-04-20 07:56:45 +00:00
|
|
|
import ChannelsDropdown from './components/ChannelsDropdown.svelte'
|
2022-01-21 09:05:55 +00:00
|
|
|
import ContactPresenter from './components/ContactPresenter.svelte'
|
|
|
|
import Contacts from './components/Contacts.svelte'
|
2021-12-06 10:07:08 +00:00
|
|
|
import CreateOrganization from './components/CreateOrganization.svelte'
|
|
|
|
import CreateOrganizations from './components/CreateOrganizations.svelte'
|
2022-01-21 09:05:55 +00:00
|
|
|
import CreatePerson from './components/CreatePerson.svelte'
|
|
|
|
import CreatePersons from './components/CreatePersons.svelte'
|
|
|
|
import EditOrganization from './components/EditOrganization.svelte'
|
|
|
|
import EditPerson from './components/EditPerson.svelte'
|
|
|
|
import OrganizationPresenter from './components/OrganizationPresenter.svelte'
|
|
|
|
import PersonPresenter from './components/PersonPresenter.svelte'
|
2021-12-06 10:07:08 +00:00
|
|
|
import SocialEditor from './components/SocialEditor.svelte'
|
2022-01-21 09:05:55 +00:00
|
|
|
import contact from './plugin'
|
2022-03-10 09:04:08 +00:00
|
|
|
import EmployeeAccountPresenter from './components/EmployeeAccountPresenter.svelte'
|
2022-03-17 09:39:57 +00:00
|
|
|
import OrganizationEditor from './components/OrganizationEditor.svelte'
|
|
|
|
import OrganizationSelector from './components/OrganizationSelector.svelte'
|
2021-12-07 09:05:52 +00:00
|
|
|
|
2022-04-20 07:56:45 +00:00
|
|
|
export { Channels, ChannelsEditor, ContactPresenter, ChannelsView, OrganizationSelector, ChannelsDropdown }
|
2021-08-07 14:49:14 +00:00
|
|
|
|
2022-04-29 05:27:17 +00:00
|
|
|
async function queryContact (
|
|
|
|
_class: Ref<Class<Contact>>,
|
|
|
|
client: Client,
|
|
|
|
search: string
|
|
|
|
): Promise<ObjectSearchResult[]> {
|
|
|
|
return (await client.findAll(_class, { name: { $like: `%${search}%` } }, { limit: 200 })).map((e) => ({
|
2022-01-21 09:05:55 +00:00
|
|
|
doc: e,
|
|
|
|
title: formatName(e.name),
|
|
|
|
icon: Avatar,
|
|
|
|
iconProps: { size: 'x-small', avatar: e.avatar },
|
|
|
|
component: UserInfo,
|
|
|
|
componentProps: { size: 'x-small' }
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2021-12-07 09:05:52 +00:00
|
|
|
export default async (): Promise<Resources> => ({
|
2021-08-07 14:49:14 +00:00
|
|
|
component: {
|
2022-03-17 09:39:57 +00:00
|
|
|
OrganizationEditor,
|
2021-12-07 09:05:52 +00:00
|
|
|
ContactPresenter,
|
2021-08-31 10:42:40 +00:00
|
|
|
PersonPresenter,
|
2021-12-06 10:07:08 +00:00
|
|
|
OrganizationPresenter,
|
|
|
|
ChannelsPresenter,
|
|
|
|
CreatePerson,
|
|
|
|
CreateOrganization,
|
|
|
|
EditPerson,
|
|
|
|
EditOrganization,
|
|
|
|
CreatePersons,
|
|
|
|
CreateOrganizations,
|
2022-01-11 09:05:53 +00:00
|
|
|
SocialEditor,
|
2022-03-10 09:04:08 +00:00
|
|
|
Contacts,
|
|
|
|
EmployeeAccountPresenter
|
2022-01-21 09:05:55 +00:00
|
|
|
},
|
|
|
|
completion: {
|
|
|
|
EmployeeQuery: async (client: Client, query: string) => await queryContact(contact.class.Employee, client, query),
|
|
|
|
PersonQuery: async (client: Client, query: string) => await queryContact(contact.class.Person, client, query),
|
2022-04-29 05:27:17 +00:00
|
|
|
OrganizationQuery: async (client: Client, query: string) =>
|
|
|
|
await queryContact(contact.class.Organization, client, query)
|
2021-12-07 09:05:52 +00:00
|
|
|
}
|
2021-08-07 14:49:14 +00:00
|
|
|
})
|