Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes #14982

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions packages/bbui/src/Form/Core/Dropzone.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Link from "../../Link/Link.svelte"
import Tag from "../../Tags/Tag.svelte"
import Tags from "../../Tags/Tags.svelte"
import ProgressCircle from "../../ProgressCircle/ProgressCircle.svelte"

const BYTES_IN_KB = 1000
const BYTES_IN_MB = 1000000
Expand Down Expand Up @@ -39,12 +40,14 @@
"jfif",
"webp",
]

const fieldId = id || uuid()

let selectedImageIdx = 0
let fileDragged = false
let selectedUrl
let fileInput
let loading = false

$: selectedImage = value?.[selectedImageIdx] ?? null
$: fileCount = value?.length ?? 0
$: isImage =
Expand Down Expand Up @@ -86,10 +89,15 @@
}

if (processFiles) {
const processedFiles = await processFiles(fileList)
const newValue = [...value, ...processedFiles]
dispatch("change", newValue)
selectedImageIdx = newValue.length - 1
loading = true
try {
const processedFiles = await processFiles(fileList)
const newValue = [...value, ...processedFiles]
dispatch("change", newValue)
selectedImageIdx = newValue.length - 1
} finally {
loading = false
}
} else {
dispatch("change", fileList)
}
Expand Down Expand Up @@ -227,7 +235,7 @@
{#if showDropzone}
<div
class="spectrum-Dropzone"
class:disabled
class:disabled={disabled || loading}
role="region"
tabindex="0"
on:dragover={handleDragOver}
Expand All @@ -241,7 +249,7 @@
id={fieldId}
{disabled}
type="file"
multiple
multiple={maximum !== 1}
accept={extensions}
bind:this={fileInput}
on:change={handleFile}
Expand Down Expand Up @@ -339,6 +347,12 @@
{/if}
{/if}
</div>

{#if loading}
<div class="loading">
<ProgressCircle size="M" />
</div>
{/if}
</div>
{/if}
</div>
Expand Down Expand Up @@ -464,6 +478,7 @@

.spectrum-Dropzone {
height: 220px;
position: relative;
}
.compact .spectrum-Dropzone {
height: 40px;
Expand All @@ -488,4 +503,14 @@
.tag {
margin-top: 8px;
}

.loading {
position: absolute;
display: grid;
place-items: center;
height: 100%;
width: 100%;
top: 0;
left: 0;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
on:close={close}
maxHeight={null}
resizable
minWidth={360}
>
<div class="content">
<slot />
Expand Down Expand Up @@ -80,7 +81,6 @@
}

.content {
width: 300px;
padding: 20px;
display: flex;
flex-direction: column;
Expand Down
1 change: 1 addition & 0 deletions packages/frontend-core/src/fetch/NestedProviderFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default class NestedProviderFetch extends DataFetch {
// Nested providers should already have exposed their own schema
return {
schema: datasource?.value?.schema,
primaryDisplay: datasource?.value?.primaryDisplay,
}
}

Expand Down
Loading