From 31c5504be42c8b13a17766124b8b6cc24cc79a92 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 3 Feb 2023 15:51:01 +0600 Subject: [PATCH] Tables total (#2586) Signed-off-by: Denis Bykhov --- packages/theme/styles/components.scss | 15 ++- packages/ui/src/types.ts | 2 +- .../src/components/schedule/MonthView.svelte | 23 +++- plugins/view-assets/lang/en.json | 4 +- plugins/view-assets/lang/ru.json | 4 +- .../src/components/Table.svelte | 104 +++++++++++------- .../src/components/TableBrowser.svelte | 1 + plugins/view-resources/src/plugin.ts | 4 +- .../src/components/SpaceContent.svelte | 2 + .../src/components/SpaceView.svelte | 2 +- .../src/components/SpecialView.svelte | 1 + server/mongo/src/storage.ts | 5 +- 12 files changed, 113 insertions(+), 54 deletions(-) diff --git a/packages/theme/styles/components.scss b/packages/theme/styles/components.scss index 8fdf3e2f53..d028df7c1c 100644 --- a/packages/theme/styles/components.scss +++ b/packages/theme/styles/components.scss @@ -459,11 +459,24 @@ .scroller-thead { position: sticky; - top: 0; z-index: 2; + top: 0; + height: 2.5rem; background-color: var(--body-color); } +.scroller-tfoot { + position: sticky; + z-index: 2; + bottom: 0; + height: 2.5rem; + background-color: var(--body-color); + + tr { + box-shadow: inset 0 1px 0 0 var(--divider-color); + } +} + // THead background-color in Tooltip and Popups .popup-tooltip .antiTable .scroller-thead, .popup .antiTable .scroller-thead { background-color: var(--accent-bg-color); } diff --git a/packages/ui/src/types.ts b/packages/ui/src/types.ts index 5d0a34d67d..8f0220ef0e 100644 --- a/packages/ui/src/types.ts +++ b/packages/ui/src/types.ts @@ -227,7 +227,7 @@ export interface FadeOptions { multipler?: Sides } export const defaultSP: FadeOptions = { multipler: { top: 0, bottom: 0 } } -export const tableSP: FadeOptions = { offset: { top: true }, multipler: { top: 2.5, bottom: 0 } } +export const tableSP: FadeOptions = { offset: { top: true, bottom: true }, multipler: { top: 2.5, bottom: 2.5 } } export const tableHRscheduleY: FadeOptions = { offset: { top: true }, multipler: { top: 5, bottom: 0 } } export const issueSP: FadeOptions = { offset: { top: true }, multipler: { top: 3, bottom: 0 } } export const emojiSP: FadeOptions = { offset: { top: true }, multipler: { top: 1.5, bottom: 0 } } diff --git a/plugins/hr-resources/src/components/schedule/MonthView.svelte b/plugins/hr-resources/src/components/schedule/MonthView.svelte index bb33dc0427..73c6d926e5 100644 --- a/plugins/hr-resources/src/components/schedule/MonthView.svelte +++ b/plugins/hr-resources/src/components/schedule/MonthView.svelte @@ -23,6 +23,7 @@ day as getDay, daysInMonth, eventToHTMLElement, + FadeOptions, floorFractionDigits, getWeekDayName, isWeekend, @@ -97,10 +98,18 @@ 3 ) } + + const fade: FadeOptions = { + ...tableSP, + multipler: { + ...tableSP.multipler, + bottom: 3.5 + } + } {#if departmentStaff.length} - + @@ -184,6 +193,8 @@ {/each} {/each} + + {/each} - +
{:else} @@ -289,9 +300,13 @@ td:not(:last-child) { border-right: 1px solid var(--divider-color); } - tr:not(.scroller-thead__tr) { - border-bottom: 1px solid var(--divider-color); + + tbody { + tr { + border-bottom: 1px solid var(--divider-color); + } } + tr.scroller-thead__tr:not(:last-child) { border-right: 1px solid var(--divider-color); } diff --git a/plugins/view-assets/lang/en.json b/plugins/view-assets/lang/en.json index efcc1658e1..2c183532c5 100644 --- a/plugins/view-assets/lang/en.json +++ b/plugins/view-assets/lang/en.json @@ -62,6 +62,8 @@ "NewFilteredView": "New filtered view", "FilteredViewName": "Filtered view name", "Then": "Then", - "ShowPreviewOnClick": "Please click to show document index preview..." + "ShowPreviewOnClick": "Please click to show document index preview...", + "Showed": "Showed", + "Total": "Total" } } diff --git a/plugins/view-assets/lang/ru.json b/plugins/view-assets/lang/ru.json index a6f5171742..d8a740970e 100644 --- a/plugins/view-assets/lang/ru.json +++ b/plugins/view-assets/lang/ru.json @@ -59,6 +59,8 @@ "NewFilteredView": "Новое фильтрованное отображение", "FilteredViewName": "Имя фильтрованного отображения", "Then": "Затем", - "ShowPreviewOnClick": "Пожалуйста нажмите чтобы увидеть предпросмотр..." + "ShowPreviewOnClick": "Пожалуйста нажмите чтобы увидеть предпросмотр...", + "Showed": "Показано", + "Total": "Всего" } } diff --git a/plugins/view-resources/src/components/Table.svelte b/plugins/view-resources/src/components/Table.svelte index 88c43dd94d..4b79120fc5 100644 --- a/plugins/view-resources/src/components/Table.svelte +++ b/plugins/view-resources/src/components/Table.svelte @@ -33,6 +33,7 @@ import { createEventDispatcher } from 'svelte' import { buildConfigLookup, buildModel, LoadingProps } from '../utils' import Menu from './Menu.svelte' + import view from '../plugin' export let _class: Ref> export let query: DocumentQuery @@ -45,6 +46,7 @@ export let config: (BuildModelKey | string)[] export let tableId: string | undefined = undefined export let readonly = false + export let showFooter = false export let prefferedSorting: string = 'modifiedOn' @@ -70,6 +72,7 @@ let userSorting = false let objects: Doc[] = [] + let total: number let objectsRecieved = false const refs: HTMLElement[] = [] @@ -101,6 +104,7 @@ query, (result) => { objects = result + total = result.total objectsRecieved = true if (sortingFunction !== undefined) { const sf = sortingFunction @@ -259,28 +263,11 @@ } }} > - {#each model as attribute, cell} - {#if !cell} - {#if enableChecking || showNotification} - - {#if showNotification} -
- {#if enableChecking} -
- { - check([object], event.detail) - }} - /> -
- {/if} - -
- {:else} + {#if enableChecking || showNotification} + + {#if showNotification} +
+ {#if enableChecking}
{/if} - - {/if} - -
- -
- - {:else} - + {:else} +
+ { + check([object], event.detail) + }} + /> +
+ {/if} + + {/if} + {#each model as attribute, cell} + +
- - {/if} +
+ {/each} {/each} @@ -346,3 +333,36 @@ {#if loading > 0}{/if} {/await} +{#if showFooter && total} + +{/if} + + diff --git a/plugins/view-resources/src/components/TableBrowser.svelte b/plugins/view-resources/src/components/TableBrowser.svelte index e2db8628ab..c2b77fe7e1 100644 --- a/plugins/view-resources/src/components/TableBrowser.svelte +++ b/plugins/view-resources/src/components/TableBrowser.svelte @@ -93,6 +93,7 @@ {loadingProps} highlightRows={true} enableChecking + showFooter checked={$selectionStore ?? []} {prefferedSorting} selection={listProvider.current($focusStore)} diff --git a/plugins/view-resources/src/plugin.ts b/plugins/view-resources/src/plugin.ts index ba6af4de5c..78fd149a43 100644 --- a/plugins/view-resources/src/plugin.ts +++ b/plugins/view-resources/src/plugin.ts @@ -62,6 +62,8 @@ export default mergeIds(viewId, view, { Ordering: '' as IntlString, Manual: '' as IntlString, Then: '' as IntlString, - ShowPreviewOnClick: '' as IntlString + ShowPreviewOnClick: '' as IntlString, + Showed: '' as IntlString, + Total: '' as IntlString } }) diff --git a/plugins/workbench-resources/src/components/SpaceContent.svelte b/plugins/workbench-resources/src/components/SpaceContent.svelte index 847a1d14da..d86073574a 100644 --- a/plugins/workbench-resources/src/components/SpaceContent.svelte +++ b/plugins/workbench-resources/src/components/SpaceContent.svelte @@ -65,6 +65,8 @@ options: viewlet.options, config: preference?.config ?? viewlet.config, viewlet, + viewOptions, + viewOptionsConfig: viewlet.viewOptions?.other, createItemDialog, createItemLabel, query: resultQuery diff --git a/plugins/workbench-resources/src/components/SpaceView.svelte b/plugins/workbench-resources/src/components/SpaceView.svelte index 790489fc7d..c446f933ec 100644 --- a/plugins/workbench-resources/src/components/SpaceView.svelte +++ b/plugins/workbench-resources/src/components/SpaceView.svelte @@ -97,7 +97,7 @@ {viewlets} {createItemDialog} {createItemLabel} - {viewOptions} + bind:viewOptions bind:search bind:viewlet /> diff --git a/plugins/workbench-resources/src/components/SpecialView.svelte b/plugins/workbench-resources/src/components/SpecialView.svelte index 4b9ab3ce36..1ed93846cd 100644 --- a/plugins/workbench-resources/src/components/SpecialView.svelte +++ b/plugins/workbench-resources/src/components/SpecialView.svelte @@ -141,6 +141,7 @@ config: preference?.config ?? viewlet.config, viewlet, viewOptions, + viewOptionsConfig: viewlet.viewOptions?.other, createItemDialog: createComponent, createItemLabel: createLabel, query: resultQuery diff --git a/server/mongo/src/storage.ts b/server/mongo/src/storage.ts index bf393521f8..ee4e5b76c3 100644 --- a/server/mongo/src/storage.ts +++ b/server/mongo/src/storage.ts @@ -441,7 +441,8 @@ abstract class MongoAdapterBase extends TxProcessor { } const domain = this.hierarchy.getDomain(_class) const coll = this.db.collection(domain) - let cursor = coll.find(this.translateQuery(_class, query)) + const mongoQuery = this.translateQuery(_class, query) + let cursor = coll.find(mongoQuery) if (options?.projection !== undefined) { const projection: Projection = {} @@ -463,7 +464,7 @@ abstract class MongoAdapterBase extends TxProcessor { cursor = cursor.sort(sort) } if (options.limit !== undefined) { - total = await coll.estimatedDocumentCount() + total = await coll.countDocuments(mongoQuery) cursor = cursor.limit(options.limit) } }