mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-21 07:46:24 +00:00
1304 Edit message (#1395)
Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
parent
e83ffd3804
commit
da45faf7d1
@ -31,6 +31,7 @@
|
|||||||
"MarkUnread": "Mark unread",
|
"MarkUnread": "Mark unread",
|
||||||
"GetNewReplies": "Get notified about new replies",
|
"GetNewReplies": "Get notified about new replies",
|
||||||
"TurnOffReplies": "Turn off notifications for replies",
|
"TurnOffReplies": "Turn off notifications for replies",
|
||||||
|
"EditMessage": "Edit message",
|
||||||
"DeleteMessage": "Delete message"
|
"DeleteMessage": "Delete message"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,6 +30,7 @@
|
|||||||
"MarkUnread": "Отметить как непрочитанное",
|
"MarkUnread": "Отметить как непрочитанное",
|
||||||
"GetNewReplies": "Получать уведомления о новых ответах",
|
"GetNewReplies": "Получать уведомления о новых ответах",
|
||||||
"TurnOffReplies": "Выключить уведомления об ответах",
|
"TurnOffReplies": "Выключить уведомления об ответах",
|
||||||
|
"EditMessage": "Редактировать сообщение",
|
||||||
"DeleteMessage": "Удалить сообщение"
|
"DeleteMessage": "Удалить сообщение"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Attachment } from '@anticrm/attachment'
|
import { Attachment } from '@anticrm/attachment'
|
||||||
import { AttachmentList } from '@anticrm/attachment-resources'
|
import { AttachmentList, AttachmentRefInput } from '@anticrm/attachment-resources'
|
||||||
import type { Message } from '@anticrm/chunter'
|
import type { Message } from '@anticrm/chunter'
|
||||||
import { Employee, EmployeeAccount, formatName } from '@anticrm/contact'
|
import { Employee, EmployeeAccount, formatName } from '@anticrm/contact'
|
||||||
import { Ref, WithLookup, getCurrentAccount } from '@anticrm/core'
|
import { Ref, WithLookup, getCurrentAccount } from '@anticrm/core'
|
||||||
@ -59,6 +59,13 @@
|
|||||||
action: chunter.actionImpl.SubscribeMessage
|
action: chunter.actionImpl.SubscribeMessage
|
||||||
} as Action)
|
} as Action)
|
||||||
|
|
||||||
|
$: isEditing = false;
|
||||||
|
|
||||||
|
const editAction = {
|
||||||
|
label: chunter.string.EditMessage,
|
||||||
|
action: () => isEditing = true
|
||||||
|
}
|
||||||
|
|
||||||
const deleteAction = {
|
const deleteAction = {
|
||||||
label: chunter.string.DeleteMessage,
|
label: chunter.string.DeleteMessage,
|
||||||
action: async () => await client.remove(message)
|
action: async () => await client.remove(message)
|
||||||
@ -79,13 +86,28 @@
|
|||||||
await impl(message)
|
await impl(message)
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
...(getCurrentAccount()._id === message.createBy ? [deleteAction] : [])
|
...(getCurrentAccount()._id === message.createBy ? [editAction, deleteAction] : [])
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
ev.target as HTMLElement
|
ev.target as HTMLElement
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onMessageEdit (event: CustomEvent) {
|
||||||
|
const { message: newContent, attachments: newAttachments } = event.detail
|
||||||
|
|
||||||
|
if (newContent !== message.content || newAttachments !== attachments) {
|
||||||
|
await client.update(
|
||||||
|
message,
|
||||||
|
{
|
||||||
|
content: newContent,
|
||||||
|
attachments: newAttachments
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
isEditing = false
|
||||||
|
}
|
||||||
|
|
||||||
function getEmployee (message: WithLookup<Message>): Employee | undefined {
|
function getEmployee (message: WithLookup<Message>): Employee | undefined {
|
||||||
const employee = (message.$lookup?.createBy as EmployeeAccount).employee
|
const employee = (message.$lookup?.createBy as EmployeeAccount).employee
|
||||||
if (employee !== undefined) {
|
if (employee !== undefined) {
|
||||||
@ -105,8 +127,18 @@
|
|||||||
{#if employee}{formatName(employee.name)}{/if}
|
{#if employee}{formatName(employee.name)}{/if}
|
||||||
<span>{getTime(message.createOn)}</span>
|
<span>{getTime(message.createOn)}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="text"><MessageViewer message={message.content} /></div>
|
{#if isEditing}
|
||||||
{#if message.attachments}<div class="attachments"><AttachmentList {attachments} /></div>{/if}
|
<AttachmentRefInput
|
||||||
|
space={message.space}
|
||||||
|
_class={chunter.class.Comment}
|
||||||
|
objectId={message._id}
|
||||||
|
content={message.content}
|
||||||
|
on:message={onMessageEdit}
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<div class="text"><MessageViewer message={message.content} /></div>
|
||||||
|
{#if message.attachments}<div class="attachments"><AttachmentList {attachments} /></div>{/if}
|
||||||
|
{/if}
|
||||||
{#if reactions || message.replies}
|
{#if reactions || message.replies}
|
||||||
<div class="footer flex-col">
|
<div class="footer flex-col">
|
||||||
<div>
|
<div>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Attachment } from '@anticrm/attachment'
|
import { Attachment } from '@anticrm/attachment'
|
||||||
import { AttachmentList } from '@anticrm/attachment-resources'
|
import { AttachmentList, AttachmentRefInput } from '@anticrm/attachment-resources'
|
||||||
import type { ThreadMessage } from '@anticrm/chunter'
|
import type { ThreadMessage } from '@anticrm/chunter'
|
||||||
import { Employee, EmployeeAccount, formatName } from '@anticrm/contact'
|
import { Employee, EmployeeAccount, formatName } from '@anticrm/contact'
|
||||||
import { Ref, WithLookup, getCurrentAccount } from '@anticrm/core'
|
import { Ref, WithLookup, getCurrentAccount } from '@anticrm/core'
|
||||||
@ -53,6 +53,13 @@
|
|||||||
action: chunter.actionImpl.SubscribeComment
|
action: chunter.actionImpl.SubscribeComment
|
||||||
} as Action)
|
} as Action)
|
||||||
|
|
||||||
|
$: isEditing = false;
|
||||||
|
|
||||||
|
const editAction = {
|
||||||
|
label: chunter.string.EditMessage,
|
||||||
|
action: () => isEditing = true
|
||||||
|
}
|
||||||
|
|
||||||
const deleteAction = {
|
const deleteAction = {
|
||||||
label: chunter.string.DeleteMessage,
|
label: chunter.string.DeleteMessage,
|
||||||
action: async () => await client.removeDoc(message._class, message.space, message._id)
|
action: async () => await client.removeDoc(message._class, message.space, message._id)
|
||||||
@ -73,13 +80,28 @@
|
|||||||
await impl(message)
|
await impl(message)
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
...(getCurrentAccount()._id === message.createBy ? [deleteAction] : [])
|
...(getCurrentAccount()._id === message.createBy ? [editAction, deleteAction] : [])
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
ev.target as HTMLElement
|
ev.target as HTMLElement
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onMessageEdit (event: CustomEvent) {
|
||||||
|
const { message: newContent, attachments: newAttachments } = event.detail
|
||||||
|
|
||||||
|
if (newContent !== message.content || newAttachments !== attachments) {
|
||||||
|
await client.update(
|
||||||
|
message,
|
||||||
|
{
|
||||||
|
content: newContent,
|
||||||
|
attachments: newAttachments
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
isEditing = false
|
||||||
|
}
|
||||||
|
|
||||||
$: employee = getEmployee(message)
|
$: employee = getEmployee(message)
|
||||||
|
|
||||||
function getEmployee (comment: WithLookup<ThreadMessage>): Employee | undefined {
|
function getEmployee (comment: WithLookup<ThreadMessage>): Employee | undefined {
|
||||||
@ -97,8 +119,18 @@
|
|||||||
{#if employee}{formatName(employee.name)}{/if}
|
{#if employee}{formatName(employee.name)}{/if}
|
||||||
<span>{getTime(message.createOn)}</span>
|
<span>{getTime(message.createOn)}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="text"><MessageViewer message={message.content} /></div>
|
{#if isEditing}
|
||||||
{#if message.attachments}<div class="attachments"><AttachmentList {attachments} /></div>{/if}
|
<AttachmentRefInput
|
||||||
|
space={message.space}
|
||||||
|
_class={chunter.class.Comment}
|
||||||
|
objectId={message._id}
|
||||||
|
content={message.content}
|
||||||
|
on:message={onMessageEdit}
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<div class="text"><MessageViewer message={message.content} /></div>
|
||||||
|
{#if message.attachments}<div class="attachments"><AttachmentList {attachments} /></div>{/if}
|
||||||
|
{/if}
|
||||||
{#if reactions}
|
{#if reactions}
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div><Reactions /></div>
|
<div><Reactions /></div>
|
||||||
|
@ -51,6 +51,7 @@ export default mergeIds(chunterId, chunter, {
|
|||||||
New: '' as IntlString,
|
New: '' as IntlString,
|
||||||
GetNewReplies: '' as IntlString,
|
GetNewReplies: '' as IntlString,
|
||||||
TurnOffReplies: '' as IntlString,
|
TurnOffReplies: '' as IntlString,
|
||||||
DeleteMessage: '' as IntlString
|
DeleteMessage: '' as IntlString,
|
||||||
|
EditMessage: '' as IntlString
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user