feat: add baseType property and related functionality across card models and UI components (#10940)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-06-30 20:17:17 +05:00
committed by GitHub
parent 9228b8d2d0
commit bf798c1bbc
32 changed files with 204 additions and 27 deletions
@@ -1,4 +1,5 @@
<script lang="ts">
import card, { type MasterTag } from '@hcengineering/card'
import core, { Association, Doc, WithLookup } from '@hcengineering/core'
import { IntlString } from '@hcengineering/platform'
import { getClient, ObjectCreate } from '@hcengineering/presentation'
@@ -25,15 +26,30 @@
function getCreate (): ObjectCreate | undefined {
const factory = client.getHierarchy().classHierarchyMixin(_class, view.mixin.ObjectFactory)
if (factory) {
const usePopup = isBaseCardTypeWithSubtypes()
return {
component: factory.component,
component: usePopup ? factory.component : undefined,
func: factory.create,
label,
props: { _class, space: object.space }
props: { _class, type: _class, space: object.space, changeType: usePopup }
}
}
}
function isBaseCardTypeWithSubtypes (): boolean {
const hierarchy = client.getHierarchy()
if (!hierarchy.isDerived(_class, card.class.Card)) return false
const clazz = hierarchy.getClass(_class) as MasterTag | undefined
if (clazz?.baseType !== true) return false
return hierarchy.getDescendants(_class).some((descendant) => {
if (descendant === _class || hierarchy.isMixin(descendant)) return false
const descendantClass = hierarchy.getClass(descendant) as MasterTag | undefined
return descendantClass?._class === card.class.MasterTag && descendantClass.removed !== true
})
}
function add (): void {
const create = getCreate()
const isVersionable = client.getHierarchy().classHierarchyMixin(_class, core.mixin.VersionableClass) !== undefined