mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-20 07:10:02 +00:00
Open channel links (#2561)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
375513e75b
commit
febd582637
@ -151,7 +151,13 @@
|
|||||||
class="select-text cover-channel"
|
class="select-text cover-channel"
|
||||||
class:show
|
class:show
|
||||||
class:copied={label === plugin.string.Copied}
|
class:copied={label === plugin.string.Copied}
|
||||||
data-tooltip={lTraslate}>{value}</span
|
class:cursor-pointer={openable}
|
||||||
|
data-tooltip={lTraslate}
|
||||||
|
on:click={() => {
|
||||||
|
if (openable) {
|
||||||
|
dispatch('update', 'open')
|
||||||
|
}
|
||||||
|
}}>{value}</span
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
focusIndex={3}
|
focusIndex={3}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
showPopup
|
showPopup
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import { ViewAction } from '@hcengineering/view'
|
import { ViewAction } from '@hcengineering/view'
|
||||||
|
import { invokeAction } from '@hcengineering/view-resources'
|
||||||
import { createEventDispatcher, tick } from 'svelte'
|
import { createEventDispatcher, tick } from 'svelte'
|
||||||
import { getChannelProviders } from '../utils'
|
import { getChannelProviders } from '../utils'
|
||||||
import ChannelEditor from './ChannelEditor.svelte'
|
import ChannelEditor from './ChannelEditor.svelte'
|
||||||
@ -58,6 +59,7 @@
|
|||||||
presenter?: AnyComponent
|
presenter?: AnyComponent
|
||||||
action?: ViewAction
|
action?: ViewAction
|
||||||
placeholder: IntlString
|
placeholder: IntlString
|
||||||
|
channel: AttachedData<Channel> | Channel
|
||||||
provider: Ref<ChannelProvider>
|
provider: Ref<ChannelProvider>
|
||||||
integration: boolean
|
integration: boolean
|
||||||
notification: boolean
|
notification: boolean
|
||||||
@ -67,7 +69,7 @@
|
|||||||
item: AttachedData<Channel>,
|
item: AttachedData<Channel>,
|
||||||
map: Map<Ref<ChannelProvider>, ChannelProvider>,
|
map: Map<Ref<ChannelProvider>, ChannelProvider>,
|
||||||
lastViews: Map<Ref<Doc>, Timestamp>
|
lastViews: Map<Ref<Doc>, Timestamp>
|
||||||
): any | undefined {
|
): Item | undefined {
|
||||||
const provider = map.get(item.provider)
|
const provider = map.get(item.provider)
|
||||||
if (provider) {
|
if (provider) {
|
||||||
const notification = (item as Channel)._id !== undefined ? isNew(item as Channel, lastViews) : false
|
const notification = (item as Channel)._id !== undefined ? isNew(item as Channel, lastViews) : false
|
||||||
@ -79,6 +81,7 @@
|
|||||||
action: provider.action,
|
action: provider.action,
|
||||||
placeholder: provider.placeholder,
|
placeholder: provider.placeholder,
|
||||||
provider: provider._id,
|
provider: provider._id,
|
||||||
|
channel: item,
|
||||||
notification,
|
notification,
|
||||||
integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false
|
integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false
|
||||||
}
|
}
|
||||||
@ -98,7 +101,7 @@
|
|||||||
displayItems = []
|
displayItems = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const result = []
|
const result: Item[] = []
|
||||||
const map = await getChannelProviders()
|
const map = await getChannelProviders()
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
for (const item of value) {
|
for (const item of value) {
|
||||||
@ -186,7 +189,7 @@
|
|||||||
value: item.value,
|
value: item.value,
|
||||||
placeholder: item.placeholder,
|
placeholder: item.placeholder,
|
||||||
editable,
|
editable,
|
||||||
openable: item.presenter ?? false
|
openable: item.presenter ?? item.action ?? false
|
||||||
},
|
},
|
||||||
el,
|
el,
|
||||||
(result) => {
|
(result) => {
|
||||||
@ -201,7 +204,14 @@
|
|||||||
}
|
}
|
||||||
if (result === undefined && item.value === '') displayItems = dropItem(n)
|
if (result === undefined && item.value === '') displayItems = dropItem(n)
|
||||||
opened = undefined
|
opened = undefined
|
||||||
if (result === 'open') dispatch('open', item)
|
if (result === 'open') {
|
||||||
|
if (item.action) {
|
||||||
|
const doc = item.channel as Channel
|
||||||
|
invokeAction(doc, result, item.action)
|
||||||
|
} else {
|
||||||
|
dispatch('open', item)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(result) => {
|
(result) => {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
@ -216,6 +226,21 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateTooltip = (result: CustomEvent, item: Item, i: number): void => {
|
||||||
|
if (result.detail === 'open') {
|
||||||
|
closeTooltip()
|
||||||
|
if (item.action) {
|
||||||
|
const doc = item.channel as Channel
|
||||||
|
invokeAction(doc, result, item.action)
|
||||||
|
} else {
|
||||||
|
dispatch('open', item)
|
||||||
|
}
|
||||||
|
} else if (result.detail === 'edit') {
|
||||||
|
closeTooltip()
|
||||||
|
editChannel(btns[i], i, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@ -249,40 +274,21 @@
|
|||||||
value: item.value,
|
value: item.value,
|
||||||
placeholder: item.placeholder,
|
placeholder: item.placeholder,
|
||||||
editable: editable !== undefined ? false : undefined,
|
editable: editable !== undefined ? false : undefined,
|
||||||
openable: item.presenter ?? false
|
openable: item.presenter ?? item.action ?? false
|
||||||
},
|
},
|
||||||
onUpdate: (result) => {
|
onUpdate: (result) => {
|
||||||
if (result.detail === 'open') {
|
updateTooltip(result, item, i)
|
||||||
closeTooltip()
|
|
||||||
dispatch('open', item)
|
|
||||||
} else if (result.detail === 'edit') {
|
|
||||||
closeTooltip()
|
|
||||||
editChannel(btns[i], i, item)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
{#if actions.length > 0 && editable}
|
{#if actions.length > 0 && editable}
|
||||||
{#if displayItems.length === 0}
|
|
||||||
<Button
|
|
||||||
focusIndex={focusIndex === -1 ? focusIndex : focusIndex + 2 + displayItems.length}
|
|
||||||
id={presentation.string.AddSocialLinks}
|
|
||||||
bind:input={addBtn}
|
|
||||||
icon={contact.icon.SocialEdit}
|
|
||||||
label={presentation.string.AddSocialLinks}
|
|
||||||
notSelected
|
|
||||||
{kind}
|
|
||||||
{size}
|
|
||||||
{shape}
|
|
||||||
on:click={showMenu}
|
|
||||||
/>
|
|
||||||
{:else}
|
|
||||||
<Button
|
<Button
|
||||||
focusIndex={focusIndex === -1 ? focusIndex : focusIndex + 2 + displayItems.length}
|
focusIndex={focusIndex === -1 ? focusIndex : focusIndex + 2 + displayItems.length}
|
||||||
id={presentation.string.AddSocialLinks}
|
id={presentation.string.AddSocialLinks}
|
||||||
bind:input={addBtn}
|
bind:input={addBtn}
|
||||||
icon={contact.icon.SocialEdit}
|
icon={contact.icon.SocialEdit}
|
||||||
|
label={displayItems.length === 0 ? presentation.string.AddSocialLinks : undefined}
|
||||||
{kind}
|
{kind}
|
||||||
{size}
|
{size}
|
||||||
{shape}
|
{shape}
|
||||||
@ -290,5 +296,4 @@
|
|||||||
on:click={showMenu}
|
on:click={showMenu}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -107,11 +107,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _open (ev: any) {
|
function _open (ev: any) {
|
||||||
if (ev.detail.presenter !== undefined && Array.isArray(channels)) {
|
if (ev.detail.presenter !== undefined) {
|
||||||
const channel = channels[0]
|
if (allowOpen) {
|
||||||
if (channel !== undefined && allowOpen) {
|
|
||||||
closeTooltip()
|
closeTooltip()
|
||||||
showPopup(ev.detail.presenter, { _id: channel.attachedTo, _class: channel.attachedToClass }, 'float')
|
showPopup(ev.detail.presenter, { _id: attachedTo, _class: attachedClass }, 'float')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,6 @@
|
|||||||
|
|
||||||
const copyLink = (): void => {
|
const copyLink = (): void => {
|
||||||
copyTextToClipboard(value.value)
|
copyTextToClipboard(value.value)
|
||||||
// .then(() => {
|
|
||||||
// console.log('Copied!', value.value)
|
|
||||||
// })
|
|
||||||
// .catch((err) => {
|
|
||||||
// console.log('Something went wrong', err)
|
|
||||||
// })
|
|
||||||
closeTooltip()
|
closeTooltip()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -14,23 +14,22 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Ref, Doc, Class } from '@hcengineering/core'
|
|
||||||
import contact, { Channel, formatName } from '@hcengineering/contact'
|
import contact, { Channel, formatName } from '@hcengineering/contact'
|
||||||
|
import { Class, Doc, Ref } from '@hcengineering/core'
|
||||||
import { SharedMessage } from '@hcengineering/gmail'
|
import { SharedMessage } from '@hcengineering/gmail'
|
||||||
import NewMessage from './NewMessage.svelte'
|
|
||||||
import FullMessage from './FullMessage.svelte'
|
|
||||||
import Chats from './Chats.svelte'
|
|
||||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
|
||||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||||
import { Panel, Icon, Label, Button, eventToHTMLElement, showPopup } from '@hcengineering/ui'
|
import { createQuery } from '@hcengineering/presentation'
|
||||||
|
import { Button, eventToHTMLElement, Icon, Label, Panel, showPopup } from '@hcengineering/ui'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import gmail from '../plugin'
|
import gmail from '../plugin'
|
||||||
|
import Chats from './Chats.svelte'
|
||||||
import Connect from './Connect.svelte'
|
import Connect from './Connect.svelte'
|
||||||
|
import FullMessage from './FullMessage.svelte'
|
||||||
|
import NewMessage from './NewMessage.svelte'
|
||||||
|
|
||||||
export let _id: Ref<Doc>
|
export let _id: Ref<Doc>
|
||||||
export let _class: Ref<Class<Doc>>
|
export let _class: Ref<Class<Doc>>
|
||||||
|
|
||||||
// export let object: Contact
|
|
||||||
let object: any
|
let object: any
|
||||||
let newMessage: boolean = false
|
let newMessage: boolean = false
|
||||||
let currentMessage: SharedMessage | undefined = undefined
|
let currentMessage: SharedMessage | undefined = undefined
|
||||||
@ -38,17 +37,19 @@
|
|||||||
const notificationClient = NotificationClientImpl.getClient()
|
const notificationClient = NotificationClientImpl.getClient()
|
||||||
let enabled: boolean
|
let enabled: boolean
|
||||||
|
|
||||||
const client = getClient()
|
const channelQuery = createQuery()
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
client
|
$: channelQuery.query(
|
||||||
.findOne(contact.class.Channel, {
|
contact.class.Channel,
|
||||||
|
{
|
||||||
attachedTo: _id,
|
attachedTo: _id,
|
||||||
provider: contact.channelProvider.Email
|
provider: contact.channelProvider.Email
|
||||||
})
|
},
|
||||||
.then((res) => {
|
(res) => {
|
||||||
channel = res
|
channel = res[0]
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const query = createQuery()
|
const query = createQuery()
|
||||||
$: _id &&
|
$: _id &&
|
||||||
|
@ -41,15 +41,18 @@
|
|||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const notificationClient = NotificationClientImpl.getClient()
|
const notificationClient = NotificationClientImpl.getClient()
|
||||||
|
const channelQuery = createQuery()
|
||||||
|
|
||||||
client
|
$: channelQuery.query(
|
||||||
.findOne(contact.class.Channel, {
|
contact.class.Channel,
|
||||||
|
{
|
||||||
attachedTo: _id,
|
attachedTo: _id,
|
||||||
provider: contact.channelProvider.Telegram
|
provider: contact.channelProvider.Telegram
|
||||||
})
|
},
|
||||||
.then((res) => {
|
(res) => {
|
||||||
channel = res
|
channel = res[0]
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const query = createQuery()
|
const query = createQuery()
|
||||||
$: _id &&
|
$: _id &&
|
||||||
|
Loading…
Reference in New Issue
Block a user