Skip to content

Commit 2bc5dd0

Browse files
committedSep 13, 2021
Add support to multiple Uppy instances
1 parent d3dbb41 commit 2bc5dd0

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed
 

‎resources/views/components/input/uppy.blade.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
{{ $extraJSForOnUploadSuccess }}
2525
};
2626
27-
uppyUpload = new Uppy({{ $options }});
27+
uppyUpload{{ $hiddenField }} = new Uppy({{ $options }});
2828
29-
uppyUpload
29+
uppyUpload{{ $hiddenField }}
3030
.use(DragDrop, {{ $dragDropOptions }})
3131
.use(AwsS3Multipart, {
3232
companionUrl: '/',
@@ -36,10 +36,10 @@
3636
},
3737
})
3838
.use(StatusBar, {{ $statusBarOptions }})
39-
.on('upload-success', onUploadSuccess('.upload .uploaded-files ol'));
39+
.on('upload-success', onUploadSuccess('.{{ $uploadElementClass }} .uploaded-files ol'));
4040
"
4141
>
42-
<section class="upload">
42+
<section class="{{ $uploadElementClass }}">
4343
<div class="for-DragDrop" x-ref="input"></div>
4444

4545
<div class="for-ProgressBar"></div>

‎src/View/Components/Input/Uppy.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,21 @@ class Uppy extends Component
1616

1717
public string $extraJSForOnUploadSuccess;
1818

19+
public string $uploadElementClass;
20+
1921
/**
2022
* Create a new component instance.
2123
*
2224
* @return void
2325
*/
24-
public function __construct(string $options = '', string $statusBarOptions = '', string $dragDropOptions = '', string $hiddenField = '', $extraJSForOnUploadSuccess = '')
26+
public function __construct(string $options = '', string $statusBarOptions = '', string $dragDropOptions = '', string $hiddenField = 'file', string $extraJSForOnUploadSuccess = '', string $uploadElementClass = 'upload')
2527
{
2628
$this->options = $options;
2729
$this->statusBarOptions = $statusBarOptions;
2830
$this->dragDropOptions = $dragDropOptions;
2931
$this->hiddenField = $hiddenField;
3032
$this->extraJSForOnUploadSuccess = $extraJSForOnUploadSuccess;
33+
$this->uploadElementClass = $uploadElementClass;
3134

3235
if (!$options) {
3336
$this->options = '{
@@ -39,20 +42,16 @@ public function __construct(string $options = '', string $statusBarOptions = '',
3942

4043
if (!$statusBarOptions) {
4144
$this->statusBarOptions = "{
42-
target: '.upload .for-ProgressBar',
45+
target: '.{$uploadElementClass} .for-ProgressBar',
4346
hideAfterFinish: false,
4447
}";
4548
}
4649

4750
if (!$dragDropOptions) {
4851
$this->dragDropOptions = "{
49-
target: '.upload .for-DragDrop',
52+
target: '.{$uploadElementClass} .for-DragDrop',
5053
}";
5154
}
52-
53-
if (!$hiddenField) {
54-
$this->hiddenField = 'file';
55-
}
5655
}
5756

5857
/**

0 commit comments

Comments
 (0)
Please sign in to comment.