From 81323439c02a75ff15fc791c0ad00a1a8280e229 Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Mon, 1 Apr 2024 16:09:14 -0400 Subject: [PATCH] Adds Access Level control to DocumentUpload --- src/lib/components/common/Flex.svelte | 2 + .../components/documents/AccessLevel.svelte | 101 ++++++++++++++++++ .../stories/AccessLevel.stories.svelte | 23 ++++ .../components/forms/DocumentUpload.svelte | 62 +++++------ 4 files changed, 153 insertions(+), 35 deletions(-) create mode 100644 src/lib/components/documents/AccessLevel.svelte create mode 100644 src/lib/components/documents/stories/AccessLevel.stories.svelte diff --git a/src/lib/components/common/Flex.svelte b/src/lib/components/common/Flex.svelte index 2b7abdf5e..c7a0a68b6 100644 --- a/src/lib/components/common/Flex.svelte +++ b/src/lib/components/common/Flex.svelte @@ -10,6 +10,7 @@ export let justify: Justify = "start"; export let reverse = false; export let gap: number = 0.5; + export let wrap: boolean = false; const alignMap: Record = { start: "flex-start", @@ -35,6 +36,7 @@ {...$$restProps} style:display="flex" style:flex-direction={directionWithReverse} + style:flex-wrap={wrap ? "wrap" : "nowrap"} style:align-items={alignMap[align]} style:justify-content={justifyMap[justify]} style:gap={`${gap}rem`} diff --git a/src/lib/components/documents/AccessLevel.svelte b/src/lib/components/documents/AccessLevel.svelte new file mode 100644 index 000000000..c8f274315 --- /dev/null +++ b/src/lib/components/documents/AccessLevel.svelte @@ -0,0 +1,101 @@ + + + + {#each levels as { value, name, description, icon }} +
+ + +
+ {/each} +
+ + diff --git a/src/lib/components/documents/stories/AccessLevel.stories.svelte b/src/lib/components/documents/stories/AccessLevel.stories.svelte new file mode 100644 index 000000000..b69be1b42 --- /dev/null +++ b/src/lib/components/documents/stories/AccessLevel.stories.svelte @@ -0,0 +1,23 @@ + + + + + + + diff --git a/src/lib/components/forms/DocumentUpload.svelte b/src/lib/components/forms/DocumentUpload.svelte index 86b3c823a..c66de7afb 100644 --- a/src/lib/components/forms/DocumentUpload.svelte +++ b/src/lib/components/forms/DocumentUpload.svelte @@ -14,6 +14,7 @@ import InputText from "../common/InputText.svelte"; import InputFile from "../common/InputFile.svelte"; import { removeUnsupportedTypes } from "@/lib/utils/validateFiles"; + import AccessLevel from "../documents/AccessLevel.svelte"; interface UploadFile { index: number; @@ -25,6 +26,8 @@ export let files: UploadFile[] = []; + let fileDropActive; + function createUploadFile(file: File, index: number): UploadFile { return { index, @@ -35,6 +38,22 @@ }; } + function addFiles(filesToAdd: FileList) { + const supportedFiles = removeUnsupportedTypes([...filesToAdd]); + files = files.concat(supportedFiles.map(createUploadFile)); + } + function removeFile(fileToRemove: UploadFile) { + files = files.filter((file) => file.index !== fileToRemove.index); + } + function formatFileType(filetype: string) { + if (filetype && filetype.includes("/")) { + return filetype.split("/")[1]; + } + return "unknown"; + } + + let accessLevel; + const projectOptions = [ { value: "1", label: "FBI Files" }, { value: "2", label: "1033 Program" }, @@ -53,33 +72,10 @@ help: $_("uploadOptions.textract"), }, ]; - - let fileDropActive; - function addFiles(filesToAdd: FileList) { - const supportedFiles = removeUnsupportedTypes([...filesToAdd]); - files = files.concat(supportedFiles.map(createUploadFile)); - } - function removeFile(fileToRemove: UploadFile) { - files = files.filter((file) => file.index !== fileToRemove.index); - } - function renameFile(index: number, name: string) { - files = files.map((file) => { - if (file.index === index) { - file.name = name; - } - return file; - }); - } - function formatFileType(filetype: string) { - if (filetype && filetype.includes("/")) { - return filetype.split("/")[1]; - } - return "unknown"; - }
- +
{#each files as file} @@ -88,12 +84,7 @@ {formatFileType(file.type)} / {filesize(file.size)}

- { - console.log(file); - }} - /> +