Fix card spaces (#8517)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2025-04-10 15:54:34 +07:00
committed by GitHub
parent 3d00656f7f
commit 311d0885a0
2 changed files with 11 additions and 3 deletions
@@ -30,7 +30,11 @@
const hierarchy = client.getHierarchy()
let name: string = space?.name ?? ''
let types: Ref<MasterTag>[] = space?.types !== undefined ? hierarchy.clone(space.types) : []
const topLevelTypes = client.getModel().findAllSync(card.class.MasterTag, {
extends: card.class.Card
})
let types: Ref<MasterTag>[] =
space?.types !== undefined ? hierarchy.clone(space.types) : topLevelTypes.map((it) => it._id)
let isPrivate: boolean = space?.private ?? false
let members: AccountUuid[] =
space?.members !== undefined ? hierarchy.clone(space.members) : [getCurrentAccount().uuid]
@@ -33,6 +33,7 @@
IconAdd,
IconDropdown,
Loading,
location,
navigate,
SelectPopupValueType,
showPopup
@@ -64,9 +65,9 @@
{ limit: 1, projection: { _id: 1 } }
)
$: _class = $location.path[4] as Ref<MasterTag>
async function createCard (): Promise<void> {
const loc = getCurrentLocation()
const _class = loc.path[4] as Ref<MasterTag>
if (_class === undefined || currentSpace === undefined) return
const lastOne = await client.findOne(card.class.Card, {}, { sort: { rank: SortingOrder.Descending } })
const title = await translate(card.string.Card, {})
@@ -84,6 +85,7 @@
const _id = await client.createDoc(_class, currentSpace, filledData)
Analytics.handleEvent(CardEvents.CardCreated)
const loc = getCurrentLocation()
loc.path[3] = _id
loc.path.length = 4
@@ -125,6 +127,7 @@
mainButtonId={'new-document'}
dropdownIcon={IconDropdown}
{dropdownItems}
disabled={currentSpace === undefined || _class === undefined}
on:dropdown-selected={(ev) => {
void dropdownItemSelected(ev.detail)
}}
@@ -150,6 +153,7 @@
width={'100%'}
kind={'primary'}
gap={'large'}
disabled={currentSpace === undefined || _class === undefined}
on:click={createCard}
/>
{/if}