Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-05-30 13:41:19 +06:00 committed by GitHub
parent a2d8bfc5e3
commit e97a6cb6f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 39 deletions

View File

@ -15,7 +15,7 @@
<script lang="ts">
import core, { Enum } from '@anticrm/core'
import presentation, { Card, getClient } from '@anticrm/presentation'
import { ActionIcon, EditBox, IconAdd, IconDelete } from '@anticrm/ui'
import { ActionIcon, EditBox, IconCheck, IconDelete } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte'
import setting from '../plugin'
@ -65,12 +65,12 @@
>
<div class="mb-2"><EditBox bind:value={name} placeholder={core.string.Name} maxWidth="13rem" /></div>
<div class="flex-between mb-4">
<EditBox placeholder={setting.string.NewValue} bind:value={newValue} maxWidth="13rem" /><ActionIcon
icon={IconAdd}
label={presentation.string.Add}
action={add}
size={'small'}
/>
<EditBox
placeholder={setting.string.NewValue}
kind="large-style"
bind:value={newValue}
maxWidth="13rem"
/><ActionIcon icon={IconCheck} label={presentation.string.Add} action={add} size={'small'} />
</div>
<div class="flex-row">
{#each values as value}

View File

@ -14,8 +14,9 @@
-->
<script lang="ts">
import core, { Enum } from '@anticrm/core'
import { createQuery } from '@anticrm/presentation'
import { CircleButton, Icon, IconAdd, Label, showPopup } from '@anticrm/ui'
import { createQuery, getClient } from '@anticrm/presentation'
import { CircleButton, EditBox, Icon, eventToHTMLElement, IconAdd, IconMoreH, Label, showPopup } from '@anticrm/ui'
import { ContextMenu } from '@anticrm/view-resources'
import setting from '../plugin'
import EnumValues from './EnumValues.svelte'
@ -23,14 +24,25 @@
let enums: Enum[] = []
let selected: Enum | undefined
const client = getClient()
query.query(core.class.Enum, {}, (res) => {
console.log(res)
enums = res
if (selected !== undefined) {
selected = enums.find((p) => p._id === selected?._id)
}
})
function create () {
showPopup(setting.component.EditEnum, 'top')
}
async function update (value: Enum): Promise<void> {
await client.update(value, {
name: value.name
})
}
</script>
<div class="antiComponent">
@ -53,12 +65,20 @@
selected = value
}}
>
{value.name}
<EditBox maxWidth="15rem" bind:value={value.name} on:change={() => update(value)} />
<div
class="hover-trans"
on:click|stopPropagation={(ev) => {
showPopup(ContextMenu, { object: value }, eventToHTMLElement(ev), () => {})
}}
>
<IconMoreH size={'medium'} />
</div>
</div>
{/each}
</div>
</div>
<div class="ac-column max">
<div class="ac-column">
{#if selected !== undefined}
<EnumValues value={selected} />
{/if}

View File

@ -14,48 +14,51 @@
-->
<script lang="ts">
import { Enum } from '@anticrm/core'
import { ActionIcon, Button, EditBox, IconAdd, IconDelete } from '@anticrm/ui'
import presentation, { getClient } from '@anticrm/presentation'
import { ActionIcon, EditBox, IconCheck, IconDelete } from '@anticrm/ui'
import { getClient } from '@anticrm/presentation'
import setting from '../plugin'
export let value: Enum
const client = getClient()
$: values = value.enumValues
let newValue = ''
function add () {
async function add () {
if (newValue.trim().length === 0) return
values.push(newValue)
values = values
await client.update(value, {
$push: { enumValues: newValue }
})
newValue = ''
}
function remove (value: string) {
values = values.filter((p) => p !== value)
}
async function save () {
async function remove (target: string) {
await client.update(value, {
enumValues: values
$pull: { enumValues: target }
})
}
</script>
<div class="flex-grow">
<div class="flex-between mb-4">
<EditBox placeholder={setting.string.NewValue} bind:value={newValue} maxWidth="20rem" /><ActionIcon
label={presentation.string.Add}
icon={IconAdd}
action={add}
size={'small'}
<EditBox
placeholder={setting.string.NewValue}
on:keydown={(evt) => {
if (evt.key === 'Enter') {
add()
}
}}
kind="large-style"
bind:value={newValue}
maxWidth="18rem"
/>
<ActionIcon icon={IconCheck} label={setting.string.Add} action={add} size={'small'} />
</div>
<div class="overflow-y-auto flex-row">
{#each values as value}
{#each value.enumValues as value}
<div class="flex-between mb-2">
{value}<ActionIcon
{value}
<ActionIcon
icon={IconDelete}
label={setting.string.Delete}
action={() => {
@ -67,12 +70,3 @@
{/each}
</div>
</div>
<div class="flex-row-reverse">
<Button
label={presentation.string.Save}
kind={'primary'}
on:click={() => {
save()
}}
/>
</div>