Fix card spaces (#8516)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2025-04-10 13:54:22 +05:00 committed by GitHub
parent 6a9e0cc1f2
commit dbab01c805
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 12 deletions

View File

@ -14,14 +14,14 @@
-->
<script lang="ts">
import { AccountArrayEditor } from '@hcengineering/contact-resources'
import core, { Account, Data, DocumentUpdate, Ref, getCurrentAccount } from '@hcengineering/core'
import core, { Account, Data, Ref, getCurrentAccount } from '@hcengineering/core'
import presentation, { Card, getClient } from '@hcengineering/presentation'
import { EditBox, Label, Toggle } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import { CardSpace, MasterTag } from '@hcengineering/card'
import TypesSelector from './TypesSelector.svelte'
import card from '../../plugin'
import TypesSelector from './TypesSelector.svelte'
export let space: CardSpace | undefined = undefined
@ -30,7 +30,11 @@
const hierarchy = client.getHierarchy()
let name: string = space?.name ?? ''
let types: Ref<MasterTag>[] = space?.types !== undefined ? hierarchy.clone(space.types) : [getCurrentAccount()._id]
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: Ref<Account>[] =
space?.members !== undefined ? hierarchy.clone(space.members) : [getCurrentAccount()._id]

View File

@ -13,16 +13,17 @@
// limitations under the License.
-->
<script lang="ts">
import { Analytics } from '@hcengineering/analytics'
import {
AccountRole,
Data,
fillDefaults,
getCurrentAccount,
hasAccountRole,
MarkupBlobRef,
Ref,
SortingOrder,
Space,
fillDefaults,
getCurrentAccount,
hasAccountRole
Space
} from '@hcengineering/core'
import { createQuery, getClient } from '@hcengineering/presentation'
import {
@ -32,17 +33,17 @@
IconAdd,
IconDropdown,
Loading,
location,
navigate,
SelectPopupValueType,
showPopup
} from '@hcengineering/ui'
import { Analytics } from '@hcengineering/analytics'
import card from '../../plugin'
import CreateSpace from './CreateSpace.svelte'
import { Card, CardEvents, MasterTag } from '@hcengineering/card'
import { translate } from '@hcengineering/platform'
import { makeRank } from '@hcengineering/rank'
import card from '../../plugin'
import CreateSpace from './CreateSpace.svelte'
export let currentSpace: Ref<Space> | undefined
@ -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}