Initial comments implementation

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-08-18 18:15:16 +02:00
parent 3948111387
commit d28082ee89
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
8 changed files with 238 additions and 206 deletions

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ import type { IntlString } from '@anticrm/platform'
import { Builder, Model, UX } from '@anticrm/model'
import type { Ref, Doc, Class, Domain } from '@anticrm/core'
import core, { TSpace, TDoc } from '@anticrm/model-core'
import type { Backlink, Channel, Message } from '@anticrm/chunter'
import type { Backlink, Channel, Message, Comment } from '@anticrm/chunter'
import type { AnyComponent } from '@anticrm/ui'
import workbench from '@anticrm/model-workbench'
@ -26,7 +26,7 @@ import view from '@anticrm/model-view'
import chunter from './plugin'
export const DOMAIN_CHUNTER = 'chunter' as Domain
export const DOMAIN_BACKLINKS = 'backlinks' as Domain
export const DOMAIN_COMMENT = 'comment' as Domain
@Model(chunter.class.Channel, core.class.Space)
@UX(chunter.string.Channel, chunter.icon.Hashtag)
@ -37,16 +37,20 @@ export class TMessage extends TDoc implements Message {
content!: string
}
@Model(chunter.class.Backlink, core.class.Doc, DOMAIN_BACKLINKS)
export class TBacklink extends TDoc implements Backlink {
@Model(chunter.class.Comment, core.class.Doc, DOMAIN_COMMENT)
export class TComment extends TDoc implements Comment {
objectId!: Ref<Doc>
backlinkId!: Ref<Doc>
backlinkClass!: Ref<Class<Doc>>
message!: string
}
@Model(chunter.class.Backlink, chunter.class.Comment)
export class TBacklink extends TComment implements Backlink {
backlinkId!: Ref<Doc>
backlinkClass!: Ref<Class<Doc>>
}
export function createModel (builder: Builder): void {
builder.createModel(TChannel, TMessage, TBacklink)
builder.createModel(TChannel, TMessage, TComment, TBacklink)
builder.mixin(chunter.class.Channel, core.class.Class, workbench.mixin.SpaceView, {
view: {
class: chunter.class.Message

View File

@ -21,4 +21,3 @@ export { default as UserInfo } from './components/UserInfo.svelte'
export { default as Avatar } from './components/Avatar.svelte'
export { default as MessageViewer } from './components/MessageViewer.svelte'
export { default as AttributeEditor } from './components/AttributeEditor.svelte'
export { default as Backlink } from './components/Backlink.svelte'

View File

@ -16,37 +16,44 @@
<script lang="ts">
import type { Doc } from '@anticrm/core'
import { Backlink as BacklinkComponent } from '@anticrm/presentation'
import type { Backlink } from '@anticrm/chunter'
import type { Doc, Ref, Space } from '@anticrm/core'
import type { Comment } from '@anticrm/chunter'
import { ReferenceInput } from '@anticrm/text-editor'
import { createQuery } from '@anticrm/presentation'
import { createQuery, getClient } from '@anticrm/presentation'
import { Section, IconComments } from '@anticrm/ui'
import Bookmark from './icons/Bookmark.svelte'
import CommentViewer from './CommentViewer.svelte'
import Backlink from './Backlink.svelte'
import chunter from '@anticrm/chunter'
export let object: Doc
export let space: Ref<Space>
let backlinks: Backlink[]
let comments: Comment[]
const client = getClient()
const query = createQuery()
$: query.query(chunter.class.Backlink, { objectId: object._id }, result => { backlinks = result })
$: query.query(chunter.class.Comment, { objectId: object._id }, result => { comments = result })
function onMessage(event: CustomEvent) {
client.createDoc(chunter.class.Comment, space, {
objectId: object._id,
message: event.detail
})
console.log(event.detail)
}
</script>
<Section icon={IconComments} label={'Comments'}>
<div class="reference"><ReferenceInput on:message={onMessage}/></div>
<!-- <Section icon={IconComments} label={'Comments'}>
<CommentViewer />
<div class="reference"><ReferenceInput /></div>
</Section>
{#if backlinks && backlinks.length > 0}
<Section icon={Bookmark} label={'Backlinks'}>
{#each backlinks as backlink}
<BacklinkComponent {backlink} />
</Section> -->
{#if comments}
{#each comments as comment}
<Backlink {comment} />
{/each}
</Section>
{/if}
<style lang="scss">

View File

@ -14,12 +14,12 @@
-->
<script lang="ts">
import type { Backlink } from '@anticrm/chunter'
import MessageViewer from './MessageViewer.svelte'
import type { Comment } from '@anticrm/chunter'
import MessageViewer from '@anticrm/presentation/src/components/MessageViewer.svelte'
import Avatar from './Avatar.svelte'
import Avatar from '@anticrm/presentation/src/components/Avatar.svelte'
export let backlink: Backlink
export let comment: Comment
</script>
@ -27,7 +27,7 @@
<div class="avatar"><Avatar size={'medium'} /></div>
<div class="flex-col-stretch message">
<div class="header">Rosamund Chen<span>July 28th</span></div>
<div class="text"><MessageViewer message={backlink.message} /></div>
<div class="text"><MessageViewer message={comment.message} /></div>
</div>
</div>

View File

@ -32,11 +32,17 @@ export interface Message extends Doc {
/**
* @public
*/
export interface Backlink extends Doc {
export interface Comment extends Doc {
objectId: Ref<Doc>
message: string
}
/**
* @public
*/
export interface Backlink extends Comment {
backlinkId: Ref<Doc>
backlinkClass: Ref<Class<Doc>>
message: string
}
/**
@ -52,7 +58,8 @@ export default plugin(chunterId, {
},
class: {
Message: '' as Ref<Class<Message>>,
Backlink: '' as Ref<Class<Backlink>>
Backlink: '' as Ref<Class<Backlink>>,
Comment: '' as Ref<Class<Comment>>
},
space: {
Backlinks: '' as Ref<Space>

View File

@ -15,6 +15,7 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import type { Ref, Space } from '@anticrm/core'
import { Dialog, Tabs } from '@anticrm/ui'
import { getClient } from '@anticrm/presentation'
import type { Candidate } from '@anticrm/recruit'
@ -23,6 +24,7 @@
import recruit from '../plugin'
export let object: Candidate
export let space: Ref<Space>
const dispatch = createEventDispatcher()
const client = getClient()
@ -52,7 +54,8 @@
label: 'Activity',
component: 'chunter:component:Activity',
props: {
object
object,
space
}
}
]

View File

@ -48,12 +48,10 @@ function getValue(doc: Doc, key: string): any {
return obj
}
const dispatch = createEventDispatcher()
const client = getClient()
function onClick(object: Doc) {
console.log('going modal: ', open)
showModal(open, { object })
showModal(open, { object, space })
}
</script>