Skip to content

Commit cd2cc75

Browse files
authored
Fix custom field grouping (#8537)
1 parent 4ec4609 commit cd2cc75

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

plugins/view-resources/src/components/ViewOptionsButton.svelte

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import { focusStore } from '../selection'
2222
import { setViewOptions } from '../viewOptions'
2323
import ViewOptionsEditor from './ViewOptions.svelte'
24+
import core, { Class, Doc, Hierarchy, Ref } from '@hcengineering/core'
2425
2526
export let viewlet: Viewlet | undefined
2627
export let kind: 'primary' | 'secondary' | 'tertiary' | 'negative' = 'secondary'
@@ -34,6 +35,15 @@
3435
let btn: HTMLButtonElement
3536
let pressed: boolean = false
3637
38+
function getGroupingCustomAttributes (h: Hierarchy, _class: Ref<Class<Doc>>): string[] {
39+
const customAttributes = [...h.getOwnAttributes(_class).values()]
40+
.filter(
41+
(attr) => attr.isCustom && !attr.isHidden && [core.class.RefTo, core.class.EnumOf].includes(attr.type._class)
42+
)
43+
.map((a) => a.name)
44+
return customAttributes
45+
}
46+
3747
async function clickHandler (): Promise<void> {
3848
if (viewlet === undefined) {
3949
return
@@ -46,6 +56,10 @@
4656
config.other = viewOptionsConfig
4757
}
4858
59+
const customAttributes = getGroupingCustomAttributes(h, viewlet.attachTo)
60+
61+
config.groupBy = Array.from(new Set([...config.groupBy, ...customAttributes]))
62+
4963
showPopup(
5064
ViewOptionsEditor,
5165
{ viewlet, config, viewOptions: h.clone(viewOptions) },

0 commit comments

Comments
 (0)