platform/plugins/setting-resources/src/components/EnumSetting.svelte

68 lines
2.1 KiB
Svelte
Raw Normal View History

<!--
// Copyright © 2022 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">
import core, { Enum } from '@anticrm/core'
import { createQuery } from '@anticrm/presentation'
import { CircleButton, Icon, IconAdd, Label, showPopup } from '@anticrm/ui'
import setting from '../plugin'
import EnumValues from './EnumValues.svelte'
const query = createQuery()
let enums: Enum[] = []
let selected: Enum | undefined
query.query(core.class.Enum, {}, (res) => {
enums = res
})
function create () {
showPopup(setting.component.EditEnum, 'top')
}
</script>
<div class="antiComponent">
<div class="ac-header short divide">
<div class="ac-header__icon"><Icon icon={setting.icon.Setting} size={'medium'} /></div>
<div class="ac-header__title"><Label label={setting.string.Enums} /></div>
</div>
<div class="ac-body columns hScroll">
<div class="ac-column">
<div class="flex-between trans-title mb-3">
<Label label={setting.string.Enums} />
<CircleButton icon={IconAdd} size="medium" on:click={create} />
</div>
<div class="overflow-y-auto">
{#each enums as value}
<div
class="ac-column__list-item"
class:selected={selected === value}
on:click={() => {
selected = value
}}
>
{value.name}
</div>
{/each}
</div>
</div>
<div class="ac-column max">
{#if selected !== undefined}
<EnumValues value={selected} />
{/if}
</div>
</div>
</div>