Fix class editor (#7099)

This commit is contained in:
Denis Bykhov 2024-11-05 08:53:02 +05:00 committed by GitHub
parent 9d79ab65ae
commit 3ea2659d9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 7 deletions

View File

@ -99,13 +99,12 @@
async function showMenu (ev: MouseEvent, attribute: AnyAttribute, row: number): Promise<void> {
hovered = row
const exist = (await client.findOne(attribute.attributeOf, { [attribute.name]: { $exists: true } })) !== undefined
const actions: Action[] = [
{
label: presentation.string.Edit,
icon: IconEdit,
action: async () => {
dispatch('select', attribute._id)
dispatch('select', attribute)
}
}
]
@ -118,7 +117,7 @@
}
})
}
const extra = await getContextActions(client, attribute, { mode: 'context' })
const extra = await getContextActions(client, attribute, { mode: 'context' }, core.class.Attribute)
actions.push(
...extra.map((it) => ({
label: it.label,

View File

@ -58,7 +58,7 @@
const data: Data<AnyAttribute> = {
attributeOf: _class,
name: name.trim().replace('/', '').replace(' ', '') + '_' + generateId(),
name: 'custom' + generateId(),
label: getEmbeddedLabel(name),
isCustom: true,
type,

View File

@ -44,7 +44,8 @@
)
})
let refClass: Ref<Doc> | undefined = type !== undefined ? hierarchy.getClass(type.of._class)._id : undefined
let refClass: Ref<Doc> | undefined =
type?.of?._class !== undefined ? hierarchy.getClass(type.of._class)._id : undefined
$: selected = types.find((p) => p._id === refClass)

View File

@ -136,9 +136,10 @@ export async function getContextActions (
context: {
mode: ViewContextType
application?: Ref<Doc>
}
},
derived: Ref<Class<Doc>> = core.class.Doc
): Promise<Action[]> {
const result = await getActions(client, doc, undefined, context.mode)
const result = await getActions(client, doc, derived, context.mode)
if (context.application !== undefined) {
return result.filter((it) => it.context.application === context.application || it.context.application === undefined)