2021-08-06 08:31:17 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// 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-03 08:34:42 +00:00
|
|
|
import { onMount } from 'svelte'
|
2021-08-06 08:31:17 +00:00
|
|
|
import type { IntlString } from '@anticrm/platform'
|
|
|
|
|
2021-09-03 08:34:42 +00:00
|
|
|
import { Label, showPopup } from '@anticrm/ui'
|
2021-08-06 08:31:17 +00:00
|
|
|
import Avatar from './Avatar.svelte'
|
2021-09-03 08:34:42 +00:00
|
|
|
import UsersPopup from './UsersPopup.svelte'
|
2021-08-06 08:31:17 +00:00
|
|
|
import Add from './icons/Add.svelte'
|
|
|
|
import Close from './icons/Close.svelte'
|
|
|
|
|
|
|
|
import type { Ref, Class } from '@anticrm/core'
|
|
|
|
import type { Person } from '@anticrm/contact'
|
|
|
|
|
|
|
|
export let _class: Ref<Class<Person>>
|
|
|
|
export let title: IntlString
|
|
|
|
export let caption: IntlString
|
|
|
|
export let value: Ref<Person>
|
|
|
|
export let show: boolean = false
|
|
|
|
|
|
|
|
let selected: Person | undefined
|
2021-09-03 08:34:42 +00:00
|
|
|
let btn: HTMLElement
|
2021-08-06 08:31:17 +00:00
|
|
|
|
2021-09-03 08:34:42 +00:00
|
|
|
onMount(() => {
|
|
|
|
if (btn && show) {
|
|
|
|
btn.click()
|
|
|
|
show = false
|
|
|
|
}
|
|
|
|
})
|
2021-08-06 08:31:17 +00:00
|
|
|
</script>
|
|
|
|
|
2021-08-17 14:46:06 +00:00
|
|
|
<div class="flex-row-center">
|
2021-09-03 08:34:42 +00:00
|
|
|
<button
|
|
|
|
class="focused-button btn"
|
|
|
|
class:selected={show}
|
|
|
|
bind:this={btn}
|
|
|
|
on:click|preventDefault={(ev) => {
|
|
|
|
showPopup(UsersPopup, { _class, title, caption }, ev.target, (result) => {
|
|
|
|
if (result) {
|
|
|
|
selected = result
|
|
|
|
value = result._id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{#if selected}
|
|
|
|
<Avatar size={'medium'} />
|
|
|
|
{:else}
|
|
|
|
<div class="icon">
|
|
|
|
{#if show}<Close size={'small'} />{:else}<Add size={'small'} />{/if}
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</button>
|
2021-08-06 08:31:17 +00:00
|
|
|
|
|
|
|
<div class="selectUser">
|
|
|
|
<div class="title"><Label label={title} /></div>
|
2021-08-17 14:46:06 +00:00
|
|
|
<div class="caption-color">
|
2021-08-06 08:31:17 +00:00
|
|
|
{#if selected}{selected.firstName + ' ' + selected.lastName}{:else}<Label label={'Not selected'} />{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2021-08-17 14:46:06 +00:00
|
|
|
.btn {
|
|
|
|
width: 2.25rem;
|
|
|
|
height: 2.25rem;
|
|
|
|
border-radius: 50%;
|
|
|
|
border: none;
|
|
|
|
}
|
2021-08-06 08:31:17 +00:00
|
|
|
|
2021-08-17 14:46:06 +00:00
|
|
|
.selectUser {
|
|
|
|
margin-left: .75rem;
|
|
|
|
.title {
|
|
|
|
font-size: .75rem;
|
|
|
|
font-weight: 500;
|
|
|
|
color: var(--theme-content-accent-color);
|
2021-08-06 08:31:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|