diff --git a/plugins/attachment-resources/src/components/AttachmentPopup.svelte b/plugins/attachment-resources/src/components/AttachmentPopup.svelte index 4c7c736b1d..8d13f056bf 100644 --- a/plugins/attachment-resources/src/components/AttachmentPopup.svelte +++ b/plugins/attachment-resources/src/components/AttachmentPopup.svelte @@ -21,6 +21,7 @@ import attachment from '@anticrm/attachment' export let objectId: Ref + export let attachments: number @@ -29,4 +30,5 @@ config={['', 'lastModified']} options={ {} } query={ { attachedTo: objectId } } + loadingProps={{ length: attachments }} /> diff --git a/plugins/attachment-resources/src/components/Attachments.svelte b/plugins/attachment-resources/src/components/Attachments.svelte index f40ebaaa42..f282222a96 100644 --- a/plugins/attachment-resources/src/components/Attachments.svelte +++ b/plugins/attachment-resources/src/components/Attachments.svelte @@ -14,26 +14,20 @@ // limitations under the License. --> {#if value && value.attachments && value.attachments > 0} - +
 {value.attachments}
diff --git a/plugins/contact-resources/src/components/EditContact.svelte b/plugins/contact-resources/src/components/EditContact.svelte index dd67931dd0..ae3c6eae2b 100644 --- a/plugins/contact-resources/src/components/EditContact.svelte +++ b/plugins/contact-resources/src/components/EditContact.svelte @@ -150,6 +150,13 @@ onDestroy(() => { observer.disconnect() }) + + function getCollectionCounter (object: Doc, key: KeyedAttribute): number { + if (client.getHierarchy().isMixin(key.attr.attributeOf)) { + return (client.getHierarchy().as(object, key.attr.attributeOf) as any)[key.key] + } + return (object as any)[key.key] ?? 0 + } {#if object !== undefined} @@ -202,7 +209,7 @@ {#each collectionKeys as collection}
{#await getCollectionEditor(collection) then is} - + {/await}
{/each} diff --git a/plugins/lead-resources/src/components/Leads.svelte b/plugins/lead-resources/src/components/Leads.svelte index 1492ca660f..f595ec3c7e 100644 --- a/plugins/lead-resources/src/components/Leads.svelte +++ b/plugins/lead-resources/src/components/Leads.svelte @@ -15,8 +15,7 @@ {#await buildModel({ client, _class, keys: config, options })} @@ -158,24 +174,46 @@ {/if} -
+ +
+ {...attribute.props}/> -
+
+ {:else} - + + /> + + {/if} + {/each} + + {/each} + + {:else if loadingProps !== undefined} + + {#each Array(getLoadingLength(loadingProps, options)) as i, row} + + {#each model as attribute, cell} + {#if !cell} + {#if enableChecking} + +
+ +
+ + {/if} + + + {/if} {/each} diff --git a/plugins/view-resources/src/index.ts b/plugins/view-resources/src/index.ts index a57d7f60e3..c95d1d7f29 100644 --- a/plugins/view-resources/src/index.ts +++ b/plugins/view-resources/src/index.ts @@ -30,7 +30,7 @@ import { deleteObject } from './utils' import MoveView from './components/Move.svelte' export { default as ContextMenu } from './components/Menu.svelte' -export { buildModel, getActions, getObjectPresenter } from './utils' +export { buildModel, getActions, getObjectPresenter, LoadingProps } from './utils' export { Table, TableView } function Delete (object: Doc): void { diff --git a/plugins/view-resources/src/utils.ts b/plugins/view-resources/src/utils.ts index f1692ea74e..1b4689694e 100644 --- a/plugins/view-resources/src/utils.ts +++ b/plugins/view-resources/src/utils.ts @@ -22,6 +22,13 @@ import type { Action, ActionTarget, BuildModelOptions } from '@anticrm/view' import view, { AttributeModel, BuildModelKey } from '@anticrm/view' import { ErrorPresenter } from '@anticrm/ui' +/** + * Define some properties to be used to show component until data is properly loaded. + */ +export interface LoadingProps { + length: number +} + /** * @public */ @@ -37,9 +44,9 @@ export async function getObjectPresenter (client: Client, _class: Ref } const presenter = await getResource(presenterMixin.presenter) const key = preserveKey.sortingKey ?? preserveKey.key - const sortingKey = clazz.sortingKey ? - (key.length > 0 ? key + '.' + clazz.sortingKey : clazz.sortingKey) - : key + const sortingKey = clazz.sortingKey !== undefined + ? (key.length > 0 ? key + '.' + clazz.sortingKey : clazz.sortingKey) + : key return { key: preserveKey.key, _class,