|
13 | 13 | // limitations under the License. |
14 | 14 | --> |
15 | 15 | <script lang="ts"> |
16 | | - import { Class, Doc, DocumentQuery, FindOptions, Ref, generateId } from '@hcengineering/core' |
| 16 | + import { Class, Doc, DocumentQuery, FindOptions, Ref, generateId, SortingOrder } from '@hcengineering/core' |
17 | 17 | import { ActionContext } from '@hcengineering/presentation' |
18 | 18 | import { Scroller, tableSP } from '@hcengineering/ui' |
19 | 19 | import { BuildModelKey, Viewlet, ViewOptionModel, ViewOptions } from '@hcengineering/view' |
20 | 20 | import { onDestroy, onMount } from 'svelte' |
21 | 21 | import { type ViewletContext, ViewletContextStore, viewletContextStore } from '../viewletContextStore' |
22 | 22 | import RelationshipTable from './RelationshipTable.svelte' |
| 23 | + import { setViewOptions } from '../viewOptions' |
23 | 24 |
|
24 | 25 | export let _class: Ref<Class<Doc>> |
25 | 26 | export let query: DocumentQuery<Doc> |
|
33 | 34 | export let readonly = false |
34 | 35 |
|
35 | 36 | const contextId = generateId() |
| 37 | + async function onSort (event: CustomEvent<{ key: string, order: SortingOrder }>) { |
| 38 | + const { key, order } = event.detail |
| 39 | + if (viewlet && viewOptions) { |
| 40 | + viewOptions.orderBy = [key, order] |
| 41 | + setViewOptions(viewlet, viewOptions) |
| 42 | + } |
| 43 | + } |
36 | 44 |
|
37 | 45 | // Set viewlet context in store when component mounts/updates |
38 | 46 | $: { |
|
92 | 100 | {viewOptions} |
93 | 101 | viewOptionsConfig={viewOptionsConfig ?? viewlet?.viewOptions?.other} |
94 | 102 | {readonly} |
| 103 | + on:sort={onSort} |
95 | 104 | /> |
96 | 105 | </Scroller> |
0 commit comments