2022-04-02 04:06:48 +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">
|
|
|
|
import type { Asset, IntlString } from '@anticrm/platform'
|
|
|
|
import { translate } from '@anticrm/platform'
|
2022-04-08 06:27:02 +00:00
|
|
|
import { createEventDispatcher } from 'svelte'
|
2022-04-02 04:06:48 +00:00
|
|
|
import { Icon, Label } from '@anticrm/ui'
|
|
|
|
|
2022-04-05 08:02:08 +00:00
|
|
|
// export let _class: Ref<Class<Space>>
|
|
|
|
// export let spaceQuery: DocumentQuery<Space> | undefined
|
2022-04-02 04:06:48 +00:00
|
|
|
export let placeholder: IntlString | undefined = undefined
|
|
|
|
export let placeholderParam: any | undefined = undefined
|
|
|
|
export let searchable: boolean = false
|
2022-04-08 06:27:02 +00:00
|
|
|
export let value: Array<{id: number | string, icon: Asset, label: IntlString}>
|
2022-04-02 04:06:48 +00:00
|
|
|
|
|
|
|
let search: string = ''
|
|
|
|
|
|
|
|
let phTraslate: string = ''
|
|
|
|
$: if (placeholder) translate(placeholder, placeholderParam ?? {}).then(res => { phTraslate = res })
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
// const query = createQuery()
|
|
|
|
// $: query.query(_class, { ...(spaceQuery ?? {}), name: { $like: '%' + search + '%' } }, result => { objects = result })
|
|
|
|
// afterUpdate(() => { dispatch('update', Date.now()) })
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="selectPopup">
|
|
|
|
{#if searchable}
|
|
|
|
<div class="header">
|
2022-04-08 06:27:02 +00:00
|
|
|
<input type='text' bind:value={search} placeholder={phTraslate} on:input={(ev) => { }} on:change/>
|
2022-04-02 04:06:48 +00:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
<div class="scroll">
|
|
|
|
<div class="box">
|
|
|
|
{#each value.filter(el => el.label.toLowerCase().includes(search.toLowerCase())) as space}
|
2022-04-08 06:27:02 +00:00
|
|
|
<button class="menu-item" on:click={() => { dispatch('close', space.id) }}>
|
2022-04-02 04:06:48 +00:00
|
|
|
<div class="icon"><Icon icon={space.icon} size={'small'} /></div>
|
|
|
|
<span class="label"><Label label={space.label} /></span>
|
|
|
|
</button>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|