client expose getModel; working ApplicationsPopup

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-27 11:06:55 +02:00
parent d805f87df7
commit 473fa9ba80
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
5 changed files with 33 additions and 14 deletions

View File

@ -35,6 +35,7 @@ export type TxHander = (tx: Tx) => void
export interface Client extends Storage { export interface Client extends Storage {
notify?: (tx: Tx) => void notify?: (tx: Tx) => void
getHierarchy: () => Hierarchy getHierarchy: () => Hierarchy
getModel: () => ModelDb
findOne: <T extends Doc>( findOne: <T extends Doc>(
_class: Ref<Class<T>>, _class: Ref<Class<T>>,
query: DocumentQuery<T>, query: DocumentQuery<T>,
@ -50,6 +51,8 @@ class ClientImpl implements Client {
getHierarchy (): Hierarchy { return this.hierarchy } getHierarchy (): Hierarchy { return this.hierarchy }
getModel (): ModelDb { return this.model }
async findAll<T extends Doc>( async findAll<T extends Doc>(
_class: Ref<Class<T>>, _class: Ref<Class<T>>,
query: DocumentQuery<T>, query: DocumentQuery<T>,

View File

@ -16,7 +16,7 @@
import { onDestroy } from 'svelte' import { onDestroy } from 'svelte'
import { Doc, Ref, Class, DocumentQuery, FindOptions, Client, Hierarchy, Tx, getCurrentAccount } from '@anticrm/core' import { Doc, Ref, Class, DocumentQuery, FindOptions, Client, Hierarchy, Tx, getCurrentAccount, ModelDb } from '@anticrm/core'
import { TxOperations } from '@anticrm/core' import { TxOperations } from '@anticrm/core'
import { LiveQuery as LQ } from '@anticrm/query' import { LiveQuery as LQ } from '@anticrm/query'
import core from '@anticrm/core' import core from '@anticrm/core'
@ -34,6 +34,10 @@ class UIClient extends TxOperations implements Client {
return this.client.getHierarchy() return this.client.getHierarchy()
} }
getModel (): ModelDb {
return this.client.getModel()
}
tx(tx: Tx): Promise<void> { tx(tx: Tx): Promise<void> {
return Promise.all([super.tx(tx), this.liveQuery.tx(tx)]) as unknown as Promise<void> return Promise.all([super.tx(tx), this.liveQuery.tx(tx)]) as unknown as Promise<void>
} }

View File

@ -16,7 +16,7 @@
import { import {
Ref, Class, Doc, Tx, DocumentQuery, TxCreateDoc, TxRemoveDoc, Client, Ref, Class, Doc, Tx, DocumentQuery, TxCreateDoc, TxRemoveDoc, Client,
FindOptions, TxUpdateDoc, _getOperator, TxProcessor, resultSort, SortingQuery, FindOptions, TxUpdateDoc, _getOperator, TxProcessor, resultSort, SortingQuery,
FindResult, Hierarchy, Refs, WithLookup, LookupData, TxMixin, TxPutBag FindResult, Hierarchy, Refs, WithLookup, LookupData, TxMixin, TxPutBag, ModelDb
} from '@anticrm/core' } from '@anticrm/core'
interface Query { interface Query {
@ -43,6 +43,10 @@ export class LiveQuery extends TxProcessor implements Client {
return this.client.getHierarchy() return this.client.getHierarchy()
} }
getModel (): ModelDb {
return this.client.getModel()
}
private match (q: Query, doc: Doc): boolean { private match (q: Query, doc: Doc): boolean {
if (!this.getHierarchy().isDerived(doc._class, q._class)) { if (!this.getHierarchy().isDerived(doc._class, q._class)) {
return false return false

View File

@ -16,23 +16,35 @@
<script lang="ts"> <script lang="ts">
import type { Candidate } from '@anticrm/recruit' import type { Applicant, Candidate } from '@anticrm/recruit'
import { CircleButton, Label } from '@anticrm/ui' import { CircleButton, Label } from '@anticrm/ui'
import Vacancy from './icons/Vacancy.svelte' import Vacancy from './icons/Vacancy.svelte'
import { getClient, createQuery } from '@anticrm/presentation'
import recruit from '@anticrm/recruit'
export let value: Candidate export let value: Candidate
const apps = [{ label: 'Lead analyst', description: 'Tesla' }, let applications: Applicant[] = []
{ label: 'Principal analyst', description: 'Google' }]
const query = createQuery()
$: query.query(recruit.class.Applicant, { candidate: value._id }, result => { applications = result })
const model = getClient().getModel()
function getApplicationLabel(app: Applicant): string {
return model.getObject(app.space).name
}
</script> </script>
<div class="flex-col"> <div class="flex-col">
{#each apps as app} {#each applications as app}
<div class="flex-row-center app"> <div class="flex-row-center app">
<div class="app-icon"><CircleButton icon={Vacancy} size={'large'} /></div> <div class="app-icon"><CircleButton icon={Vacancy} size={'large'} /></div>
<div class="flex-grow flex-col"> <div class="flex-grow flex-col">
<div class="overflow-label label">{app.label}</div> <div class="overflow-label label">{getApplicationLabel(app)}</div>
<div class="overflow-label desc">{app.description}</div> <div class="overflow-label desc">Cisco</div>
</div> </div>
</div> </div>
{/each} {/each}

View File

@ -17,19 +17,15 @@
<script lang="ts"> <script lang="ts">
import type { Candidate } from '@anticrm/recruit' import type { Candidate } from '@anticrm/recruit'
import { CircleButton, IconFile, Label, Tooltip } from '@anticrm/ui' import { IconFile, Tooltip } from '@anticrm/ui'
import Vacancy from './icons/Vacancy.svelte'
import ApplicationsPopup from './ApplicationsPopup.svelte' import ApplicationsPopup from './ApplicationsPopup.svelte'
export let value: Candidate export let value: Candidate
let trigger: HTMLElement
const apps = [{ label: 'Lead analyst', description: 'Tesla' },
{ label: 'Principal analyst', description: 'Google' }]
</script> </script>
{#if value.applications && value.applications > 0} {#if value.applications && value.applications > 0}
<Tooltip label={'Applications'} component={ApplicationsPopup} props={{ value: value }}> <Tooltip label={'Applications'} component={ApplicationsPopup} props={{ value }}>
<div class="flex-row-center"> <div class="flex-row-center">
<IconFile size={'small'} />&nbsp;{value.applications} <IconFile size={'small'} />&nbsp;{value.applications}
</div> </div>