mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 12:25:17 +00:00
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
51b0cdb5f4
commit
7cbbb0a919
@ -15,8 +15,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import type { IntlString } from '@anticrm/platform'
|
import type { IntlString } from '@anticrm/platform'
|
||||||
import { Builder, Model, TypeString, Prop, ArrOf } from '@anticrm/model'
|
import { Builder, Model, TypeString, Prop, ArrOf, TypeBoolean } from '@anticrm/model'
|
||||||
import core, { TAttachedDoc, TDoc } from '@anticrm/model-core'
|
import core, { TAttachedDoc } from '@anticrm/model-core'
|
||||||
import contact from '@anticrm/model-contact'
|
import contact from '@anticrm/model-contact'
|
||||||
import gmail from './plugin'
|
import gmail from './plugin'
|
||||||
import type { Message, SharedMessage, SharedMessages } from '@anticrm/gmail'
|
import type { Message, SharedMessage, SharedMessages } from '@anticrm/gmail'
|
||||||
@ -30,8 +30,8 @@ function TypeSharedMessage (): Type<SharedMessage> {
|
|||||||
return { _class: gmail.class.SharedMessage, label: 'Shared message' as IntlString }
|
return { _class: gmail.class.SharedMessage, label: 'Shared message' as IntlString }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(gmail.class.Message, core.class.Doc, DOMAIN_GMAIL)
|
@Model(gmail.class.Message, core.class.AttachedDoc, DOMAIN_GMAIL)
|
||||||
export class TMessage extends TDoc implements Message {
|
export class TMessage extends TAttachedDoc implements Message {
|
||||||
@Prop(TypeString(), gmail.string.MessageID)
|
@Prop(TypeString(), gmail.string.MessageID)
|
||||||
messageId!: string
|
messageId!: string
|
||||||
|
|
||||||
@ -58,6 +58,9 @@ export class TMessage extends TDoc implements Message {
|
|||||||
|
|
||||||
@Prop(ArrOf(TypeString()), 'Copy' as IntlString)
|
@Prop(ArrOf(TypeString()), 'Copy' as IntlString)
|
||||||
copy?: string[]
|
copy?: string[]
|
||||||
|
|
||||||
|
@Prop(TypeBoolean(), 'Incoming' as IntlString)
|
||||||
|
incoming!: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(gmail.class.SharedMessages, core.class.AttachedDoc, DOMAIN_GMAIL)
|
@Model(gmail.class.SharedMessages, core.class.AttachedDoc, DOMAIN_GMAIL)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { createQuery, getClient } from '@anticrm/presentation'
|
import { createQuery, getClient } from '@anticrm/presentation'
|
||||||
import { Message, SharedMessage } from '@anticrm/gmail'
|
import { Message, SharedMessage } from '@anticrm/gmail'
|
||||||
import gmail from '../plugin'
|
import gmail from '../plugin'
|
||||||
import { Contact, EmployeeAccount, formatName } from '@anticrm/contact'
|
import { Channel, Contact, EmployeeAccount, formatName } from '@anticrm/contact'
|
||||||
import contact from '@anticrm/contact'
|
import contact from '@anticrm/contact'
|
||||||
import { ActionIcon, IconShare, Button, ScrollBox, showPopup, Icon, Label } from '@anticrm/ui'
|
import { ActionIcon, IconShare, Button, ScrollBox, showPopup, Icon, Label } from '@anticrm/ui'
|
||||||
import { getCurrentAccount, Ref, SortingOrder, Space } from '@anticrm/core'
|
import { getCurrentAccount, Ref, SortingOrder, Space } from '@anticrm/core'
|
||||||
@ -27,7 +27,7 @@
|
|||||||
import Messages from './Messages.svelte'
|
import Messages from './Messages.svelte'
|
||||||
|
|
||||||
export let object: Contact
|
export let object: Contact
|
||||||
export let contactString: string
|
export let channel: Channel
|
||||||
export let newMessage: boolean
|
export let newMessage: boolean
|
||||||
|
|
||||||
let messages: Message[] = []
|
let messages: Message[] = []
|
||||||
@ -44,9 +44,9 @@
|
|||||||
|
|
||||||
$: messagesQuery.query(
|
$: messagesQuery.query(
|
||||||
gmail.class.Message,
|
gmail.class.Message,
|
||||||
{ modifiedBy: accountId, contact: { $like: '%' + contactString + '%' } },
|
{ modifiedBy: accountId, attachedTo: channel._id },
|
||||||
(res) => {
|
(res) => {
|
||||||
// messages = res
|
messages = res
|
||||||
},
|
},
|
||||||
{ sort: { modifiedOn: SortingOrder.Descending } }
|
{ sort: { modifiedOn: SortingOrder.Descending } }
|
||||||
)
|
)
|
||||||
@ -59,15 +59,15 @@
|
|||||||
setting.class.Integration,
|
setting.class.Integration,
|
||||||
{ type: gmail.integrationType.Gmail, space: accountId as string as Ref<Space> },
|
{ type: gmail.integrationType.Gmail, space: accountId as string as Ref<Space> },
|
||||||
(res) => {
|
(res) => {
|
||||||
// enabled = res.length > 0
|
enabled = res.length > 0
|
||||||
// me = res[0].value
|
me = res[0].value
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
async function share (): Promise<void> {
|
async function share (): Promise<void> {
|
||||||
const selectedMessages = messages.filter((m) => selected.has(m._id as string as Ref<SharedMessage>))
|
const selectedMessages = messages.filter((m) => selected.has(m._id as string as Ref<SharedMessage>))
|
||||||
await client.addCollection(gmail.class.SharedMessages, object.space, object._id, object._class, 'gmailMessages', {
|
await client.addCollection(gmail.class.SharedMessages, object.space, object._id, object._class, 'gmailSharedMessages', {
|
||||||
messages: convertMessages(selectedMessages)
|
messages: convertMessages(selectedMessages)
|
||||||
})
|
})
|
||||||
clear()
|
clear()
|
||||||
@ -85,21 +85,16 @@
|
|||||||
...m,
|
...m,
|
||||||
_id: m._id as string as Ref<SharedMessage>,
|
_id: m._id as string as Ref<SharedMessage>,
|
||||||
sender: account ? getName(m, account, true) : '',
|
sender: account ? getName(m, account, true) : '',
|
||||||
receiver: account ? getName(m, account, false) : '',
|
receiver: account ? getName(m, account, false) : ''
|
||||||
incoming: !amISender(m)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName (message: Message, account: EmployeeAccount, sender: boolean): string {
|
function getName (message: Message, account: EmployeeAccount, sender: boolean): string {
|
||||||
return amISender(message) !== sender
|
return message.incoming === sender
|
||||||
? `${formatName(object.name)} (${contactString})`
|
? `${formatName(object.name)} (${channel.value})`
|
||||||
: `${formatName(account.name)} (${me})`
|
: `${formatName(account.name)} (${me})`
|
||||||
}
|
}
|
||||||
|
|
||||||
function amISender (message: Message): boolean {
|
|
||||||
return !message.from.includes(contactString)
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex-between header">
|
<div class="flex-between header">
|
||||||
|
@ -24,14 +24,14 @@
|
|||||||
export let object: Contact
|
export let object: Contact
|
||||||
let newMessage: boolean = false
|
let newMessage: boolean = false
|
||||||
let currentMessage: SharedMessage | undefined = undefined
|
let currentMessage: SharedMessage | undefined = undefined
|
||||||
let channelValue: string | undefined = undefined
|
let channel: Channel | undefined = undefined
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
client.findOne(contact.class.Channel, {
|
client.findOne(contact.class.Channel, {
|
||||||
attachedTo: object._id,
|
attachedTo: object._id,
|
||||||
provider: contact.channelProvider.Email
|
provider: contact.channelProvider.Email
|
||||||
}).then((res) => channelValue = res?.value)
|
}).then((res) => channel = res)
|
||||||
|
|
||||||
function back () {
|
function back () {
|
||||||
if (newMessage) {
|
if (newMessage) {
|
||||||
@ -45,12 +45,12 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if channelValue}
|
{#if channel}
|
||||||
{#if newMessage}
|
{#if newMessage}
|
||||||
<NewMessage {object} contact={channelValue} {currentMessage} on:close={back} />
|
<NewMessage {object} {channel} {currentMessage} on:close={back} />
|
||||||
{:else if currentMessage}
|
{:else if currentMessage}
|
||||||
<FullMessage {currentMessage} bind:newMessage on:close={back} />
|
<FullMessage {currentMessage} bind:newMessage on:close={back} />
|
||||||
{:else}
|
{:else}
|
||||||
<Chats {object} contactString={channelValue} bind:newMessage on:select={selectHandler} />
|
<Chats {object} {channel} bind:newMessage on:select={selectHandler} />
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
import Button from '@anticrm/ui/src/components/Button.svelte'
|
import Button from '@anticrm/ui/src/components/Button.svelte'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import { IconArrowLeft, Label } from '@anticrm/ui'
|
import { IconArrowLeft, Label } from '@anticrm/ui'
|
||||||
import { Contact, formatName } from '@anticrm/contact'
|
import { Channel, Contact, formatName } from '@anticrm/contact'
|
||||||
import { TextEditor } from '@anticrm/text-editor'
|
import { TextEditor } from '@anticrm/text-editor'
|
||||||
import plugin from '../plugin'
|
import plugin from '../plugin'
|
||||||
|
|
||||||
export let object: Contact
|
export let object: Contact
|
||||||
export let contact: string
|
export let channel: Channel
|
||||||
export let currentMessage: SharedMessage | undefined
|
export let currentMessage: SharedMessage | undefined
|
||||||
|
|
||||||
let editor: TextEditor
|
let editor: TextEditor
|
||||||
@ -35,7 +35,7 @@
|
|||||||
const obj: NewMessage = {
|
const obj: NewMessage = {
|
||||||
subject: currentMessage ? 'RE: ' + currentMessage.subject : '',
|
subject: currentMessage ? 'RE: ' + currentMessage.subject : '',
|
||||||
content: '',
|
content: '',
|
||||||
to: contact,
|
to: channel.value,
|
||||||
replyTo: currentMessage?.messageId
|
replyTo: currentMessage?.messageId
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@
|
|||||||
<div class="fs-title">Gmail</div>
|
<div class="fs-title">Gmail</div>
|
||||||
<div class="small-text content-dark-color overflow-label">
|
<div class="small-text content-dark-color overflow-label">
|
||||||
<Label label={plugin.string.NewMessageTo} />
|
<Label label={plugin.string.NewMessageTo} />
|
||||||
<span class="content-accent-color">{formatName(object.name)} ({contact})</span>
|
<span class="content-accent-color">{formatName(object.name)} ({channel.value})</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-3">
|
<div class="mr-3">
|
||||||
|
@ -22,11 +22,11 @@ import type { IntegrationType, Handler } from '@anticrm/setting'
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export interface Message extends NewMessage, Doc {
|
export interface Message extends NewMessage, AttachedDoc {
|
||||||
messageId: string
|
messageId: string
|
||||||
from: string
|
from: string
|
||||||
textContent: string
|
textContent: string
|
||||||
contact: string
|
incoming: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user