Passed files as FileTree

This commit is contained in:
Alabhya Jindal 2024-03-03 14:15:24 +05:30
parent f0a248e74b
commit 4a19332092
2 changed files with 10 additions and 2 deletions

View File

@ -52,6 +52,7 @@
{selectedFiles}
{isUnapplied}
{branchController}
{files}
/>
{/if}
</div>

View File

@ -6,9 +6,9 @@
import TreeListFile from './TreeListFile.svelte';
import TreeListFolder from './TreeListFolder.svelte';
import type { BranchController } from '$lib/vbranches/branchController';
import type { TreeNode } from '$lib/vbranches/filetree';
import { sortLikeFileTree, type TreeNode } from '$lib/vbranches/filetree';
import type { Ownership } from '$lib/vbranches/ownership';
import type { AnyFile } from '$lib/vbranches/types';
import type { AnyFile, LocalFile, RemoteFile } from '$lib/vbranches/types';
import type { Writable } from 'svelte/store';
export let expanded = true;
@ -22,6 +22,7 @@
export let allowMultiple = false;
export let readonly = false;
export let branchController: BranchController;
export let files: LocalFile[] | RemoteFile[];
function isNodeChecked(selectedOwnership: Ownership, node: TreeNode): boolean {
if (node.file) {
@ -59,6 +60,7 @@
}
$: isIndeterminate = isNodeIndeterminate($selectedOwnership, node);
$: sortedFiles = sortLikeFileTree(files);
function toggle() {
expanded = !expanded;
@ -80,6 +82,7 @@
{readonly}
{allowMultiple}
{branchController}
{files}
on:checked
on:unchecked
/>
@ -112,6 +115,9 @@
$selectedFiles = [file];
}
}}
on:keydown={() => {
console.log(sortedFiles);
}}
/>
{:else if node.children.length > 0}
<!-- Node is a folder -->
@ -144,6 +150,7 @@
{readonly}
{allowMultiple}
{branchController}
{files}
on:checked
on:unchecked
/>