Provide attribute type data to editor (#1691)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-05-06 23:46:34 +06:00 committed by GitHub
parent 03cb718c72
commit 64a8a27265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 7 deletions

View File

@ -76,6 +76,7 @@
this={instance} this={instance}
label={attribute?.label} label={attribute?.label}
placeholder={attribute?.label} placeholder={attribute?.label}
type={attribute?.type}
{maxWidth} {maxWidth}
value={getAttribute(client, object, { key: attributeKey, attr: attribute })} value={getAttribute(client, object, { key: attributeKey, attr: attribute })}
space={object.space} space={object.space}
@ -97,6 +98,7 @@
this={instance} this={instance}
label={attribute?.label} label={attribute?.label}
placeholder={attribute?.label} placeholder={attribute?.label}
type={attribute?.type}
{maxWidth} {maxWidth}
value={getAttribute(client, object, { key: attributeKey, attr: attribute })} value={getAttribute(client, object, { key: attributeKey, attr: attribute })}
space={object.space} space={object.space}
@ -113,6 +115,7 @@
this={instance} this={instance}
label={attribute?.label} label={attribute?.label}
placeholder={attribute?.label} placeholder={attribute?.label}
type={attribute?.type}
{maxWidth} {maxWidth}
value={getAttribute(client, object, { key: attributeKey, attr: attribute })} value={getAttribute(client, object, { key: attributeKey, attr: attribute })}
space={object.space} space={object.space}
@ -130,6 +133,7 @@
placeholder={attribute?.label} placeholder={attribute?.label}
kind={'link'} kind={'link'}
size={'large'} size={'large'}
type={attribute?.type}
{maxWidth} {maxWidth}
value={getAttribute(client, object, { key: attributeKey, attr: attribute })} value={getAttribute(client, object, { key: attributeKey, attr: attribute })}
space={object.space} space={object.space}
@ -142,6 +146,7 @@
<div style="grid-column: 1/3;"> <div style="grid-column: 1/3;">
<svelte:component <svelte:component
this={instance} this={instance}
type={attribute?.type}
{maxWidth} {maxWidth}
value={getAttribute(client, object, { key: attributeKey, attr: attribute })} value={getAttribute(client, object, { key: attributeKey, attr: attribute })}
space={object.space} space={object.space}

View File

@ -59,6 +59,7 @@
this={instance} this={instance}
label={attribute?.label} label={attribute?.label}
placeholder={attribute?.label} placeholder={attribute?.label}
type={attribute?.type}
{maxWidth} {maxWidth}
value={getAttribute(client, object, { key: attributeKey, attr: attribute })} value={getAttribute(client, object, { key: attributeKey, attr: attribute })}
{onChange} {onChange}

View File

@ -20,6 +20,7 @@
export let value: any export let value: any
export let maxWidth: string | undefined = undefined export let maxWidth: string | undefined = undefined
export let withoutUndefined: boolean = false
export let onChange: (value: any) => void export let onChange: (value: any) => void
</script> </script>
@ -31,7 +32,7 @@
style={maxWidth ? `max-width: ${maxWidth};` : ''} style={maxWidth ? `max-width: ${maxWidth};` : ''}
on:click={() => { on:click={() => {
if (value === true) value = false if (value === true) value = false
else if (value === false) value = undefined else if (value === false && !withoutUndefined) value = undefined
else value = true else value = true
onChange(value) onChange(value)
}} }}

View File

@ -1,6 +1,5 @@
<!-- <!--
// Copyright © 2020, 2021 Anticrm Platform Contributors. // Copyright © 2022 Hardcore Engineering Inc.
// Copyright © 2021 Hardcore Engineering Inc.
// //
// Licensed under the Eclipse Public License, Version 2.0 (the "License"); // 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 // you may not use this file except in compliance with the License. You may
@ -14,18 +13,21 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
// import { TypeDate } from '@anticrm/core' import { TypeDate } from '@anticrm/core'
// import { IntlString } from '@anticrm/platform' // import { IntlString } from '@anticrm/platform'
import { DateRangePresenter } from '@anticrm/ui' import { DateRangePresenter } from '@anticrm/ui'
export let value: number | null | undefined export let value: number | null | undefined
export let type: TypeDate | undefined
// export let label: IntlString // export let label: IntlString
export let onChange: (value: any) => void export let onChange: (value: any) => void
$: withTime = type?.withTime ?? true
</script> </script>
<DateRangePresenter <DateRangePresenter
{value} {value}
withTime {withTime}
editable editable
on:change={(res) => { on:change={(res) => {
if (res.detail !== undefined) onChange(res.detail) if (res.detail !== undefined) onChange(res.detail)

View File

@ -32,9 +32,10 @@
<Label label={view.string.WithTime} /> <Label label={view.string.WithTime} />
<div class="ml-2"> <div class="ml-2">
<BooleanEditor <BooleanEditor
withoutUndefined
bind:value={withTime} bind:value={withTime}
onChange={(e) => { onChange={(e) => {
dispatch('change', TypeDate(e)) dispatch('change', { type: TypeDate(e) })
}} }}
/> />
</div> </div>