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
6a7642b8
Commit
6a7642b8
authored
5 years ago
by
pdg16
Browse files
Options
Downloads
Patches
Plain Diff
Add title field
parent
819ddb9c
Branches
Branches containing commit
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
+33
-15
33 additions, 15 deletions
src/App.js
with
33 additions
and
15 deletions
src/App.js
+
33
−
15
View file @
6a7642b8
...
@@ -9,10 +9,12 @@ import ReorderIcon from '@material-ui/icons/Reorder';
...
@@ -9,10 +9,12 @@ import ReorderIcon from '@material-ui/icons/Reorder';
import
RadioButtonCheckedIcon
from
'
@material-ui/icons/RadioButtonChecked
'
;
import
RadioButtonCheckedIcon
from
'
@material-ui/icons/RadioButtonChecked
'
;
import
CheckBoxOutlineBlankIcon
from
'
@material-ui/icons/CheckBoxOutlineBlank
'
;
import
CheckBoxOutlineBlankIcon
from
'
@material-ui/icons/CheckBoxOutlineBlank
'
;
import
FormFieldText
from
'
./components/FormFieldText
'
;
import
FormFieldText
from
'
./components/fieldsCreateForm/FormFieldText
'
;
import
FormFieldSelect
from
'
./components/FormFieldSelect
'
;
import
FormFieldSelect
from
'
./components/fieldsCreateForm/FormFieldSelect
'
;
import
FormFieldRadio
from
'
./components/FormFieldRadio
'
;
import
FormFieldRadio
from
'
./components/fieldsCreateForm/FormFieldRadio
'
;
import
FormFieldCheckbox
from
'
./components/FormFieldCheckbox
'
;
import
FormFieldCheckbox
from
'
./components/fieldsCreateForm/FormFieldCheckbox
'
;
import
FormFieldTitle
from
'
./components/fieldsCreateForm/FormFieldTitle
'
;
const
useStyles
=
makeStyles
(
theme
=>
({
const
useStyles
=
makeStyles
(
theme
=>
({
menu
:
{
menu
:
{
...
@@ -28,7 +30,7 @@ const useStyles = makeStyles(theme => ({
...
@@ -28,7 +30,7 @@ const useStyles = makeStyles(theme => ({
function
App
()
{
function
App
()
{
const
classes
=
useStyles
();
const
classes
=
useStyles
();
const
[
form
,
setForm
]
=
useState
([]);
const
[
form
,
setForm
]
=
useState
([
{
type
:
"
title
"
,
title
:
""
,
description
:
""
}
]);
function
addToFormQuestion
()
{
function
addToFormQuestion
()
{
setForm
([...
form
,
{
type
:
"
question
"
,
required
:
false
,
question
:
""
}]);
setForm
([...
form
,
{
type
:
"
question
"
,
required
:
false
,
question
:
""
}]);
...
@@ -69,7 +71,7 @@ function App() {
...
@@ -69,7 +71,7 @@ function App() {
console
.
log
(
form
);
console
.
log
(
form
);
}
}
function
set
Text
Field
(
value
,
index
)
{
function
set
Question
Field
(
value
,
index
)
{
form
[
index
].
question
=
value
;
form
[
index
].
question
=
value
;
setForm
([...
form
]);
setForm
([...
form
]);
console
.
log
(
form
);
console
.
log
(
form
);
...
@@ -87,6 +89,18 @@ function App() {
...
@@ -87,6 +89,18 @@ function App() {
console
.
log
(
form
);
console
.
log
(
form
);
}
}
function
setTitleField
(
value
,
index
)
{
form
[
index
].
title
=
value
;
setForm
([...
form
]);
console
.
log
(
form
);
}
function
setDescriptionField
(
value
,
index
)
{
form
[
index
].
description
=
value
;
setForm
([...
form
]);
console
.
log
(
form
);
}
return
(
return
(
<
div
>
<
div
>
<
Grid
<
Grid
...
@@ -95,32 +109,36 @@ function App() {
...
@@ -95,32 +109,36 @@ function App() {
alignItems
=
"
center
"
alignItems
=
"
center
"
justify
=
"
center
"
justify
=
"
center
"
>
>
{
{
form
.
map
((
x
,
index
)
=>
{
form
.
map
((
x
,
index
)
=>
{
if
(
x
.
type
===
"
question
"
)
if
(
x
.
type
===
"
question
"
)
return
<
FormFieldText
question
=
{
x
.
question
}
idq
=
{
index
}
return
<
FormFieldText
question
=
{
x
.
question
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
set
Text
Field
=
{
set
Text
Field
}
deleteFromForm
=
{
deleteFromForm
}
set
Question
Field
=
{
set
Question
Field
}
setRequiredField
=
{
setRequiredField
}
/
>
setRequiredField
=
{
setRequiredField
}
required
=
{
x
.
required
}
/
>
else
if
(
x
.
type
===
"
select
"
)
else
if
(
x
.
type
===
"
select
"
)
return
<
FormFieldSelect
question
=
{
x
.
question
}
options
=
{
x
.
options
}
idq
=
{
index
}
return
<
FormFieldSelect
question
=
{
x
.
question
}
options
=
{
x
.
options
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
addSelectOption
=
{
addSelectOption
}
deleteFromForm
=
{
deleteFromForm
}
addSelectOption
=
{
addSelectOption
}
removeSelectOption
=
{
removeSelectOption
}
setSelectOption
=
{
setSelectOption
}
removeSelectOption
=
{
removeSelectOption
}
setSelectOption
=
{
setSelectOption
}
setTextField
=
{
setTextField
}
setRequiredField
=
{
setRequiredField
}
/
>
setQuestionField
=
{
setQuestionField
}
setRequiredField
=
{
setRequiredField
}
required
=
{
x
.
required
}
/
>
else
if
(
x
.
type
===
"
radio
"
)
else
if
(
x
.
type
===
"
radio
"
)
return
<
FormFieldRadio
question
=
{
x
.
question
}
options
=
{
x
.
options
}
idq
=
{
index
}
return
<
FormFieldRadio
question
=
{
x
.
question
}
options
=
{
x
.
options
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
addSelectOption
=
{
addSelectOption
}
deleteFromForm
=
{
deleteFromForm
}
addSelectOption
=
{
addSelectOption
}
removeSelectOption
=
{
removeSelectOption
}
setSelectOption
=
{
setSelectOption
}
removeSelectOption
=
{
removeSelectOption
}
setSelectOption
=
{
setSelectOption
}
setTextField
=
{
setTextField
}
setRequiredField
=
{
setRequiredField
}
/
>
setQuestionField
=
{
setQuestionField
}
setRequiredField
=
{
setRequiredField
}
required
=
{
x
.
required
}
/
>
else
if
(
x
.
type
===
"
checkbox
"
)
else
if
(
x
.
type
===
"
checkbox
"
)
return
<
FormFieldCheckbox
question
=
{
x
.
question
}
options
=
{
x
.
options
}
idq
=
{
index
}
return
<
FormFieldCheckbox
question
=
{
x
.
question
}
options
=
{
x
.
options
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
addSelectOption
=
{
addSelectOption
}
deleteFromForm
=
{
deleteFromForm
}
addSelectOption
=
{
addSelectOption
}
removeSelectOption
=
{
removeSelectOption
}
setSelectOption
=
{
setSelectOption
}
removeSelectOption
=
{
removeSelectOption
}
setSelectOption
=
{
setSelectOption
}
setTextField
=
{
setTextField
}
setRequiredField
=
{
setRequiredField
}
/
>
setQuestionField
=
{
setQuestionField
}
setRequiredField
=
{
setRequiredField
}
required
=
{
x
.
required
}
/
>
else
if
(
x
.
type
===
"
title
"
)
return
<
FormFieldTitle
question
=
{
x
.
question
}
idq
=
{
index
}
deleteFromForm
=
{
deleteFromForm
}
setTitleField
=
{
setTitleField
}
setDescriptionField
=
{
setDescriptionField
}
/
>
})
})
}
}
<
/Grid
>
<
/Grid
>
<
Paper
className
=
{
classes
.
menu
}
>
<
Paper
className
=
{
classes
.
menu
}
>
...
...
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