2021-09-01 07:46:05 +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">
|
2022-09-21 08:08:25 +00:00
|
|
|
import { AttachedData, Ref } from '@hcengineering/core'
|
2021-09-01 12:38:22 +00:00
|
|
|
import { createEventDispatcher } from 'svelte'
|
2022-09-21 08:08:25 +00:00
|
|
|
import { EditBox, Button, ScrollBox, Label } from '@hcengineering/ui'
|
|
|
|
import { getClient } from '@hcengineering/presentation'
|
2021-09-01 09:55:56 +00:00
|
|
|
|
2022-09-21 08:08:25 +00:00
|
|
|
import { ChannelProvider, Channel } from '@hcengineering/contact'
|
2021-12-06 10:07:08 +00:00
|
|
|
import contact from '../plugin'
|
2021-09-01 15:11:01 +00:00
|
|
|
|
|
|
|
export let values: Channel[]
|
2022-01-31 09:06:30 +00:00
|
|
|
const newValues: AttachedData<Channel>[] = []
|
2021-09-01 09:55:56 +00:00
|
|
|
|
2021-09-01 12:38:22 +00:00
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
|
2021-09-01 09:55:56 +00:00
|
|
|
let providers: ChannelProvider[] = []
|
2021-09-01 15:11:01 +00:00
|
|
|
|
2021-12-07 09:05:52 +00:00
|
|
|
function findValue (provider: Ref<ChannelProvider>): number {
|
|
|
|
for (let i = 0; i < values.length; i++) {
|
2021-09-01 15:11:01 +00:00
|
|
|
if (values[i].provider === provider) return i
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
2021-09-01 09:55:56 +00:00
|
|
|
|
|
|
|
const client = getClient()
|
2021-12-07 09:05:52 +00:00
|
|
|
client.findAll(contact.class.ChannelProvider, {}).then((result) => {
|
2021-09-01 15:11:01 +00:00
|
|
|
providers = result
|
|
|
|
for (const provider of providers) {
|
|
|
|
const i = findValue(provider._id)
|
|
|
|
if (i !== -1) {
|
2022-02-25 09:05:25 +00:00
|
|
|
newValues.push({ ...values[i] })
|
2021-09-01 15:11:01 +00:00
|
|
|
} else {
|
|
|
|
newValues.push({ provider: provider._id, value: '' })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-02-07 09:03:14 +00:00
|
|
|
function filterUndefined (channels: AttachedData<Channel>[]): AttachedData<Channel>[] {
|
2021-12-07 09:05:52 +00:00
|
|
|
return channels.filter((channel) => channel.value !== undefined && channel.value.length > 0)
|
2021-09-02 09:26:45 +00:00
|
|
|
}
|
2021-09-01 07:46:05 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="popup">
|
2021-09-02 17:41:42 +00:00
|
|
|
<ScrollBox vertical stretch>
|
|
|
|
<div class="popup-block">
|
2022-02-23 16:10:11 +00:00
|
|
|
<span><Label label={contact.string.SocialLinks} /></span>
|
2021-09-02 17:41:42 +00:00
|
|
|
{#each providers as provider, i}
|
2022-10-04 15:49:11 +00:00
|
|
|
<EditBox label={provider.label} placeholder={provider.placeholder} bind:value={newValues[i].value} />
|
2021-09-02 17:41:42 +00:00
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</ScrollBox>
|
|
|
|
<div class="buttons">
|
2021-12-07 09:05:52 +00:00
|
|
|
<div class="btn">
|
|
|
|
<Button
|
|
|
|
label={contact.string.Apply}
|
|
|
|
width={'100%'}
|
|
|
|
on:click={() => {
|
|
|
|
dispatch('close', filterUndefined(newValues))
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-09-01 07:46:05 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.popup {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2021-09-02 17:41:42 +00:00
|
|
|
padding: 1.5rem 1.25rem 1.25rem;
|
2021-09-01 18:02:12 +00:00
|
|
|
width: 17rem;
|
|
|
|
max-width: 17rem;
|
2021-09-02 17:41:42 +00:00
|
|
|
height: 22rem;
|
2023-03-10 00:08:04 +00:00
|
|
|
color: var(--caption-color);
|
|
|
|
background-color: var(--popup-bg-color);
|
2021-12-07 09:05:52 +00:00
|
|
|
border-radius: 0.75rem;
|
2023-03-10 00:08:04 +00:00
|
|
|
box-shadow: var(--popup-shadow);
|
2021-09-01 07:46:05 +00:00
|
|
|
|
|
|
|
&-block {
|
|
|
|
display: grid;
|
|
|
|
grid-auto-flow: row;
|
2021-12-07 09:05:52 +00:00
|
|
|
row-gap: 0.75rem;
|
2021-09-01 07:46:05 +00:00
|
|
|
|
|
|
|
span {
|
|
|
|
font-weight: 600;
|
|
|
|
font-size: 0.625rem;
|
2023-03-10 00:08:04 +00:00
|
|
|
color: var(--caption-color);
|
2021-09-01 07:46:05 +00:00
|
|
|
text-transform: uppercase;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-02 17:41:42 +00:00
|
|
|
.buttons {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 1rem;
|
2021-12-07 09:05:52 +00:00
|
|
|
.btn {
|
|
|
|
flex-grow: 1;
|
|
|
|
}
|
2021-09-01 07:46:05 +00:00
|
|
|
}
|
|
|
|
</style>
|