UBER-1129: Fix list support attached documents properly (#3889)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-10-26 10:33:24 +07:00 committed by GitHub
parent a92423d842
commit b0650fb8b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 18 deletions

View File

@ -40,7 +40,8 @@
export let shrink: number = 0 export let shrink: number = 0
export let isAction: boolean = false export let isAction: boolean = false
$: _object = object ?? value ?? [] $: _object =
(typeof object !== 'string' ? object : undefined) ?? (typeof value !== 'string' ? value : undefined) ?? []
const client = getClient() const client = getClient()
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -48,7 +49,7 @@
const docQuery: DocumentQuery<Employee> = { active: true } const docQuery: DocumentQuery<Employee> = { active: true }
const handleAssigneeChanged = async (newAssignee: Ref<Person> | undefined | null) => { const handleAssigneeChanged = async (newAssignee: Ref<Person> | undefined | null) => {
if (newAssignee === undefined || (!Array.isArray(_object) && _object.assignee === newAssignee)) { if (newAssignee === undefined || (!Array.isArray(_object) && _object?.assignee === newAssignee)) {
return return
} }

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { Class, Doc, DocumentQuery, FindOptions, Ref, Space, RateLimitter } from '@hcengineering/core' import core, { Class, Doc, DocumentQuery, FindOptions, Ref, Space, RateLimitter } from '@hcengineering/core'
import { IntlString, getResource } from '@hcengineering/platform' import { IntlString, getResource } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation' import { createQuery, getClient } from '@hcengineering/presentation'
import { AnyComponent, AnySvelteComponent } from '@hcengineering/ui' import { AnyComponent, AnySvelteComponent } from '@hcengineering/ui'
@ -73,7 +73,7 @@
...resultOptions.projection, ...resultOptions.projection,
_id: 1, _id: 1,
_class: 1, _class: 1,
...getProjection(viewOptions.groupBy, queryNoLookup) ...getProjection(viewOptions.groupBy, queryNoLookup, _class)
} }
} }
@ -97,7 +97,7 @@
$: docs = [...fastDocs, ...slowDocs.filter((it) => !fastQueryIds.has(it._id))] $: docs = [...fastDocs, ...slowDocs.filter((it) => !fastQueryIds.has(it._id))]
function getProjection (fields: string[], query: DocumentQuery<Doc>): Record<string, number> { function getProjection (fields: string[], query: DocumentQuery<Doc>, _class: Ref<Class<Doc>>): Record<string, number> {
const res: Record<string, number> = {} const res: Record<string, number> = {}
for (const f of fields) { for (const f of fields) {
/* /*
@ -114,6 +114,11 @@
res[f] = 1 res[f] = 1
} }
} }
if (client.getHierarchy().isDerived(_class, core.class.AttachedDoc)) {
res.attachedTo = 1
res.attachedToClass = 1
res.collection = 1
}
return res return res
} }

View File

@ -34,7 +34,6 @@
AnyComponent, AnyComponent,
AnySvelteComponent, AnySvelteComponent,
ExpandCollapse, ExpandCollapse,
Spinner,
getEventPositionElement, getEventPositionElement,
mouseAttractor, mouseAttractor,
showPopup showPopup
@ -479,7 +478,7 @@
dragstart={dragStartHandler} dragstart={dragStartHandler}
/> />
{:else if itemModels && itemModels.size > 0 && (!collapsed || wasLoaded || dragItemIndex !== undefined)} {:else if itemModels && itemModels.size > 0 && (!collapsed || wasLoaded || dragItemIndex !== undefined)}
{#if limited && !loading} {#if limited}
{#key configurationsVersion} {#key configurationsVersion}
{#each limited as docObject, i (docObject._id)} {#each limited as docObject, i (docObject._id)}
<ListItem <ListItem
@ -515,8 +514,6 @@
{/each} {/each}
{/key} {/key}
{/if} {/if}
{:else if loading}
<Spinner size="small" />
{/if} {/if}
</ExpandCollapse> </ExpandCollapse>
</div> </div>

View File

@ -145,7 +145,7 @@
/> />
{/if} {/if}
{#if loading} {#if loading && items.length === 0}
<div class="p-1"> <div class="p-1">
<Loading shrink size={'small'} /> <Loading shrink size={'small'} />
</div> </div>
@ -163,14 +163,20 @@
<span class="text-xs mx-0-5">/</span> <span class="text-xs mx-0-5">/</span>
{itemsProj.length} {itemsProj.length}
</div> </div>
<ActionIcon {#if loading}
size={'small'} <div class="p-1">
icon={IconMoreH} <Loading shrink size={'small'} />
label={ui.string.ShowMore} </div>
action={() => { {:else}
dispatch('more') <ActionIcon
}} size={'small'}
/> icon={IconMoreH}
label={ui.string.ShowMore}
action={() => {
dispatch('more')
}}
/>
{/if}
{:else} {:else}
<span class="antiSection-header__counter ml-2">{itemsProj.length}</span> <span class="antiSection-header__counter ml-2">{itemsProj.length}</span>
{/if} {/if}