2022-05-29 04:56:06 +00:00
|
|
|
<!--
|
|
|
|
// 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">
|
2022-09-21 08:08:25 +00:00
|
|
|
import core, { Enum } from '@hcengineering/core'
|
|
|
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
|
|
|
import {
|
|
|
|
CircleButton,
|
|
|
|
EditBox,
|
|
|
|
Icon,
|
|
|
|
eventToHTMLElement,
|
|
|
|
IconAdd,
|
|
|
|
IconMoreH,
|
|
|
|
Label,
|
|
|
|
showPopup
|
|
|
|
} from '@hcengineering/ui'
|
|
|
|
import { ContextMenu } from '@hcengineering/view-resources'
|
2022-05-29 04:56:06 +00:00
|
|
|
import setting from '../plugin'
|
|
|
|
import EnumValues from './EnumValues.svelte'
|
|
|
|
|
|
|
|
const query = createQuery()
|
|
|
|
|
|
|
|
let enums: Enum[] = []
|
|
|
|
let selected: Enum | undefined
|
2022-05-30 07:41:19 +00:00
|
|
|
const client = getClient()
|
2022-05-29 04:56:06 +00:00
|
|
|
|
|
|
|
query.query(core.class.Enum, {}, (res) => {
|
|
|
|
enums = res
|
2022-05-30 07:41:19 +00:00
|
|
|
if (selected !== undefined) {
|
|
|
|
selected = enums.find((p) => p._id === selected?._id)
|
|
|
|
}
|
2022-05-29 04:56:06 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
function create () {
|
2023-03-24 04:54:56 +00:00
|
|
|
showPopup(setting.component.EditEnum, {}, 'top')
|
2022-05-29 04:56:06 +00:00
|
|
|
}
|
2022-05-30 07:41:19 +00:00
|
|
|
|
|
|
|
async function update (value: Enum): Promise<void> {
|
|
|
|
await client.update(value, {
|
|
|
|
name: value.name
|
|
|
|
})
|
|
|
|
}
|
2022-05-29 04:56:06 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="antiComponent">
|
|
|
|
<div class="ac-header short divide">
|
2022-07-02 04:03:25 +00:00
|
|
|
<div class="ac-header__icon"><Icon icon={setting.icon.Enums} size={'medium'} /></div>
|
2022-05-29 04:56:06 +00:00
|
|
|
<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}
|
2022-12-05 16:27:49 +00:00
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
2022-05-29 04:56:06 +00:00
|
|
|
<div
|
|
|
|
class="ac-column__list-item"
|
|
|
|
class:selected={selected === value}
|
|
|
|
on:click={() => {
|
|
|
|
selected = value
|
|
|
|
}}
|
|
|
|
>
|
2022-10-04 15:49:11 +00:00
|
|
|
<EditBox bind:value={value.name} on:change={() => update(value)} />
|
2022-05-30 07:41:19 +00:00
|
|
|
<div
|
|
|
|
class="hover-trans"
|
|
|
|
on:click|stopPropagation={(ev) => {
|
|
|
|
showPopup(ContextMenu, { object: value }, eventToHTMLElement(ev), () => {})
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<IconMoreH size={'medium'} />
|
|
|
|
</div>
|
2022-05-29 04:56:06 +00:00
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-07-01 15:22:58 +00:00
|
|
|
<div class="ac-column max">
|
2022-05-29 04:56:06 +00:00
|
|
|
{#if selected !== undefined}
|
|
|
|
<EnumValues value={selected} />
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|