mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 19:44:59 +03:00
Channels presenter fix (#908)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
fa3b298af9
commit
d8219734aa
@ -26,7 +26,7 @@
|
||||
import contact from '@anticrm/contact'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
export let value: AttachedData<Channel>[] | null
|
||||
export let value: AttachedData<Channel>[] | AttachedData<Channel> | null
|
||||
export let size: 'small' | 'medium' | 'large' | 'x-large' = 'large'
|
||||
export let reverse: boolean = false
|
||||
export let integrations: Set<Ref<Doc>> = new Set<Ref<Doc>>()
|
||||
@ -51,21 +51,35 @@
|
||||
return map
|
||||
}
|
||||
|
||||
async function update (value: AttachedData<Channel>[]) {
|
||||
function getProvider (item: AttachedData<Channel>, map: Map<Ref<ChannelProvider>, ChannelProvider>): any | undefined {
|
||||
const provider = map.get(item.provider)
|
||||
if (provider) {
|
||||
return {
|
||||
label: provider.label as IntlString,
|
||||
icon: provider.icon as Asset,
|
||||
value: item.value,
|
||||
presenter: provider.presenter,
|
||||
integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false
|
||||
}
|
||||
} else {
|
||||
console.log('provider not found: ', item.provider)
|
||||
}
|
||||
}
|
||||
|
||||
async function update (value: AttachedData<Channel>[] | AttachedData<Channel>) {
|
||||
const result = []
|
||||
const map = await getProviders()
|
||||
for (const item of value) {
|
||||
const provider = map.get(item.provider)
|
||||
if (provider) {
|
||||
result.push({
|
||||
label: provider.label as IntlString,
|
||||
icon: provider.icon as Asset,
|
||||
value: item.value,
|
||||
presenter: provider.presenter,
|
||||
integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false
|
||||
})
|
||||
} else {
|
||||
console.log('provider not found: ', item.provider)
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) {
|
||||
const provider = getProvider(item, map)
|
||||
if (provider !== undefined) {
|
||||
result.push(provider)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const provider = getProvider(value, map)
|
||||
if (provider !== undefined) {
|
||||
result.push(provider)
|
||||
}
|
||||
}
|
||||
displayItems = result
|
||||
|
@ -17,7 +17,7 @@
|
||||
import type { Channel } from '@anticrm/contact'
|
||||
import { Channels } from '@anticrm/presentation'
|
||||
|
||||
export let value: Channel[] | null
|
||||
export let value: Channel[] | Channel | null
|
||||
</script>
|
||||
|
||||
<Channels {value} size={'small'} reverse />
|
||||
|
Loading…
Reference in New Issue
Block a user