mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-13 10:53:06 +00:00
Fix custom field grouping (#8537)
This commit is contained in:
parent
4ec4609364
commit
cd2cc7528c
@ -21,6 +21,7 @@
|
|||||||
import { focusStore } from '../selection'
|
import { focusStore } from '../selection'
|
||||||
import { setViewOptions } from '../viewOptions'
|
import { setViewOptions } from '../viewOptions'
|
||||||
import ViewOptionsEditor from './ViewOptions.svelte'
|
import ViewOptionsEditor from './ViewOptions.svelte'
|
||||||
|
import core, { Class, Doc, Hierarchy, Ref } from '@hcengineering/core'
|
||||||
|
|
||||||
export let viewlet: Viewlet | undefined
|
export let viewlet: Viewlet | undefined
|
||||||
export let kind: 'primary' | 'secondary' | 'tertiary' | 'negative' = 'secondary'
|
export let kind: 'primary' | 'secondary' | 'tertiary' | 'negative' = 'secondary'
|
||||||
@ -34,6 +35,15 @@
|
|||||||
let btn: HTMLButtonElement
|
let btn: HTMLButtonElement
|
||||||
let pressed: boolean = false
|
let pressed: boolean = false
|
||||||
|
|
||||||
|
function getGroupingCustomAttributes (h: Hierarchy, _class: Ref<Class<Doc>>): string[] {
|
||||||
|
const customAttributes = [...h.getOwnAttributes(_class).values()]
|
||||||
|
.filter(
|
||||||
|
(attr) => attr.isCustom && !attr.isHidden && [core.class.RefTo, core.class.EnumOf].includes(attr.type._class)
|
||||||
|
)
|
||||||
|
.map((a) => a.name)
|
||||||
|
return customAttributes
|
||||||
|
}
|
||||||
|
|
||||||
async function clickHandler (): Promise<void> {
|
async function clickHandler (): Promise<void> {
|
||||||
if (viewlet === undefined) {
|
if (viewlet === undefined) {
|
||||||
return
|
return
|
||||||
@ -46,6 +56,10 @@
|
|||||||
config.other = viewOptionsConfig
|
config.other = viewOptionsConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const customAttributes = getGroupingCustomAttributes(h, viewlet.attachTo)
|
||||||
|
|
||||||
|
config.groupBy = Array.from(new Set([...config.groupBy, ...customAttributes]))
|
||||||
|
|
||||||
showPopup(
|
showPopup(
|
||||||
ViewOptionsEditor,
|
ViewOptionsEditor,
|
||||||
{ viewlet, config, viewOptions: h.clone(viewOptions) },
|
{ viewlet, config, viewOptions: h.clone(viewOptions) },
|
||||||
|
Loading…
Reference in New Issue
Block a user