mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-24 03:59:50 +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 contact from '@anticrm/contact'
|
||||||
import { createEventDispatcher } from 'svelte'
|
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 size: 'small' | 'medium' | 'large' | 'x-large' = 'large'
|
||||||
export let reverse: boolean = false
|
export let reverse: boolean = false
|
||||||
export let integrations: Set<Ref<Doc>> = new Set<Ref<Doc>>()
|
export let integrations: Set<Ref<Doc>> = new Set<Ref<Doc>>()
|
||||||
@ -51,21 +51,35 @@
|
|||||||
return map
|
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 result = []
|
||||||
const map = await getProviders()
|
const map = await getProviders()
|
||||||
for (const item of value) {
|
if (Array.isArray(value)) {
|
||||||
const provider = map.get(item.provider)
|
for (const item of value) {
|
||||||
if (provider) {
|
const provider = getProvider(item, map)
|
||||||
result.push({
|
if (provider !== undefined) {
|
||||||
label: provider.label as IntlString,
|
result.push(provider)
|
||||||
icon: provider.icon as Asset,
|
}
|
||||||
value: item.value,
|
}
|
||||||
presenter: provider.presenter,
|
} else {
|
||||||
integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false
|
const provider = getProvider(value, map)
|
||||||
})
|
if (provider !== undefined) {
|
||||||
} else {
|
result.push(provider)
|
||||||
console.log('provider not found: ', item.provider)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayItems = result
|
displayItems = result
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import type { Channel } from '@anticrm/contact'
|
import type { Channel } from '@anticrm/contact'
|
||||||
import { Channels } from '@anticrm/presentation'
|
import { Channels } from '@anticrm/presentation'
|
||||||
|
|
||||||
export let value: Channel[] | null
|
export let value: Channel[] | Channel | null
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Channels {value} size={'small'} reverse />
|
<Channels {value} size={'small'} reverse />
|
||||||
|
Loading…
Reference in New Issue
Block a user