Skip to content

Commit

Permalink
UBER-1129: Fix list support attached documents properly (#3889)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo authored and BykhovDenis committed Oct 26, 2023
1 parent 14d03a0 commit 1da21a5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@
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()
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
}
Expand Down
11 changes: 8 additions & 3 deletions plugins/view-resources/src/components/list/List.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -73,7 +73,7 @@
...resultOptions.projection,
_id: 1,
_class: 1,
...getProjection(viewOptions.groupBy, queryNoLookup)
...getProjection(viewOptions.groupBy, queryNoLookup, _class)
}
}
Expand All @@ -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) {
/*
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
AnyComponent,
AnySvelteComponent,
ExpandCollapse,
Spinner,
getEventPositionElement,
mouseAttractor,
showPopup
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -515,8 +514,6 @@
{/each}
{/key}
{/if}
{:else if loading}
<Spinner size="small" />
{/if}
</ExpandCollapse>
</div>
Expand Down
24 changes: 15 additions & 9 deletions plugins/view-resources/src/components/list/ListHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
/>
{/if}

{#if loading}
{#if loading && items.length === 0}
<div class="p-1">
<Loading shrink size={'small'} />
</div>
Expand All @@ -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}
Expand Down

0 comments on commit 1da21a5

Please sign in to comment.