2021-08-31 10:42:40 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
// Copyright © 2021 Hardcore Engineering Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-09-01 15:11:01 +00:00
|
|
|
import type { Ref } from '@anticrm/core'
|
|
|
|
import type { IntlString, Asset } from '@anticrm/platform'
|
|
|
|
import type { Channel, ChannelProvider } from '@anticrm/contact'
|
|
|
|
import { getClient } from '@anticrm/presentation'
|
2021-08-31 10:42:40 +00:00
|
|
|
|
2021-09-01 15:11:01 +00:00
|
|
|
import { Icon } from '@anticrm/ui'
|
2021-09-02 17:05:48 +00:00
|
|
|
import IconCopy from './icons/Copy.svelte'
|
2021-09-01 15:11:01 +00:00
|
|
|
|
|
|
|
import contact from '@anticrm/contact'
|
2021-08-31 10:42:40 +00:00
|
|
|
|
2021-09-02 09:26:45 +00:00
|
|
|
export let value: Channel[] | undefined
|
2021-08-31 10:42:40 +00:00
|
|
|
|
2021-09-01 15:11:01 +00:00
|
|
|
interface Item {
|
|
|
|
label: IntlString,
|
|
|
|
icon: Asset,
|
|
|
|
value: string
|
|
|
|
}
|
|
|
|
|
|
|
|
const client = getClient()
|
|
|
|
|
|
|
|
async function getProviders(): Promise<Map<Ref<ChannelProvider>, ChannelProvider>> {
|
|
|
|
const providers = await client.findAll(contact.class.ChannelProvider, {})
|
|
|
|
const map = new Map<Ref<ChannelProvider>, ChannelProvider>()
|
|
|
|
for (const provider of providers) { map.set(provider._id, provider) }
|
|
|
|
return map
|
|
|
|
}
|
|
|
|
|
|
|
|
async function update(value: 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,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
console.log('provider not found: ', item.provider)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
displayItems = result
|
|
|
|
}
|
|
|
|
|
2021-09-02 09:26:45 +00:00
|
|
|
$: if (value !== undefined) update(value)
|
2021-09-01 15:11:01 +00:00
|
|
|
|
|
|
|
let displayItems: Item[] = []
|
|
|
|
|
2021-08-31 10:42:40 +00:00
|
|
|
</script>
|
|
|
|
|
2021-09-02 17:05:48 +00:00
|
|
|
<div class="container" on:click|stopPropagation={() => {}}>
|
2021-09-01 19:08:07 +00:00
|
|
|
{#each displayItems as item}
|
2021-09-02 17:05:48 +00:00
|
|
|
<div class="circle list">
|
2021-09-01 19:52:15 +00:00
|
|
|
<div class="icon"><Icon icon={item.icon} size={'small'}/></div>
|
|
|
|
</div>
|
2021-09-02 17:05:48 +00:00
|
|
|
<div class="window">
|
|
|
|
<div class="circle circle-icon">
|
|
|
|
<div class="icon"><Icon icon={item.icon} size={'small'}/></div>
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow flex-col caption-color">
|
|
|
|
<div class="overflow-label label">{item.label}</div>
|
|
|
|
<div class="overflow-label">{item.value}</div>
|
|
|
|
</div>
|
|
|
|
<div class="button" on:click|preventDefault={() => { alert('Copied: ' + item.value) }}>
|
2021-09-02 17:42:04 +00:00
|
|
|
<IconCopy size={'small'}/>
|
2021-09-02 17:05:48 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-01 19:08:07 +00:00
|
|
|
{/each}
|
|
|
|
</div>
|
2021-08-31 10:42:40 +00:00
|
|
|
|
2021-09-01 19:08:07 +00:00
|
|
|
<style lang="scss">
|
|
|
|
.container {
|
2021-09-02 17:05:48 +00:00
|
|
|
position: relative;
|
2021-09-01 19:08:07 +00:00
|
|
|
display: flex;
|
2021-09-01 19:52:15 +00:00
|
|
|
flex-direction: row-reverse;
|
2021-09-01 19:08:07 +00:00
|
|
|
align-items: center;
|
2021-09-01 19:52:15 +00:00
|
|
|
|
|
|
|
.circle {
|
2021-09-02 17:05:48 +00:00
|
|
|
position: relative;
|
2021-09-01 19:52:15 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
border: 1px solid var(--theme-bg-focused-color);
|
|
|
|
border-radius: 50%;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
.icon {
|
2021-09-02 17:05:48 +00:00
|
|
|
transform-origin: center center;
|
|
|
|
transform: scale(.75);
|
2021-09-01 19:52:15 +00:00
|
|
|
opacity: .4;
|
|
|
|
}
|
2021-09-02 17:05:48 +00:00
|
|
|
|
|
|
|
&-icon {
|
|
|
|
margin-right: .75rem;
|
|
|
|
width: 2.25rem;
|
|
|
|
height: 2.25rem;
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
transform: none;
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.list {
|
|
|
|
margin-right: .25rem;
|
|
|
|
width: 1.5rem;
|
|
|
|
height: 1.5rem;
|
|
|
|
|
2021-09-01 19:52:15 +00:00
|
|
|
&:hover {
|
|
|
|
border-color: var(--theme-bg-focused-border);
|
2021-09-02 17:05:48 +00:00
|
|
|
z-index: 5;
|
2021-09-01 19:52:15 +00:00
|
|
|
.icon { opacity: 1; }
|
2021-09-02 17:05:48 +00:00
|
|
|
& + .window {
|
|
|
|
z-index: 4;
|
|
|
|
visibility: visible;
|
|
|
|
}
|
|
|
|
&::after { content: ''; }
|
|
|
|
}
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: -1rem;
|
2021-09-01 19:52:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-02 17:05:48 +00:00
|
|
|
|
|
|
|
.window {
|
|
|
|
position: absolute;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
padding: 1rem;
|
|
|
|
top: 2.25rem;
|
|
|
|
right: 0;
|
|
|
|
background-color: var(--theme-button-bg-focused);
|
|
|
|
border: 1px solid var(--theme-button-border-enabled);
|
|
|
|
border-radius: .75rem;
|
|
|
|
box-shadow: 0 .75rem 1.25rem rgba(0, 0, 0, .2);
|
|
|
|
visibility: hidden;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
z-index: 4;
|
|
|
|
visibility: visible;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.label {
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: .75rem;
|
|
|
|
}
|
|
|
|
.button {
|
|
|
|
margin-left: 1.5rem;
|
|
|
|
opacity: .4;
|
|
|
|
cursor: pointer;
|
|
|
|
&:hover { opacity: 1; }
|
2021-09-01 19:08:07 +00:00
|
|
|
}
|
|
|
|
</style>
|