mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-24 12:06:57 +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,23 +51,37 @@
|
|||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update (value: AttachedData<Channel>[]) {
|
function getProvider (item: AttachedData<Channel>, map: Map<Ref<ChannelProvider>, ChannelProvider>): any | undefined {
|
||||||
const result = []
|
|
||||||
const map = await getProviders()
|
|
||||||
for (const item of value) {
|
|
||||||
const provider = map.get(item.provider)
|
const provider = map.get(item.provider)
|
||||||
if (provider) {
|
if (provider) {
|
||||||
result.push({
|
return {
|
||||||
label: provider.label as IntlString,
|
label: provider.label as IntlString,
|
||||||
icon: provider.icon as Asset,
|
icon: provider.icon as Asset,
|
||||||
value: item.value,
|
value: item.value,
|
||||||
presenter: provider.presenter,
|
presenter: provider.presenter,
|
||||||
integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false
|
integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false
|
||||||
})
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('provider not found: ', item.provider)
|
console.log('provider not found: ', item.provider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function update (value: AttachedData<Channel>[] | AttachedData<Channel>) {
|
||||||
|
const result = []
|
||||||
|
const map = await getProviders()
|
||||||
|
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
|
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