Allow to sort attributes for parent and sub class together (#10816)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-05-03 23:41:27 +05:00
committed by GitHub
parent c6738a02cb
commit 8d62d91d28
3 changed files with 12 additions and 3 deletions
@@ -62,6 +62,7 @@
showHeader={false}
disabled={false}
isCard
showAll
>
<div slot="header">
<ButtonIcon
@@ -47,6 +47,7 @@
export let showHeader: boolean = true
export let disabled: boolean = true
export let isCard: boolean = false
export let showAll: boolean = false
export let attributeMapper:
| {
component: AnySvelteComponent
@@ -112,6 +113,10 @@
const classUpdated = (_clazz: Ref<Class<Doc>>, to: Ref<Class<Doc>>): void => {
selected = undefined
const h = client.getHierarchy()
if (showAll && !h.isMixin(_class)) {
classes = []
return
}
const toAncestors = new Set(h.getAncestors(to))
classes = h
.getAncestors(_class)
@@ -213,6 +218,7 @@
{_class}
{ofClass}
{attributeMapper}
showAll={showAll && !hierarchy.isMixin(_class)}
{selected}
on:deselect={handleDeselect}
on:select={handleSelect}
@@ -230,6 +236,7 @@
{ofClass}
{attributeMapper}
{selected}
showAll={showAll && !hierarchy.isMixin(_class)}
notUseOfClass
on:deselect={handleDeselect}
on:select={handleSelect}
@@ -244,6 +251,7 @@
{ofClass}
{attributeMapper}
{selected}
showAll={showAll && !hierarchy.isMixin(_class)}
on:deselect={handleDeselect}
on:select={handleSelect}
/>
@@ -47,6 +47,7 @@
export let ofClass: Ref<Class<Doc>> | undefined = undefined
export let notUseOfClass: boolean = false
export let selected: AnyAttribute | undefined = undefined
export let showAll: boolean = false
export let attributeMapper:
| {
@@ -73,9 +74,8 @@
function getCustomAttributes (_class: Ref<Class<Doc>>): AnyAttribute[] {
const cl = hierarchy.getClass(_class)
const attributes = Array.from(
hierarchy.getAllAttributes(_class, _class === ofClass && !notUseOfClass ? core.class.Doc : cl.extends).values()
).sort((a, b) => {
const to = showAll ? ofClass : _class === ofClass && !notUseOfClass ? core.class.Doc : cl.extends
const attributes = Array.from(hierarchy.getAllAttributes(_class, to).values()).sort((a, b) => {
const rankA = a.rank ?? toRank(a._id) ?? ''
const rankB = b.rank ?? toRank(b._id) ?? ''
return rankA.localeCompare(rankB)