mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 00:37:47 +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 { createQuery, getClient, getFileMetadata, uploadFile } from '@hcengineering/presentation'
|
||||||
import { ActionIcon, IconAdd, Label, Loading } from '@hcengineering/ui'
|
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 { setPlatformStatus, unknownError } from '@hcengineering/platform'
|
||||||
import { AttachmentPresenter } from '..'
|
import { AttachmentPresenter } from '..'
|
||||||
@ -59,8 +59,11 @@
|
|||||||
try {
|
try {
|
||||||
const uuid = await uploadFile(file)
|
const uuid = await uploadFile(file)
|
||||||
const metadata = await getFileMetadata(file, uuid)
|
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,
|
name: file.name,
|
||||||
file: uuid,
|
file: uuid,
|
||||||
type: file.type,
|
type: file.type,
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import attachment, { Attachment, AttachmentsEvents } from '@hcengineering/attachment'
|
import attachment, { Attachment, AttachmentsEvents } from '@hcengineering/attachment'
|
||||||
import contact from '@hcengineering/contact'
|
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 { IntlString, getResource, setPlatformStatus, unknownError } from '@hcengineering/platform'
|
||||||
import {
|
import {
|
||||||
FileOrBlob,
|
FileOrBlob,
|
||||||
@ -173,13 +173,17 @@
|
|||||||
try {
|
try {
|
||||||
const _id: Ref<Attachment> = generateId()
|
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 = {
|
const attachmentDoc: Attachment = {
|
||||||
_id,
|
_id,
|
||||||
_class: attachment.class.Attachment,
|
_class: attachment.class.Attachment,
|
||||||
collection: 'attachments',
|
collection: 'attachments',
|
||||||
modifiedOn: 0,
|
modifiedOn: 0,
|
||||||
modifiedBy: '' as PersonId,
|
modifiedBy: '' as PersonId,
|
||||||
space: object.space,
|
space,
|
||||||
attachedTo: object._id,
|
attachedTo: object._id,
|
||||||
attachedToClass: object._class,
|
attachedToClass: object._class,
|
||||||
name,
|
name,
|
||||||
@ -192,7 +196,7 @@
|
|||||||
|
|
||||||
await client.addCollection(
|
await client.addCollection(
|
||||||
attachment.class.Attachment,
|
attachment.class.Attachment,
|
||||||
object.space,
|
space,
|
||||||
object._id,
|
object._id,
|
||||||
object._class,
|
object._class,
|
||||||
'attachments',
|
'attachments',
|
||||||
|
Loading…
Reference in New Issue
Block a user