Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sesatheque
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Sesamath
sesatheque
Commits
7275e4f3
Commit
7275e4f3
authored
Oct 08, 2019
by
Daniel Caillibaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initialize pas utilisé viré
parent
be73a7c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
app/client-react/components/ResourceForm.js
app/client-react/components/ResourceForm.js
+13
-12
No files found.
app/client-react/components/ResourceForm.js
View file @
7275e4f3
...
...
@@ -67,8 +67,7 @@ ResourceForm.propTypes = {
handleSubmit
:
PropTypes
.
func
,
submitting
:
PropTypes
.
bool
,
saveRessource
:
PropTypes
.
func
,
pristine
:
PropTypes
.
bool
,
initialize
:
PropTypes
.
func
pristine
:
PropTypes
.
bool
}
const
validate
=
(
values
)
=>
{
...
...
@@ -76,12 +75,14 @@ const validate = (values) => {
const
{
type
}
=
values
const
{
validate
:
typeValidate
}
=
getEditor
(
type
)
if
(
typeValidate
)
{
console
.
log
(
`pour le type
${
type
}
on a un validate`
)
typeValidate
(
values
,
errors
)
}
console
.
log
(
`pour le type
${
type
}
on retourne les erreurs de validation`
,
errors
)
return
errors
}
const
onSubmit
=
(
values
,
dispatch
,
{
saveRessource
,
initialize
})
=>
{
const
onSubmit
=
(
values
,
dispatch
,
{
saveRessource
})
=>
{
const
{
saveHook
=
identity
}
=
getEditor
(
values
.
type
)
return
saveRessource
(
saveHook
(
values
),
(
savedRessource
)
=>
{
...
...
@@ -103,6 +104,13 @@ const onSubmit = (values, dispatch, {saveRessource, initialize}) => {
})
}
const
propsAfterLoadHook
=
({
ressource
})
=>
{
const
{
loadHook
=
identity
}
=
getEditor
(
ressource
.
type
)
return
{
initialValues
:
loadHook
(
ressource
)
}
}
const
formDef
=
{
form
:
'
ressource
'
,
validate
,
...
...
@@ -110,20 +118,13 @@ const formDef = {
onSubmitFail
,
enableReinitialize
:
true
}
const
formComponent
=
reduxForm
(
formDef
)(
ResourceForm
)
export
default
ensureLogged
(
resourceLoader
(
aliasForker
(
// fork si on édite un alias
resourceSaver
(
// fournit saveRessource
withProps
(({
ressource
})
=>
{
const
{
loadHook
=
identity
}
=
getEditor
(
ressource
.
type
)
return
{
initialValues
:
loadHook
(
ressource
)
}
})(
reduxForm
(
formDef
)(
ResourceForm
)
)
withProps
(
propsAfterLoadHook
)(
formComponent
)
)
)
)
...
...
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