mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
Remove extra lookups (#963)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
16686010b0
commit
aa8519d02a
@ -134,7 +134,7 @@ export function createModel (builder: Builder): void {
|
||||
|
||||
const leadLookup: Lookup<Lead> =
|
||||
{
|
||||
attachedTo: [contact.class.Contact, { _id: { channels: contact.class.Channel } }],
|
||||
attachedTo: [contact.class.Contact, { _id: { channels: lead.mixin.Customer } }],
|
||||
state: task.class.State
|
||||
}
|
||||
|
||||
@ -161,9 +161,11 @@ export function createModel (builder: Builder): void {
|
||||
descriptor: task.viewlet.Kanban,
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
options: {
|
||||
lookup: leadLookup
|
||||
lookup: {
|
||||
attachedTo: lead.mixin.Customer
|
||||
}
|
||||
} as FindOptions<Doc>, // TODO: fix
|
||||
config: ['$lookup.customer', '$lookup.state']
|
||||
config: []
|
||||
})
|
||||
|
||||
builder.mixin(lead.class.Lead, core.class.Class, task.mixin.KanbanCard, {
|
||||
|
@ -210,8 +210,8 @@ export function createModel (builder: Builder): void {
|
||||
|
||||
const applicantKanbanLookup: Lookup<Applicant> =
|
||||
{
|
||||
attachedTo: [recruit.mixin.Candidate, { _id: { channels: contact.class.Channel } }],
|
||||
state: task.class.State
|
||||
attachedTo: recruit.mixin.Candidate,
|
||||
assignee: contact.class.Employee
|
||||
}
|
||||
|
||||
builder.createDoc(view.class.Viewlet, core.space.Model, {
|
||||
@ -221,7 +221,7 @@ export function createModel (builder: Builder): void {
|
||||
options: {
|
||||
lookup: applicantKanbanLookup
|
||||
} as FindOptions<Doc>, // TODO: fix
|
||||
config: ['$lookup.attachedTo', '$lookup.state', '$lookup.attachedTo.city', '$lookup.attachedTo.$lookup.channels']
|
||||
config: []
|
||||
})
|
||||
|
||||
builder.createDoc(view.class.Viewlet, core.space.Model, {
|
||||
|
@ -317,15 +317,10 @@ export function createModel (builder: Builder): void {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
options: {
|
||||
lookup: {
|
||||
state: task.class.State,
|
||||
assignee: contact.class.Employee
|
||||
}
|
||||
} as FindOptions<Doc>, // TODO: fix
|
||||
config: [
|
||||
// '$lookup.attachedTo',
|
||||
'$lookup.state',
|
||||
'$lookup.assignee'
|
||||
]
|
||||
config: []
|
||||
})
|
||||
|
||||
builder.mixin(task.class.Issue, core.class.Class, task.mixin.KanbanCard, {
|
||||
|
@ -115,20 +115,13 @@ export enum SortingOrder {
|
||||
* @public
|
||||
*/
|
||||
export type RefsAsDocs<T> = {
|
||||
[P in keyof T]: T[P] extends Ref<infer X> ? (T extends X ? X : X | WithLookup<X>) : never
|
||||
[P in keyof T]: T[P] extends Ref<infer X> | null ? (T extends X ? X : X | WithLookup<X>) : AttachedDoc[]
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type RemoveNever<T extends object> = Omit<T, KeysByType<T, never>>
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type LookupData<T extends Doc> = Partial<RemoveNever<RefsAsDocs<T>>> | RemoveNever<{
|
||||
[key: string]: Doc[]
|
||||
}>
|
||||
export type LookupData<T extends Doc> = Partial<RefsAsDocs<T>>
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
@ -45,8 +45,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-between">
|
||||
{#if object.$lookup?.customer}
|
||||
<ContactPresenter value={object.$lookup?.customer} />
|
||||
{#if object.$lookup?.attachedTo}
|
||||
<ContactPresenter value={object.$lookup?.attachedTo} />
|
||||
{/if}
|
||||
<div class="flex-row-center">
|
||||
{#if (object.attachments ?? 0) > 0}
|
||||
|
@ -54,7 +54,7 @@
|
||||
<div class="step-lr75"><CommentsPresenter value={object} /></div>
|
||||
{/if}
|
||||
</div>
|
||||
<Avatar size={'x-small'} />
|
||||
<Avatar avatar={object.$lookup?.assignee?.avatar} size={'x-small'} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -47,9 +47,8 @@
|
||||
<div class="step-lr75"><CommentsPresenter value={object} /></div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if object.$lookup}
|
||||
<!-- object.$lookup?.assignee?.avatar -->
|
||||
<Avatar avatar={undefined} size={'x-small'} />
|
||||
{#if object.$lookup?.assignee}
|
||||
<Avatar avatar={object.$lookup?.assignee?.avatar} size={'x-small'} />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user