Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
form-creator-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
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
simmctic
form-creator
form-creator-ui
Commits
166e54d2
Commit
166e54d2
authored
5 years ago
by
pdg16
Browse files
Options
Downloads
Patches
Plain Diff
add select field option
parent
45b18fa5
No related branches found
No related tags found
3 merge requests
!58
Version 1.1
,
!54
Issue #53: Fix password info
,
!15
Issue/4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/App.js
+39
-8
39 additions, 8 deletions
src/App.js
with
39 additions
and
8 deletions
src/App.js
+
39
−
8
View file @
166e54d2
...
...
@@ -6,6 +6,7 @@ import TextField from '@material-ui/core/TextField';
import
AddIcon
from
'
@material-ui/icons/Add
'
;
import
IconButton
from
'
@material-ui/core/IconButton
'
;
import
ReorderIcon
from
'
@material-ui/icons/Reorder
'
;
import
RadioButtonCheckedIcon
from
'
@material-ui/icons/RadioButtonChecked
'
;
import
FormFieldText
from
'
./components/FormFieldText
'
...
...
@@ -15,7 +16,7 @@ import FormFieldSelect from './components/FormFieldSelect'
const
useStyles
=
makeStyles
(
theme
=>
({
menu
:
{
width
:
theme
.
spacing
(
6
),
height
:
theme
.
spacing
(
15
),
min
height
:
theme
.
spacing
(
15
),
position
:
'
fixed
'
,
top
:
theme
.
spacing
(
10
),
left
:
'
90%
'
,
...
...
@@ -29,12 +30,22 @@ function App() {
const
[
form
,
setForm
]
=
useState
([]);
function
addToFormQuestion
()
{
setForm
([...
form
,
{
type
:
"
question
"
,
question
:
""
}]);
setForm
([...
form
,
{
type
:
"
question
"
,
required
:
false
,
question
:
""
}]);
console
.
log
(
form
);
}
function
addToFormSelect
()
{
setForm
([...
form
,
{
type
:
"
select
"
,
question
:
""
,
options
:
[]}]);
setForm
([...
form
,
{
type
:
"
select
"
,
question
:
""
,
required
:
false
,
options
:
[
""
]}]);
console
.
log
(
form
);
}
function
addToFormRadio
()
{
}
function
addSelectOption
(
index
)
{
form
[
index
].
options
.
push
(
""
);
setForm
([...
form
]);
console
.
log
(
form
);
}
...
...
@@ -45,17 +56,29 @@ function App() {
setForm
([...
form
]);
}
function
removeSelectOption
(
index
,
idopt
)
{
form
[
index
].
options
.
splice
(
idopt
,
1
);
setForm
([...
form
]);
console
.
log
(
form
);
}
function
setTextField
(
value
,
index
)
{
form
[
index
].
question
=
value
;
setForm
([...
form
]);
console
.
log
(
form
);
}
function
setSelectField
(
value
,
index
)
{
function
setSelectOption
(
value
,
index
,
idopt
)
{
form
[
index
].
options
[
idopt
]
=
value
;
setForm
([...
form
]);
console
.
log
(
form
);
}
function
setRequiredField
(
index
)
{
form
[
index
].
required
=
!
form
[
index
].
required
;
setForm
([...
form
]);
console
.
log
(
form
);
}
return
(
<
div
>
...
...
@@ -69,9 +92,14 @@ function App() {
{
form
.
map
((
x
,
index
)
=>
{
if
(
x
.
type
===
"
question
"
)
return
<
FormFieldText
question
=
{
x
.
question
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
setTextField
=
{
setTextField
}
/
>
return
<
FormFieldText
question
=
{
x
.
question
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
setTextField
=
{
setTextField
}
setRequiredField
=
{
setRequiredField
}
/
>
else
if
(
x
.
type
===
"
select
"
)
return
<
FormFieldSelect
question
=
{
x
.
question
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
setTextField
=
{
setSelectField
}
/
>
return
<
FormFieldSelect
question
=
{
x
.
question
}
options
=
{
x
.
options
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
addSelectOption
=
{
addSelectOption
}
removeSelectOption
=
{
removeSelectOption
}
setSelectOption
=
{
setSelectOption
}
setTextField
=
{
setTextField
}
setRequiredField
=
{
setRequiredField
}
/
>
})
}
...
...
@@ -93,6 +121,9 @@ function App() {
<
IconButton
aria
-
label
=
"
add select
"
onClick
=
{
addToFormSelect
}
>
<
ReorderIcon
/>
<
/IconButton
>
<
IconButton
aria
-
label
=
"
add radio
"
onClick
=
{
addToFormRadio
}
>
<
RadioButtonCheckedIcon
/>
<
/IconButton
>
<
/Grid
>
<
/Grid
>
<
/Paper
>
...
...
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