diff --git a/plugins/view-resources/src/components/list/SortableList.svelte b/plugins/view-resources/src/components/list/SortableList.svelte index 913309e1ce..dc56cce01c 100644 --- a/plugins/view-resources/src/components/list/SortableList.svelte +++ b/plugins/view-resources/src/components/list/SortableList.svelte @@ -21,7 +21,6 @@ import view, { AttributeModel, ObjectFactory } from '@hcengineering/view' import { flip } from 'svelte/animate' import { getObjectPresenter } from '../../utils' - import SortableListItem from './SortableListItem.svelte' /* How to use: @@ -32,7 +31,6 @@ To create a new items, we should add "ObjectFactory" mixin also. We can create a custom list items or editor based on "SortableListItem" - and "SortableListItemPresenter" Important: the "ObjectFactory" component must emit the "close" event */ @@ -42,6 +40,7 @@ export let query: DocumentQuery = {} export let queryOptions: FindOptions | undefined = undefined export let presenterProps: Record = {} + export let direction: 'row' | 'column' = 'column' export let flipDuration = 200 const client = getClient() @@ -169,13 +168,16 @@ {#if isLoading} {:else if model && items} -
+ {@const isVertical = direction === 'column'} +
{#each items as item, index (item._id)} {@const isDraggable = isSortable && items.length > 1 && !areItemsSorting}
draggingIndex} + class="item" + class:column={isVertical} + class:row={!isVertical} + class:is-dragged-over-before={draggingIndex !== null && index === hoveringIndex && index < draggingIndex} + class:is-dragged-over-after={draggingIndex !== null && index === hoveringIndex && index > draggingIndex} draggable={isDraggable} animate:flip={{ duration: flipDuration }} on:dragstart={(ev) => handleDragStart(ev, index)} @@ -183,9 +185,7 @@ on:drop={() => handleDrop(index)} on:dragend={resetDrag} > - - - +
{/each} @@ -198,22 +198,27 @@
diff --git a/plugins/view-resources/src/components/list/SortableListItem.svelte b/plugins/view-resources/src/components/list/SortableListItem.svelte index 5cc4c4d1c1..b3adcee6c3 100644 --- a/plugins/view-resources/src/components/list/SortableListItem.svelte +++ b/plugins/view-resources/src/components/list/SortableListItem.svelte @@ -13,22 +13,81 @@ // limitations under the License. --> -
+
dispatch('edit') : undefined} +>
- +
+
+ +
+ + {#if areButtonsVisible} +
+ {#if isEditing} + + {/if} + {#if isDeletable} + + {/if} + {/if} +
+ {/if} +
diff --git a/plugins/view-resources/src/index.ts b/plugins/view-resources/src/index.ts index b594a34236..b26d140af8 100644 --- a/plugins/view-resources/src/index.ts +++ b/plugins/view-resources/src/index.ts @@ -56,7 +56,6 @@ import ValueSelector from './components/ValueSelector.svelte' import HTMLEditor from './components/HTMLEditor.svelte' import SortableList from './components/list/SortableList.svelte' import SortableListItem from './components/list/SortableListItem.svelte' -import SortableListItemPresenter from './components/list/SortableListItemPresenter.svelte' import { afterResult, beforeResult, @@ -117,8 +116,7 @@ export { NumberPresenter, TimestampPresenter, SortableList, - SortableListItem, - SortableListItemPresenter + SortableListItem } export default async (): Promise => ({