This commit is contained in:
vcoppe
2024-05-20 14:32:52 +02:00
parent 60f3896b8b
commit b997b7518a

View File

@@ -23,11 +23,19 @@
: node instanceof Track : node instanceof Track
? 'segment' ? 'segment'
: 'waypoint'; : 'waypoint';
let pull: Record<string, string[]> = {
file: ['file', 'track'],
track: ['file', 'track'],
segment: ['file', 'track', 'segment'],
waypoint: ['waypoint']
};
let sortable: Sortable; let sortable: Sortable;
onMount(() => { onMount(() => {
sortable = Sortable.create(container, { sortable = Sortable.create(container, {
group: sortableLevel, group: {
name: sortableLevel
},
forceAutoScrollFallback: true, forceAutoScrollFallback: true,
multiDrag: true, multiDrag: true,
multiDragKey: 'Meta', multiDragKey: 'Meta',
@@ -60,36 +68,38 @@
</div> </div>
{/each} {/each}
{#if node.wpt.length > 0} {#if node.wpt.length > 0}
<div> <FileListNode node={node.wpt} id={`${id}-wpt`} on:click={(e) => handleClick(e.detail.id)} />
<FileListNode node={node.wpt} id={`${id}-wpt`} on:click={(e) => handleClick(e.detail.id)} />
</div>
{/if} {/if}
{:else if node instanceof Track} {:else if node instanceof Track}
{#each node.children as child, i} {#each node.children as child, i}
<div> <div>
<Button <div>
variant="ghost" <Button
class="ml-1 truncate flex flex-row justify-start py-0 px-1 h-fit" variant="ghost"
on:click={() => handleClick(`${id}-seg-${i + 1}`)}>{`Segment ${i + 1}`}</Button class="ml-1 truncate flex flex-row justify-start py-0 px-1 h-fit"
> on:click={() => handleClick(`${id}-seg-${i + 1}`)}>{`Segment ${i + 1}`}</Button
>
</div>
</div> </div>
{/each} {/each}
{:else if Array.isArray(node) && node.length > 0 && node[0] instanceof Waypoint} {:else if Array.isArray(node) && node.length > 0 && node[0] instanceof Waypoint}
{#each node as wpt, i} {#each node as wpt, i}
<div> <div>
<Button <div>
variant="ghost" <Button
class="ml-1 flex flex-row justify-start py-0 px-1 h-fit" variant="ghost"
on:click={() => handleClick(`${id}-${i + 1}`)} class="ml-1 flex flex-row justify-start py-0 px-1 h-fit"
><span class="truncate">{wpt.name ?? `Waypoint ${i + 1}`}</span></Button on:click={() => handleClick(`${id}-${i + 1}`)}
> ><span class="truncate">{wpt.name ?? `Waypoint ${i + 1}`}</span></Button
>
</div>
</div> </div>
{/each} {/each}
{/if} {/if}
</div> </div>
<style lang="postcss"> <style lang="postcss">
div :global(.sortable-selected) { div :global(.sortable-selected > * > button) {
@apply bg-accent; @apply bg-accent;
} }
</style> </style>