2021-12-07 09:05:52 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
// Copyright © 2021 Hardcore Engineering Inc.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2022-09-21 08:08:25 +00:00
|
|
|
import { Contact, Employee, Organization } from '@hcengineering/contact'
|
|
|
|
import { getClient } from '@hcengineering/presentation'
|
2022-07-02 18:49:22 +00:00
|
|
|
import contact from '../plugin'
|
2023-03-09 09:05:42 +00:00
|
|
|
import EmployeePresenter from './EmployeePresenter.svelte'
|
2021-12-07 09:05:52 +00:00
|
|
|
|
|
|
|
import OrganizationPresenter from './OrganizationPresenter.svelte'
|
|
|
|
import PersonPresenter from './PersonPresenter.svelte'
|
|
|
|
|
|
|
|
export let value: Contact
|
2023-03-17 03:52:32 +00:00
|
|
|
export let inline: boolean = false
|
2022-06-07 04:10:34 +00:00
|
|
|
export let isInteractive = true
|
2021-12-07 09:05:52 +00:00
|
|
|
|
|
|
|
function isPerson (value: Contact): boolean {
|
|
|
|
const client = getClient()
|
|
|
|
const hierarchy = client.getHierarchy()
|
|
|
|
return hierarchy.isDerived(value._class, contact.class.Person)
|
|
|
|
}
|
2022-07-02 18:49:22 +00:00
|
|
|
function isEmployee (value: Contact): boolean {
|
|
|
|
const client = getClient()
|
|
|
|
const hierarchy = client.getHierarchy()
|
|
|
|
return hierarchy.isDerived(value._class, contact.class.Employee)
|
|
|
|
}
|
2022-06-07 04:10:34 +00:00
|
|
|
const toOrg = (contact: Contact) => contact as Organization
|
2022-07-02 18:49:22 +00:00
|
|
|
const toEmployee = (contact: Contact) => contact as Employee
|
2021-12-07 09:05:52 +00:00
|
|
|
</script>
|
|
|
|
|
2023-03-09 09:05:42 +00:00
|
|
|
{#if isEmployee(value)}
|
2023-03-17 03:52:32 +00:00
|
|
|
<EmployeePresenter {isInteractive} value={toEmployee(value)} {inline} />
|
2023-03-09 09:05:42 +00:00
|
|
|
{:else if isPerson(value)}
|
2023-03-17 03:52:32 +00:00
|
|
|
<PersonPresenter {isInteractive} {value} {inline} />
|
2021-12-07 09:05:52 +00:00
|
|
|
{:else}
|
2023-03-17 03:52:32 +00:00
|
|
|
<OrganizationPresenter value={toOrg(value)} {inline} />
|
2021-12-07 09:05:52 +00:00
|
|
|
{/if}
|