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

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
plugins
tracker-resources/src/components/issues
view-resources/src/components/list

View File

@ -40,7 +40,8 @@
export let shrink: number = 0
export let isAction: boolean = false
$: _object = object ?? value ?? []
$: _object =
(typeof object !== 'string' ? object : undefined) ?? (typeof value !== 'string' ? value : undefined) ?? []
const client = getClient()
const dispatch = createEventDispatcher()
@ -48,7 +49,7 @@
const docQuery: DocumentQuery<Employee> = { active: true }
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
}

View File

@ -13,7 +13,7 @@
// limitations under the License.
-->
<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 { createQuery, getClient } from '@hcengineering/presentation'
import { AnyComponent, AnySvelteComponent } from '@hcengineering/ui'
@ -73,7 +73,7 @@
...resultOptions.projection,
_id: 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))]
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> = {}
for (const f of fields) {
/*
@ -114,6 +114,11 @@
res[f] = 1
}
}
if (client.getHierarchy().isDerived(_class, core.class.AttachedDoc)) {
res.attachedTo = 1
res.attachedToClass = 1
res.collection = 1
}
return res
}

View File

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

View File

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