Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
5eca4db9
Commit
5eca4db9
authored
Feb 02, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multi file upload
parent
bc69a003
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
ContractVerificationFieldSources.tsx
...tVerification/fields/ContractVerificationFieldSources.tsx
+9
-3
FileInput.tsx
ui/shared/forms/FileInput.tsx
+1
-1
No files found.
ui/contractVerification/fields/ContractVerificationFieldSources.tsx
View file @
5eca4db9
...
@@ -19,7 +19,7 @@ interface Props {
...
@@ -19,7 +19,7 @@ interface Props {
}
}
const
ContractVerificationFieldSources
=
({
accept
,
multiple
,
title
,
className
,
hint
}:
Props
)
=>
{
const
ContractVerificationFieldSources
=
({
accept
,
multiple
,
title
,
className
,
hint
}:
Props
)
=>
{
const
{
setValue
,
getValues
,
control
,
formState
}
=
useFormContext
<
FormFields
>
();
const
{
setValue
,
getValues
,
control
,
formState
,
clearErrors
}
=
useFormContext
<
FormFields
>
();
const
error
=
'
sources
'
in
formState
.
errors
?
formState
.
errors
.
sources
:
undefined
;
const
error
=
'
sources
'
in
formState
.
errors
?
formState
.
errors
.
sources
:
undefined
;
...
@@ -31,8 +31,9 @@ const ContractVerificationFieldSources = ({ accept, multiple, title, className,
...
@@ -31,8 +31,9 @@ const ContractVerificationFieldSources = ({ accept, multiple, title, className,
const
value
=
getValues
(
'
sources
'
).
slice
();
const
value
=
getValues
(
'
sources
'
).
slice
();
value
.
splice
(
index
,
1
);
value
.
splice
(
index
,
1
);
setValue
(
'
sources
'
,
value
);
setValue
(
'
sources
'
,
value
);
clearErrors
(
'
sources
'
);
},
[
getValues
,
setValue
]);
},
[
getValues
,
clearErrors
,
setValue
]);
const
renderFiles
=
React
.
useCallback
((
files
:
Array
<
File
>
)
=>
{
const
renderFiles
=
React
.
useCallback
((
files
:
Array
<
File
>
)
=>
{
return
(
return
(
...
@@ -54,7 +55,12 @@ const ContractVerificationFieldSources = ({ accept, multiple, title, className,
...
@@ -54,7 +55,12 @@ const ContractVerificationFieldSources = ({ accept, multiple, title, className,
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
sources
'
>
})
=>
(
const
renderControl
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
FormFields
,
'
sources
'
>
})
=>
(
<>
<>
<
FileInput
<
FormFields
,
'
sources
'
>
accept=
{
accept
}
multiple=
{
multiple
}
field=
{
field
}
>
<
FileInput
<
FormFields
,
'
sources
'
>
accept=
{
accept
}
multiple=
{
multiple
}
field=
{
field
}
>
<
Button
variant=
"outline"
size=
"sm"
display=
{
field
.
value
&&
field
.
value
.
length
>
0
?
'
none
'
:
'
block
'
}
>
<
Button
variant=
"outline"
size=
"sm"
display=
{
field
.
value
&&
field
.
value
.
length
>
0
&&
!
multiple
?
'
none
'
:
'
block
'
}
mb=
{
field
.
value
&&
field
.
value
.
length
>
0
?
2
:
0
}
>
Upload file
{
multiple
?
'
s
'
:
''
}
Upload file
{
multiple
?
'
s
'
:
''
}
</
Button
>
</
Button
>
</
FileInput
>
</
FileInput
>
...
...
ui/shared/forms/FileInput.tsx
View file @
5eca4db9
...
@@ -20,7 +20,7 @@ const FileInput = <Values extends FieldValues, Names extends Path<Values>>({ chi
...
@@ -20,7 +20,7 @@ const FileInput = <Values extends FieldValues, Names extends Path<Values>>({ chi
}
}
const
files
=
Array
.
from
(
fileList
);
const
files
=
Array
.
from
(
fileList
);
field
.
onChange
(
files
);
field
.
onChange
(
[
...(
field
.
value
||
[]),
...
files
]
);
field
.
onBlur
();
field
.
onBlur
();
},
[
field
]);
},
[
field
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment