mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 01:40:32 +00:00
Fix card spaces (#8516)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
6a9e0cc1f2
commit
dbab01c805
@ -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]
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user