mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
Sortable list adjustments (#2427)
Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@xored.com>
This commit is contained in:
parent
231f04f6a5
commit
a843530bb2
@ -42,6 +42,9 @@
|
|||||||
export let presenterProps: Record<string, any> = {}
|
export let presenterProps: Record<string, any> = {}
|
||||||
export let direction: 'row' | 'column' = 'column'
|
export let direction: 'row' | 'column' = 'column'
|
||||||
export let flipDuration = 200
|
export let flipDuration = 200
|
||||||
|
export let isAddButtonHidden = false
|
||||||
|
export let isAddButtonDisabled = false
|
||||||
|
export let itemsCount = 0
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const hierarchy = client.getHierarchy()
|
const hierarchy = client.getHierarchy()
|
||||||
@ -60,10 +63,10 @@
|
|||||||
|
|
||||||
let isCreating = false
|
let isCreating = false
|
||||||
|
|
||||||
async function updateModel (modelClassRef: Ref<Class<Doc>>) {
|
async function updateModel (modelClassRef: Ref<Class<Doc>>, props: Record<string, any>) {
|
||||||
try {
|
try {
|
||||||
isModelLoading = true
|
isModelLoading = true
|
||||||
model = await getObjectPresenter(client, modelClassRef, { key: '', props: presenterProps })
|
model = await getObjectPresenter(client, modelClassRef, { key: '', props })
|
||||||
} finally {
|
} finally {
|
||||||
isModelLoading = false
|
isModelLoading = false
|
||||||
}
|
}
|
||||||
@ -131,16 +134,17 @@
|
|||||||
hoveringIndex = null
|
hoveringIndex = null
|
||||||
}
|
}
|
||||||
|
|
||||||
$: updateModel(_class)
|
$: updateModel(_class, presenterProps)
|
||||||
$: updateObjectFactory(_class)
|
$: updateObjectFactory(_class)
|
||||||
$: itemsQuery.query(_class, query, updateItems, { ...queryOptions, limit: Math.max(queryOptions?.limit ?? 0, 200) })
|
$: itemsQuery.query(_class, query, updateItems, { ...queryOptions, limit: Math.max(queryOptions?.limit ?? 0, 200) })
|
||||||
|
|
||||||
$: isLoading = isModelLoading || areItemsloading
|
$: isLoading = isModelLoading || areItemsloading
|
||||||
$: isSortable = hierarchy.getAllAttributes(_class).has('rank')
|
$: isSortable = hierarchy.getAllAttributes(_class).has('rank')
|
||||||
|
$: itemsCount = items?.length ?? 0
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex-col">
|
<div class="flex-col">
|
||||||
{#if label}
|
{#if label || !isAddButtonHidden}
|
||||||
<div class="flex mb-4">
|
<div class="flex mb-4">
|
||||||
{#if label}
|
{#if label}
|
||||||
<div class="title-wrapper">
|
<div class="title-wrapper">
|
||||||
@ -149,11 +153,11 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if objectFactory}
|
{#if !isAddButtonHidden}
|
||||||
<div class="ml-auto">
|
<div class="ml-auto">
|
||||||
<Button
|
<Button
|
||||||
showTooltip={{ label: presentation.string.Add }}
|
showTooltip={{ label: presentation.string.Add }}
|
||||||
disabled={isLoading}
|
disabled={isAddButtonDisabled || isLoading || !objectFactory}
|
||||||
width="min-content"
|
width="min-content"
|
||||||
icon={IconAdd}
|
icon={IconAdd}
|
||||||
size="small"
|
size="small"
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import Circles from '../icons/Circles.svelte'
|
import Circles from '../icons/Circles.svelte'
|
||||||
|
|
||||||
|
export let style = ''
|
||||||
export let isDraggable = false
|
export let isDraggable = false
|
||||||
export let isEditable = false
|
export let isEditable = false
|
||||||
export let isDeletable = false
|
export let isDeletable = false
|
||||||
@ -32,6 +33,7 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="root flex background-button-bg-color border-radius-1"
|
class="root flex background-button-bg-color border-radius-1"
|
||||||
|
{style}
|
||||||
on:dblclick|preventDefault={isEditable && !isEditing ? () => dispatch('edit') : undefined}
|
on:dblclick|preventDefault={isEditable && !isEditing ? () => dispatch('edit') : undefined}
|
||||||
>
|
>
|
||||||
<div class="flex-center ml-2">
|
<div class="flex-center ml-2">
|
||||||
|
Loading…
Reference in New Issue
Block a user