Tidy reordering stuff
This commit is contained in:
parent
b93f575bca
commit
b5a72438e1
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
|
|
||||||
const { columns, rand, scroll, visibleColumns, stickyColumn } =
|
const { columns, rand, scroll, visibleColumns, stickyColumn, isReordering } =
|
||||||
getContext("sheet")
|
getContext("sheet")
|
||||||
const MinColumnWidth = 100
|
const MinColumnWidth = 100
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if !$isReordering}
|
||||||
{#if $stickyColumn}
|
{#if $stickyColumn}
|
||||||
<div
|
<div
|
||||||
class="resize-slider sticky"
|
class="resize-slider sticky"
|
||||||
|
@ -95,6 +96,7 @@
|
||||||
<div class="resize-indicator" />
|
<div class="resize-indicator" />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.resize-slider {
|
.resize-slider {
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
</SheetCell>
|
</SheetCell>
|
||||||
|
|
||||||
{#if $stickyColumn}
|
{#if $stickyColumn}
|
||||||
<HeaderCell column={$stickyColumn} />
|
<HeaderCell column={$stickyColumn} orderable={false} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import { getIconForField } from "../utils"
|
import { getIconForField } from "../utils"
|
||||||
|
|
||||||
export let column
|
export let column
|
||||||
|
export let orderable = true
|
||||||
|
|
||||||
const { reorder, isReordering, rand } = getContext("sheet")
|
const { reorder, isReordering, rand } = getContext("sheet")
|
||||||
|
|
||||||
|
@ -43,8 +44,8 @@
|
||||||
<SheetCell
|
<SheetCell
|
||||||
reorderSource={$reorder.sourceColumn === column.name}
|
reorderSource={$reorder.sourceColumn === column.name}
|
||||||
reorderTarget={$reorder.targetColumn === column.name}
|
reorderTarget={$reorder.targetColumn === column.name}
|
||||||
on:mousedown={startReordering}
|
on:mousedown={orderable ? startReordering : null}
|
||||||
on:mouseup={stopReordering}
|
on:mouseup={orderable ? stopReordering : null}
|
||||||
on:click={onClick}
|
on:click={onClick}
|
||||||
width={column.width}
|
width={column.width}
|
||||||
left={column.left}
|
left={column.left}
|
||||||
|
@ -75,8 +76,10 @@
|
||||||
<MenuItem icon="Edit">Edit column</MenuItem>
|
<MenuItem icon="Edit">Edit column</MenuItem>
|
||||||
<MenuItem icon="SortOrderUp">Sort ascending</MenuItem>
|
<MenuItem icon="SortOrderUp">Sort ascending</MenuItem>
|
||||||
<MenuItem icon="SortOrderDown">Sort descending</MenuItem>
|
<MenuItem icon="SortOrderDown">Sort descending</MenuItem>
|
||||||
|
{#if orderable}
|
||||||
<MenuItem icon="ArrowLeft">Move left</MenuItem>
|
<MenuItem icon="ArrowLeft">Move left</MenuItem>
|
||||||
<MenuItem icon="ArrowRight">Move right</MenuItem>
|
<MenuItem icon="ArrowRight">Move right</MenuItem>
|
||||||
|
{/if}
|
||||||
<MenuItem icon="Delete">Delete</MenuItem>
|
<MenuItem icon="Delete">Delete</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
|
@ -95,9 +95,6 @@
|
||||||
.cell.reorder-source {
|
.cell.reorder-source {
|
||||||
background: var(--spectrum-global-color-gray-100);
|
background: var(--spectrum-global-color-gray-100);
|
||||||
}
|
}
|
||||||
.cell.header.reorder-source {
|
|
||||||
background: var(--spectrum-global-color-gray-200);
|
|
||||||
}
|
|
||||||
.cell.reorder-target:after {
|
.cell.reorder-target:after {
|
||||||
content: " ";
|
content: " ";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -48,7 +48,6 @@ export const createReorderStores = context => {
|
||||||
|
|
||||||
// Trigger a move event immediately so ensure a candidate column is chosen
|
// Trigger a move event immediately so ensure a candidate column is chosen
|
||||||
onReorderMouseMove(e)
|
onReorderMouseMove(e)
|
||||||
document.getElementById(`sheet-${rand}`).classList.add("is-reordering")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback when moving the mouse when reordering columns
|
// Callback when moving the mouse when reordering columns
|
||||||
|
@ -107,7 +106,6 @@ export const createReorderStores = context => {
|
||||||
// Remove event handlers
|
// Remove event handlers
|
||||||
document.removeEventListener("mousemove", onReorderMouseMove)
|
document.removeEventListener("mousemove", onReorderMouseMove)
|
||||||
document.removeEventListener("mouseup", stopReordering)
|
document.removeEventListener("mouseup", stopReordering)
|
||||||
document.getElementById(`sheet-${rand}`).classList.remove("is-reordering")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue