introduce AttachedDoc

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-14 10:10:32 +02:00
parent 5554c29eff
commit 6d743c92e9
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
11 changed files with 25 additions and 20 deletions

View File

@ -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

View File

@ -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

View File

@ -61,6 +61,13 @@ export interface UXObject extends Obj {
icon?: Asset
}
/**
* @public
*/
export interface AttachedDoc extends Doc {
attachedTo: Ref<Doc>
}
/**
* @public
*/

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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

View File

@ -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