show boolean attributes in card title (#10354)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-01-04 22:19:18 +05:00
committed by GitHub
parent 121d6afa74
commit c75c077e95
7 changed files with 58 additions and 24 deletions
@@ -14,7 +14,7 @@
-->
<script lang="ts">
import { Card, MasterTag } from '@hcengineering/card'
import core, { Ref } from '@hcengineering/core'
import core, { Ref, toRank } from '@hcengineering/core'
import { Asset, getEmbeddedLabel } from '@hcengineering/platform'
import { getClient } from '@hcengineering/presentation'
import { AnySvelteComponent, tooltip } from '@hcengineering/ui'
@@ -58,16 +58,22 @@
$: ids = getIds(cardObj)
function getIds (val: Card | undefined): string {
if (val === undefined) return ''
function getIds (object: Card | undefined): string {
if (object === undefined) return ''
const h = client.getHierarchy()
const attrs = h.getAllAttributes(val._class, core.class.Doc)
const attrs = [...h.getAllAttributes(object._class, core.class.Doc).values()].sort((a, b) => {
const rankA = a.rank ?? toRank(a._id) ?? ''
const rankB = b.rank ?? toRank(b._id) ?? ''
return rankA.localeCompare(rankB)
})
const res: string[] = []
for (const [k, v] of attrs) {
if (v.type._class === core.class.TypeIdentifier) {
const str = (val as any)[k]
if (v.showInPresenter === true && str !== undefined) {
res.push(str)
for (const attr of attrs) {
const val = (object as any)[attr.name]
if (attr.showInPresenter === true && val !== undefined) {
if (typeof val === 'string' || typeof val === 'number') {
res.push(val.toString())
} else if (typeof val === 'boolean') {
res.push(val ? '✅' : '❌️')
}
}
}
@@ -72,7 +72,7 @@
async function newVersion (): Promise<void> {
showPopup(MessageBox, {
title: card.string.NewVersion,
label: card.string.NewVersion,
message: card.string.NewVersionConfirmation,
action: async () => {
const _id = await createNewVersion(value)
@@ -61,7 +61,7 @@
{readonly}
>
<svelte:fragment slot="item" let:item={it}>
<CardPresenter value={it} disabled showVersion={false} />
<CardPresenter value={it} disabled />
</svelte:fragment>
<svelte:fragment slot="category" let:item={it}>
@@ -92,6 +92,7 @@
ObjectBoxPopup,
{
_class: core.class.Permission,
searchField: 'label',
docQuery: { _id: { $in: allPermissions.map((p) => p._id) } },
multiSelect: true,
allowDeselect: true,
+14 -6
View File
@@ -34,6 +34,7 @@ import core, {
type RelatedDocument,
SortingOrder,
type Space,
toRank,
type TxOperations,
type WithLookup
} from '@hcengineering/core'
@@ -255,16 +256,23 @@ export async function getCardTitle (client: TxOperations, ref: Ref<Card>, doc?:
const object = doc ?? (await client.findOne(card.class.Card, { _id: ref }))
if (object === undefined) throw new Error(`Card not found, _id: ${ref}`)
const h = client.getHierarchy()
const attrs = h.getAllAttributes(object._class, core.class.Doc)
const attrs = [...h.getAllAttributes(object._class, core.class.Doc).values()].sort((a, b) => {
const rankA = a.rank ?? toRank(a._id) ?? ''
const rankB = b.rank ?? toRank(b._id) ?? ''
return rankA.localeCompare(rankB)
})
const res: string[] = []
for (const [k, v] of attrs) {
if (v.type._class === core.class.TypeIdentifier) {
const str = (object as any)[k]
if (v.showInPresenter === true && str !== undefined) {
res.push(str)
for (const attr of attrs) {
const val = (object as any)[attr.name]
if (attr.showInPresenter === true && val !== undefined) {
if (typeof val === 'string' || typeof val === 'number') {
res.push(val.toString())
} else if (typeof val === 'boolean') {
res.push(val ? '✅' : '❌️')
}
}
}
const ids = res.join(' ')
let version = ''
if (h.classHierarchyMixin(object._class, core.mixin.VersionableClass)?.enabled === true) {
@@ -13,16 +13,19 @@
// limitations under the License.
-->
<script lang="ts">
import core, { AnyAttribute, Type } from '@hcengineering/core'
import { TypeBoolean } from '@hcengineering/model'
import { Label } from '@hcengineering/ui'
import setting from '../../plugin'
import { createEventDispatcher, onMount } from 'svelte'
import core, { Type } from '@hcengineering/core'
import { Label, Toggle } from '@hcengineering/ui'
import { BooleanEditor } from '@hcengineering/view-resources'
import { createEventDispatcher, onMount } from 'svelte'
import setting from '../../plugin'
export let type: Type<boolean> | undefined
export let attribute: AnyAttribute | undefined
export let defaultValue: boolean | undefined
let showInPresenter = attribute?.showInPresenter ?? false
const dispatch = createEventDispatcher()
onMount(() => {
@@ -34,9 +37,14 @@
function change () {
dispatch('change', {
type: TypeBoolean(),
defaultValue
defaultValue,
extra: { showInPresenter }
})
}
async function changeShowing () {
dispatch('change', { extra: { showInPresenter } })
}
</script>
<span class="label">
@@ -49,3 +57,7 @@
change()
}}
/>
<span class="label">
<Label label={setting.string.ShowInTitle} />
</span>
<Toggle bind:on={showInPresenter} on:change={changeShowing} />
@@ -44,12 +44,12 @@
$: currentSequence = sequences.find((s) => s._id === seq)
async function change () {
if (!editable) return
if (identifiers.has(identifier.toUpperCase())) return
if (identifier.toUpperCase() === (currentSequence?.prefix?.toUpperCase() ?? '')) return
if (currentSequence !== undefined) {
await client.update(currentSequence, { prefix: identifier.toUpperCase() })
} else {
if (!editable) return
const newSeq = await client.createDoc(core.class.CustomSequence, core.space.Workspace, {
prefix: identifier.toUpperCase(),
sequence: 0,
@@ -71,7 +71,14 @@
<Label label={core.string.Id} />
</span>
<div class="flex-row-center">
<EditBox bind:value={identifier} placeholder={core.string.Id} uppercase maxWidth={'50%'} on:change={change} />
<EditBox
bind:value={identifier}
disabled={!editable}
placeholder={core.string.Id}
uppercase
maxWidth={'50%'}
on:change={change}
/>
{#if editable && identifiers.has(identifier.toUpperCase())}
<div class="overflow-label duplicated-identifier">
<Label label={setting.string.IdentifierExists} />