Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kszkepzes-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KSZK
DevTeam
kszkepzes
old
kszkepzes-frontend
Commits
135301ae
Commit
135301ae
authored
6 years ago
by
Bsandor453
Browse files
Options
Downloads
Patches
Plain Diff
Add front-end validation for file type and size
parent
06edec63
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/forms/AddSolutionForm.js
+22
-3
22 additions, 3 deletions
src/components/forms/AddSolutionForm.js
with
22 additions
and
3 deletions
src/components/forms/AddSolutionForm.js
+
22
−
3
View file @
135301ae
...
...
@@ -6,6 +6,15 @@ import './Forms.css';
import
ConfirmModal
from
'
../forms/ConfirmModal
'
;
import
{
emptyMessage
}
from
'
../pages/Homework
'
;
const
allowedFileTypes
=
[
'
image/jpeg
'
,
'
image/png
'
,
'
application/x-zip-compressed
'
,
];
//in megabytes
const
maxFileSize
=
50
;
class
AddSolutionForm
extends
Component
{
constructor
(
props
)
{
super
(
props
);
...
...
@@ -23,7 +32,7 @@ class AddSolutionForm extends Component {
const
accepted
=
false
;
const
sentences
=
this
.
props
.
taskdesc
.
split
(
'
\n
'
);
const
note
=
''
;
const
disabledText
=
'
A határidő lejárt, további beadás nem lehetséges.
'
const
disabledText
=
'
A határidő lejárt, további beadás nem lehetséges.
'
;
return
(
<
Modal
open
=
{
this
.
state
.
showModal
}
...
...
@@ -65,7 +74,7 @@ class AddSolutionForm extends Component {
placeholder
=
'
Add meg a megoldás leírását...
'
/>
<
Form
.
Field
>
<
label
>
Fájl
:
<
/label
>
<
label
>
Fájl
(
Megengedett
fájltípusok
:
png
,
jpeg
,
jpg
,
zip
.
Maximum
50
MB
.)
:
<
/label
>
<
Input
type
=
'
file
'
onChange
=
{
e
=>
this
.
props
.
writeSolutionFile
(
e
)}
/
>
<
/Form.Field
>
<
/Form
>
...
...
@@ -86,7 +95,16 @@ class AddSolutionForm extends Component {
?
<
ConfirmModal
button
=
{
<
Button
disabled
=
{(
name
===
''
||
description
===
''
)}
inverted
color
=
'
green
'
>
<
Button
disabled
=
{
name
===
''
||
description
===
''
||
!
allowedFileTypes
.
includes
(
file
.
type
)
||
file
.
size
>
(
maxFileSize
)
*
(
1024
**
2
)
}
inverted
color
=
'
green
'
>
<
Icon
name
=
'
checkmark
'
/>
Beadás
<
/Button
>
}
...
...
@@ -95,6 +113,7 @@ class AddSolutionForm extends Component {
this
.
props
.
addSolution
({
task
,
accepted
,
corrected
,
note
,
name
,
description
,
file
,
});
console
.
log
(
file
);
this
.
setState
({
showModal
:
false
});
this
.
props
.
clearWrite
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment