mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-27 10:49:44 +00:00
introduce AttachedDoc
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
5554c29eff
commit
6d743c92e9
@ -25,7 +25,7 @@ function extractBacklinks (backlinkId: Ref<Doc>, message: string, kids: NodeList
|
||||
for (const kid of kids) {
|
||||
if (kid.nodeName === 'span') {
|
||||
result.push({
|
||||
objectId: kid.getAttribute('data-id') as Ref<Doc>,
|
||||
attachedTo: kid.getAttribute('data-id') as Ref<Doc>,
|
||||
backlinkId,
|
||||
backlinkClass: chunter.class.Message,
|
||||
message
|
||||
|
@ -43,7 +43,7 @@ export class TMessage extends TDoc implements Message {
|
||||
|
||||
@Model(chunter.class.Comment, core.class.Doc, DOMAIN_COMMENT)
|
||||
export class TComment extends TDoc implements Comment {
|
||||
objectId!: Ref<Doc>
|
||||
attachedTo!: Ref<Doc>
|
||||
message!: string
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ export class TBacklink extends TComment implements Backlink {
|
||||
|
||||
@Model(chunter.class.Attachment, core.class.Doc, DOMAIN_ATTACHMENT)
|
||||
export class TAttachment extends TDoc implements Attachment {
|
||||
attachmentTo!: Ref<Doc>
|
||||
attachedTo!: Ref<Doc>
|
||||
collection!: string
|
||||
name!: string
|
||||
file!: string
|
||||
|
@ -61,6 +61,13 @@ export interface UXObject extends Obj {
|
||||
icon?: Asset
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface AttachedDoc extends Doc {
|
||||
attachedTo: Ref<Doc>
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
|
@ -38,11 +38,11 @@
|
||||
|
||||
const client = getClient()
|
||||
const query = createQuery()
|
||||
$: query.query(chunter.class.Comment, { objectId: object._id }, result => { comments = result })
|
||||
$: query.query(chunter.class.Comment, { attachedTo: object._id }, result => { comments = result })
|
||||
|
||||
function onMessage(event: CustomEvent) {
|
||||
client.createDoc(chunter.class.Comment, object.space, {
|
||||
objectId: object._id,
|
||||
attachedTo: object._id,
|
||||
message: event.detail
|
||||
})
|
||||
console.log(event.detail)
|
||||
|
@ -31,11 +31,11 @@ let comments: Comment[]
|
||||
|
||||
const client = getClient()
|
||||
const query = createQuery()
|
||||
$: query.query(chunter.class.Comment, { objectId: object._id }, result => { comments = result })
|
||||
$: query.query(chunter.class.Comment, { attachedTo: object._id }, result => { comments = result })
|
||||
|
||||
function onMessage(event: CustomEvent) {
|
||||
client.createDoc(chunter.class.Comment, space, {
|
||||
objectId: object._id,
|
||||
attachedTo: object._id,
|
||||
message: event.detail
|
||||
})
|
||||
console.log(event.detail)
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import { plugin } from '@anticrm/platform'
|
||||
import type { Asset, Plugin } from '@anticrm/platform'
|
||||
import type { Space, Doc, Ref, Class } from '@anticrm/core'
|
||||
import type { Space, Doc, Ref, Class, AttachedDoc } from '@anticrm/core'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -32,8 +32,7 @@ export interface Message extends Doc {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface Comment extends Doc {
|
||||
objectId: Ref<Doc>
|
||||
export interface Comment extends AttachedDoc {
|
||||
message: string
|
||||
}
|
||||
|
||||
@ -48,8 +47,7 @@ export interface Backlink extends Comment {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface Attachment extends Doc {
|
||||
attachmentTo: Ref<Doc>
|
||||
export interface Attachment extends AttachedDoc {
|
||||
collection: string
|
||||
name: string
|
||||
file: string
|
||||
|
@ -32,7 +32,7 @@
|
||||
let files: Attachment[] = []
|
||||
|
||||
const query = createQuery()
|
||||
$: query.query(chunter.class.Attachment, { attachmentTo: object._id }, result => { files = result})
|
||||
$: query.query(chunter.class.Attachment, { attachedTo: object._id }, result => { files = result})
|
||||
|
||||
let inputFile: HTMLInputElement
|
||||
let loading = false
|
||||
@ -46,7 +46,7 @@
|
||||
const uuid = await uploadFile(id, object.space, file)
|
||||
console.log('uploaded file uuid', uuid)
|
||||
client.createDoc(chunter.class.Attachment, object.space, {
|
||||
attachmentTo: object._id,
|
||||
attachedTo: object._id,
|
||||
collection: 'attachment',
|
||||
name: file.name,
|
||||
file: uuid,
|
||||
|
@ -61,7 +61,7 @@
|
||||
// create attachment
|
||||
console.log('creaing attachment space', space)
|
||||
client.createDoc(chunter.class.Attachment, space, {
|
||||
attachmentTo: candidateId,
|
||||
attachedTo: candidateId,
|
||||
collection: 'resume',
|
||||
name: resume.name,
|
||||
file: resume.uuid,
|
||||
|
@ -75,7 +75,7 @@
|
||||
// create attachment
|
||||
console.log('creaing attachment space', _space)
|
||||
client.createDoc(chunter.class.Attachment, _space, {
|
||||
attachmentTo: candidateId,
|
||||
attachedTo: candidateId,
|
||||
collection: 'resume',
|
||||
name: resume.name,
|
||||
file: resume.uuid,
|
||||
|
@ -26,7 +26,7 @@ function extractBacklinks (backlinkId: Ref<Doc>, message: string, kids: Node[]):
|
||||
for (const kid of kids) {
|
||||
if ((kid as HTMLElement).localName === 'span') {
|
||||
result.push({
|
||||
objectId: (kid as HTMLElement).getAttribute('data-id') as Ref<Doc>,
|
||||
attachedTo: (kid as HTMLElement).getAttribute('data-id') as Ref<Doc>,
|
||||
backlinkId,
|
||||
backlinkClass: chunter.class.Message,
|
||||
message
|
||||
|
@ -56,10 +56,10 @@ async function minioUpload (minio: Client, workspace: string, file: UploadedFile
|
||||
return id
|
||||
}
|
||||
|
||||
// async function createAttachment (endpoint: string, token: string, account: Ref<Account>, space: Ref<Space>, attachmentTo: Ref<Doc>, collection: string, name: string, file: string): Promise<void> {
|
||||
// async function createAttachment (endpoint: string, token: string, account: Ref<Account>, space: Ref<Space>, attachedTo: Ref<Doc>, collection: string, name: string, file: string): Promise<void> {
|
||||
// const txFactory = new TxFactory(account)
|
||||
// const tx = txFactory.createTxCreateDoc(chunter.class.Attachment, space, {
|
||||
// attachmentTo,
|
||||
// attachedTo,
|
||||
// collection,
|
||||
// name,
|
||||
// file
|
||||
@ -140,7 +140,7 @@ export function start (transactorEndpoint: string, elasticUrl: string, minio: Cl
|
||||
// token,
|
||||
// 'core:account:System' as Ref<Account>,
|
||||
// space,
|
||||
// attachmentTo,
|
||||
// attachedTo,
|
||||
// collection,
|
||||
// name,
|
||||
// fileId
|
||||
|
Loading…
Reference in New Issue
Block a user