mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-09 09:41:03 +00:00
Fix attachment spaces (#8200)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
783d794d56
commit
0ba5e949f6
@ -18,7 +18,7 @@
|
||||
import { createQuery, getClient, getFileMetadata, uploadFile } from '@hcengineering/presentation'
|
||||
import { ActionIcon, IconAdd, Label, Loading } from '@hcengineering/ui'
|
||||
|
||||
import type { Doc, WithLookup } from '@hcengineering/core'
|
||||
import core, { Doc, Ref, Space, WithLookup } from '@hcengineering/core'
|
||||
|
||||
import { setPlatformStatus, unknownError } from '@hcengineering/platform'
|
||||
import { AttachmentPresenter } from '..'
|
||||
@ -59,8 +59,11 @@
|
||||
try {
|
||||
const uuid = await uploadFile(file)
|
||||
const metadata = await getFileMetadata(file, uuid)
|
||||
const space = client.getHierarchy().isDerived(object._class, core.class.Space)
|
||||
? (object._id as Ref<Space>)
|
||||
: object.space
|
||||
|
||||
await client.addCollection(attachment.class.Attachment, object.space, object._id, object._class, 'attachments', {
|
||||
await client.addCollection(attachment.class.Attachment, space, object._id, object._class, 'attachments', {
|
||||
name: file.name,
|
||||
file: uuid,
|
||||
type: file.type,
|
||||
|
@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import attachment, { Attachment, AttachmentsEvents } from '@hcengineering/attachment'
|
||||
import contact from '@hcengineering/contact'
|
||||
import { BlobMetadata, Doc, PersonId, Ref, generateId, type Blob } from '@hcengineering/core'
|
||||
import core, { BlobMetadata, Doc, PersonId, Ref, generateId, type Blob } from '@hcengineering/core'
|
||||
import { IntlString, getResource, setPlatformStatus, unknownError } from '@hcengineering/platform'
|
||||
import {
|
||||
FileOrBlob,
|
||||
@ -173,13 +173,17 @@
|
||||
try {
|
||||
const _id: Ref<Attachment> = generateId()
|
||||
|
||||
const space = client.getHierarchy().isDerived(object._class, core.class.Space)
|
||||
? (object._id as Ref<Space>)
|
||||
: object.space
|
||||
|
||||
const attachmentDoc: Attachment = {
|
||||
_id,
|
||||
_class: attachment.class.Attachment,
|
||||
collection: 'attachments',
|
||||
modifiedOn: 0,
|
||||
modifiedBy: '' as PersonId,
|
||||
space: object.space,
|
||||
space,
|
||||
attachedTo: object._id,
|
||||
attachedToClass: object._class,
|
||||
name,
|
||||
@ -192,7 +196,7 @@
|
||||
|
||||
await client.addCollection(
|
||||
attachment.class.Attachment,
|
||||
object.space,
|
||||
space,
|
||||
object._id,
|
||||
object._class,
|
||||
'attachments',
|
||||
|
Loading…
Reference in New Issue
Block a user