mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-19 23:00:13 +00:00
Fix UI for adding attributes (#1660)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
d250853ffc
commit
c4b73a8fd0
@ -36,6 +36,6 @@
|
|||||||
"Type": "Type",
|
"Type": "Type",
|
||||||
"WithTime": "WithTime",
|
"WithTime": "WithTime",
|
||||||
"CreatingAttribute": "Creating an attribute",
|
"CreatingAttribute": "Creating an attribute",
|
||||||
"CreatingAttributeConfirm": "Do you want to create an attribute? It will not be possible to change or delete it."
|
"CreatingAttributeConfirm": "Warning: It will not be possible for now to change or delete created attribute."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
"Type": "Тип",
|
"Type": "Тип",
|
||||||
"WithTime": "Со временем",
|
"WithTime": "Со временем",
|
||||||
"CreatingAttribute": "Создание атрибута",
|
"CreatingAttribute": "Создание атрибута",
|
||||||
"CreatingAttributeConfirm": "Вы хотите создать атрибут? Изменить или удалить его будет невозможно",
|
"CreatingAttributeConfirm": "Предупреждение: Изменить или удалить аттрибут в текущей версии невозможно.",
|
||||||
"MoveLeft": "Переместить влево",
|
"MoveLeft": "Переместить влево",
|
||||||
"MoveRight": "Переместить вправо",
|
"MoveRight": "Переместить вправо",
|
||||||
"MoveUp": "Переместить вверх",
|
"MoveUp": "Переместить вверх",
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
icon={IconAdd}
|
icon={IconAdd}
|
||||||
size="small"
|
size="small"
|
||||||
action={() => {
|
action={() => {
|
||||||
showPopup(view.component.CreateAttribute, { _class: objectClass._id }, undefined, () => {
|
showPopup(view.component.CreateAttribute, { _class: objectClass._id }, 'top', () => {
|
||||||
updateKeys(ignoreKeys)
|
updateKeys(ignoreKeys)
|
||||||
dispatch('update')
|
dispatch('update')
|
||||||
})
|
})
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import core, { AnyAttribute, Class, Data, generateId, IndexKind, PropertyType, Ref, Space, Type } from '@anticrm/core'
|
import core, { AnyAttribute, Class, Data, generateId, IndexKind, PropertyType, Ref, Space, Type } from '@anticrm/core'
|
||||||
import presentation, { getClient, MessageBox } from '@anticrm/presentation'
|
import { getEmbeddedLabel } from '@anticrm/platform'
|
||||||
import { AnyComponent, EditBox, DropdownLabelsIntl, Label, Component, Button, showPopup } from '@anticrm/ui'
|
import { Card, getClient } from '@anticrm/presentation'
|
||||||
|
import { AnyComponent, Component, DropdownLabelsIntl, EditBox, Label } from '@anticrm/ui'
|
||||||
import { DropdownIntlItem } from '@anticrm/ui/src/types'
|
import { DropdownIntlItem } from '@anticrm/ui/src/types'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import view from '../plugin'
|
import view from '../plugin'
|
||||||
import { getEmbeddedLabel } from '@anticrm/platform'
|
|
||||||
|
|
||||||
export let _class: Ref<Class<Space>>
|
export let _class: Ref<Class<Space>>
|
||||||
let name: string
|
let name: string
|
||||||
@ -32,15 +32,7 @@
|
|||||||
|
|
||||||
async function save (): Promise<void> {
|
async function save (): Promise<void> {
|
||||||
if (type === undefined) return
|
if (type === undefined) return
|
||||||
showPopup(
|
|
||||||
MessageBox,
|
|
||||||
{
|
|
||||||
label: view.string.CreatingAttribute,
|
|
||||||
message: view.string.CreatingAttributeConfirm
|
|
||||||
},
|
|
||||||
undefined,
|
|
||||||
async (result) => {
|
|
||||||
if (result && type !== undefined) {
|
|
||||||
const data: Data<AnyAttribute> = {
|
const data: Data<AnyAttribute> = {
|
||||||
attributeOf: _class,
|
attributeOf: _class,
|
||||||
name: name + generateId(),
|
name: name + generateId(),
|
||||||
@ -54,9 +46,6 @@
|
|||||||
await client.createDoc(core.class.Attribute, core.space.Model, data)
|
await client.createDoc(core.class.Attribute, core.space.Model, data)
|
||||||
dispatch('close')
|
dispatch('close')
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTypes (): DropdownIntlItem[] {
|
function getTypes (): DropdownIntlItem[] {
|
||||||
const descendants = hierarchy.getDescendants(core.class.Type)
|
const descendants = hierarchy.getDescendants(core.class.Type)
|
||||||
@ -87,10 +76,19 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="antiPopup w-60 p-4 flex-col">
|
<Card
|
||||||
|
label={view.string.CreatingAttribute}
|
||||||
|
okAction={save}
|
||||||
|
canSave={!(type === undefined || name === undefined || name.trim().length === 0)}
|
||||||
|
on:close={() => {
|
||||||
|
dispatch('close')
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div class="mb-2"><EditBox bind:value={name} placeholder={core.string.Name} maxWidth="13rem" /></div>
|
<div class="mb-2"><EditBox bind:value={name} placeholder={core.string.Name} maxWidth="13rem" /></div>
|
||||||
<div class="flex-between mb-2">
|
<div class="flex-col mb-2">
|
||||||
|
<div class="flex-row-center flex-grow">
|
||||||
<Label label={view.string.Type} />
|
<Label label={view.string.Type} />
|
||||||
|
<div class="ml-4">
|
||||||
<DropdownLabelsIntl
|
<DropdownLabelsIntl
|
||||||
label={view.string.Type}
|
label={view.string.Type}
|
||||||
{items}
|
{items}
|
||||||
@ -99,7 +97,9 @@
|
|||||||
on:selected={(e) => selectType(e.detail)}
|
on:selected={(e) => selectType(e.detail)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{#if is}
|
{#if is}
|
||||||
|
<div class="flex mt-4">
|
||||||
<Component
|
<Component
|
||||||
{is}
|
{is}
|
||||||
on:change={(e) => {
|
on:change={(e) => {
|
||||||
@ -107,18 +107,11 @@
|
|||||||
index = e.detail?.index
|
index = e.detail?.index
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="mt-2">
|
<Label label={view.string.CreatingAttributeConfirm} />
|
||||||
<Button
|
|
||||||
width="100%"
|
|
||||||
disabled={type === undefined || name === undefined || name.trim().length === 0}
|
|
||||||
label={presentation.string.Create}
|
|
||||||
on:click={() => {
|
|
||||||
save()
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
</style>
|
</style>
|
||||||
|
@ -28,8 +28,9 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex-between">
|
<div class="flex-row-center">
|
||||||
<Label label={view.string.WithTime} />
|
<Label label={view.string.WithTime} />
|
||||||
|
<div class="ml-2">
|
||||||
<BooleanEditor
|
<BooleanEditor
|
||||||
bind:value={withTime}
|
bind:value={withTime}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@ -37,3 +38,4 @@
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user