mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
Initial comments implementation
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
3948111387
commit
d28082ee89
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@ import type { IntlString } from '@anticrm/platform'
|
|||||||
import { Builder, Model, UX } from '@anticrm/model'
|
import { Builder, Model, UX } from '@anticrm/model'
|
||||||
import type { Ref, Doc, Class, Domain } from '@anticrm/core'
|
import type { Ref, Doc, Class, Domain } from '@anticrm/core'
|
||||||
import core, { TSpace, TDoc } from '@anticrm/model-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 type { AnyComponent } from '@anticrm/ui'
|
||||||
|
|
||||||
import workbench from '@anticrm/model-workbench'
|
import workbench from '@anticrm/model-workbench'
|
||||||
@ -26,7 +26,7 @@ import view from '@anticrm/model-view'
|
|||||||
import chunter from './plugin'
|
import chunter from './plugin'
|
||||||
|
|
||||||
export const DOMAIN_CHUNTER = 'chunter' as Domain
|
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)
|
@Model(chunter.class.Channel, core.class.Space)
|
||||||
@UX(chunter.string.Channel, chunter.icon.Hashtag)
|
@UX(chunter.string.Channel, chunter.icon.Hashtag)
|
||||||
@ -37,16 +37,20 @@ export class TMessage extends TDoc implements Message {
|
|||||||
content!: string
|
content!: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(chunter.class.Backlink, core.class.Doc, DOMAIN_BACKLINKS)
|
@Model(chunter.class.Comment, core.class.Doc, DOMAIN_COMMENT)
|
||||||
export class TBacklink extends TDoc implements Backlink {
|
export class TComment extends TDoc implements Comment {
|
||||||
objectId!: Ref<Doc>
|
objectId!: Ref<Doc>
|
||||||
backlinkId!: Ref<Doc>
|
|
||||||
backlinkClass!: Ref<Class<Doc>>
|
|
||||||
message!: string
|
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 {
|
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, {
|
builder.mixin(chunter.class.Channel, core.class.Class, workbench.mixin.SpaceView, {
|
||||||
view: {
|
view: {
|
||||||
class: chunter.class.Message
|
class: chunter.class.Message
|
||||||
|
@ -21,4 +21,3 @@ export { default as UserInfo } from './components/UserInfo.svelte'
|
|||||||
export { default as Avatar } from './components/Avatar.svelte'
|
export { default as Avatar } from './components/Avatar.svelte'
|
||||||
export { default as MessageViewer } from './components/MessageViewer.svelte'
|
export { default as MessageViewer } from './components/MessageViewer.svelte'
|
||||||
export { default as AttributeEditor } from './components/AttributeEditor.svelte'
|
export { default as AttributeEditor } from './components/AttributeEditor.svelte'
|
||||||
export { default as Backlink } from './components/Backlink.svelte'
|
|
||||||
|
@ -16,37 +16,44 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import type { Doc } from '@anticrm/core'
|
import type { Doc, Ref, Space } from '@anticrm/core'
|
||||||
import { Backlink as BacklinkComponent } from '@anticrm/presentation'
|
import type { Comment } from '@anticrm/chunter'
|
||||||
import type { Backlink } from '@anticrm/chunter'
|
|
||||||
import { ReferenceInput } from '@anticrm/text-editor'
|
import { ReferenceInput } from '@anticrm/text-editor'
|
||||||
import { createQuery } from '@anticrm/presentation'
|
import { createQuery, getClient } from '@anticrm/presentation'
|
||||||
import { Section, IconComments } from '@anticrm/ui'
|
import { Section, IconComments } from '@anticrm/ui'
|
||||||
|
|
||||||
import Bookmark from './icons/Bookmark.svelte'
|
import Bookmark from './icons/Bookmark.svelte'
|
||||||
import CommentViewer from './CommentViewer.svelte'
|
import Backlink from './Backlink.svelte'
|
||||||
|
|
||||||
import chunter from '@anticrm/chunter'
|
import chunter from '@anticrm/chunter'
|
||||||
|
|
||||||
export let object: Doc
|
export let object: Doc
|
||||||
|
export let space: Ref<Space>
|
||||||
|
|
||||||
let backlinks: Backlink[]
|
let comments: Comment[]
|
||||||
|
|
||||||
|
const client = getClient()
|
||||||
const query = createQuery()
|
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>
|
</script>
|
||||||
|
|
||||||
<Section icon={IconComments} label={'Comments'}>
|
<div class="reference"><ReferenceInput on:message={onMessage}/></div>
|
||||||
|
|
||||||
|
<!-- <Section icon={IconComments} label={'Comments'}>
|
||||||
<CommentViewer />
|
<CommentViewer />
|
||||||
<div class="reference"><ReferenceInput /></div>
|
</Section> -->
|
||||||
</Section>
|
{#if comments}
|
||||||
{#if backlinks && backlinks.length > 0}
|
{#each comments as comment}
|
||||||
<Section icon={Bookmark} label={'Backlinks'}>
|
<Backlink {comment} />
|
||||||
{#each backlinks as backlink}
|
|
||||||
<BacklinkComponent {backlink} />
|
|
||||||
{/each}
|
{/each}
|
||||||
</Section>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Backlink } from '@anticrm/chunter'
|
import type { Comment } from '@anticrm/chunter'
|
||||||
import MessageViewer from './MessageViewer.svelte'
|
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>
|
</script>
|
||||||
|
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<div class="avatar"><Avatar size={'medium'} /></div>
|
<div class="avatar"><Avatar size={'medium'} /></div>
|
||||||
<div class="flex-col-stretch message">
|
<div class="flex-col-stretch message">
|
||||||
<div class="header">Rosamund Chen<span>July 28th</span></div>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -32,11 +32,17 @@ export interface Message extends Doc {
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export interface Backlink extends Doc {
|
export interface Comment extends Doc {
|
||||||
objectId: Ref<Doc>
|
objectId: Ref<Doc>
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export interface Backlink extends Comment {
|
||||||
backlinkId: Ref<Doc>
|
backlinkId: Ref<Doc>
|
||||||
backlinkClass: Ref<Class<Doc>>
|
backlinkClass: Ref<Class<Doc>>
|
||||||
message: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +58,8 @@ export default plugin(chunterId, {
|
|||||||
},
|
},
|
||||||
class: {
|
class: {
|
||||||
Message: '' as Ref<Class<Message>>,
|
Message: '' as Ref<Class<Message>>,
|
||||||
Backlink: '' as Ref<Class<Backlink>>
|
Backlink: '' as Ref<Class<Backlink>>,
|
||||||
|
Comment: '' as Ref<Class<Comment>>
|
||||||
},
|
},
|
||||||
space: {
|
space: {
|
||||||
Backlinks: '' as Ref<Space>
|
Backlinks: '' as Ref<Space>
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
|
import type { Ref, Space } from '@anticrm/core'
|
||||||
import { Dialog, Tabs } from '@anticrm/ui'
|
import { Dialog, Tabs } from '@anticrm/ui'
|
||||||
import { getClient } from '@anticrm/presentation'
|
import { getClient } from '@anticrm/presentation'
|
||||||
import type { Candidate } from '@anticrm/recruit'
|
import type { Candidate } from '@anticrm/recruit'
|
||||||
@ -23,6 +24,7 @@
|
|||||||
import recruit from '../plugin'
|
import recruit from '../plugin'
|
||||||
|
|
||||||
export let object: Candidate
|
export let object: Candidate
|
||||||
|
export let space: Ref<Space>
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
@ -52,7 +54,8 @@
|
|||||||
label: 'Activity',
|
label: 'Activity',
|
||||||
component: 'chunter:component:Activity',
|
component: 'chunter:component:Activity',
|
||||||
props: {
|
props: {
|
||||||
object
|
object,
|
||||||
|
space
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -48,12 +48,10 @@ function getValue(doc: Doc, key: string): any {
|
|||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
function onClick(object: Doc) {
|
function onClick(object: Doc) {
|
||||||
console.log('going modal: ', open)
|
showModal(open, { object, space })
|
||||||
showModal(open, { object })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user