Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
11bc7b01
Commit
11bc7b01
authored
6 years ago
by
Alexandru Munteanu
Browse files
Options
Downloads
Patches
Plain Diff
feat(new-submit-wizard): add author list and validations
parent
75ba6401
No related branches found
No related tags found
1 merge request
!14
Sprint #15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-wizard/src/components/NewWizard.js
+45
-3
45 additions, 3 deletions
packages/component-wizard/src/components/NewWizard.js
packages/components-faraday/src/components/UIComponents/FormItems.js
+1
-1
1 addition, 1 deletion
...mponents-faraday/src/components/UIComponents/FormItems.js
with
46 additions
and
4 deletions
packages/component-wizard/src/components/NewWizard.js
+
45
−
3
View file @
11bc7b01
import
React
,
{
Fragment
}
from
'
react
'
import
{
connect
}
from
'
react-redux
'
import
{
reduxForm
}
from
'
redux-form
'
import
{
Field
,
reduxForm
,
hasSubmitFailed
,
getFormSyncErrors
,
}
from
'
redux-form
'
import
{
th
}
from
'
@pubsweet/ui-toolkit
'
import
{
actions
}
from
'
pubsweet-client
'
import
{
withJournal
}
from
'
xpub-journal
'
import
{
ConnectPage
}
from
'
xpub-connect
'
import
{
required
}
from
'
xpub-validators
'
import
{
DragDropContext
}
from
'
react-dnd
'
import
{
get
,
debounce
,
omit
}
from
'
lodash
'
import
styled
,
{
css
}
from
'
styled-components
'
import
HTML5Backend
from
'
react-dnd-html5-backend
'
import
{
get
,
debounce
,
omit
,
has
,
isEmpty
,
isBoolean
}
from
'
lodash
'
import
{
selectCollection
,
selectFragment
}
from
'
xpub-selectors
'
import
{
Icon
,
Checkbox
,
ValidatedField
,
Menu
,
Button
}
from
'
@pubsweet/ui
'
import
{
withStateHandlers
,
compose
,
toClass
,
withProps
}
from
'
recompose
'
...
...
@@ -22,6 +27,7 @@ import {
import
{
autosaveRequest
}
from
'
../redux/autosave
'
const
{
Err
,
Row
,
Label
,
Title
,
...
...
@@ -106,7 +112,13 @@ const NewStepOne = () => (
// #endregion
// #region StepTwo
const
NewStepTwo
=
({
version
,
project
,
manuscriptTypes
})
=>
(
const
NewStepTwo
=
({
version
,
project
,
syncErrors
,
submitFailed
,
manuscriptTypes
,
})
=>
(
<
Fragment
>
<
Title
>
2
.
Manuscript
&
Authors
Details
<
/Title
>
<
Subtitle
>
...
...
@@ -146,11 +158,16 @@ const NewStepTwo = ({ version, project, manuscriptTypes }) => (
<
Row
className
=
"
row
"
>
<
RowItem
vertical
>
<
Label
>
AUTHORS
DETAILS
*<
/Label
>
<
Field
component
=
{()
=>
<
div
/>
}
name
=
"
authors
"
/>
<
AuthorList
parentForm
=
"
submission
"
project
=
{
project
}
version
=
{
version
}
/
>
{
submitFailed
&&
has
(
syncErrors
,
'
authors
'
)
&&
(
<
Err
align
=
"
left
"
>
{
get
(
syncErrors
,
'
authors
'
)}
<
/Err
>
)}
<
/RowItem
>
<
/Row
>
<
/Fragment
>
...
...
@@ -164,6 +181,8 @@ const NewWizard = ({
nextStep
,
prevStep
,
handleSubmit
,
submitFailed
,
formSyncErrors
,
journal
:
{
manuscriptTypes
=
[]
},
})
=>
(
<
Fragment
>
...
...
@@ -184,6 +203,8 @@ const NewWizard = ({
<
NewStepTwo
manuscriptTypes
=
{
manuscriptTypes
}
project
=
{
project
}
submitFailed
=
{
submitFailed
}
syncErrors
=
{
formSyncErrors
}
version
=
{
version
}
/
>
)}
...
...
@@ -210,6 +231,24 @@ const onChange = (values, dispatch, { project, version }) => {
)
}
const
validate
=
(
values
,
props
)
=>
{
const
errors
=
{}
if
(
isEmpty
(
get
(
props
,
'
version.authors
'
)))
{
errors
.
authors
=
'
Authors are required.
'
}
if
(
!
isBoolean
(
values
.
authorForm
)
&&
values
.
authorForm
>
-
1
)
{
errors
.
authors
=
'
You have an unsaved author.
'
}
if
(
isBoolean
(
values
.
authorForm
)
&&
values
.
authorForm
)
{
errors
.
authors
=
'
Finish or cancel adding a new author.
'
}
return
errors
}
// #region export
export
default
compose
(
ConnectPage
(({
match
})
=>
[
...
...
@@ -223,6 +262,8 @@ export default compose(
connect
((
state
,
{
match
})
=>
({
version
:
selectFragment
(
state
,
get
(
match
,
'
params.version
'
)),
project
:
selectCollection
(
state
,
get
(
match
,
'
params.project
'
)),
formSyncErrors
:
getFormSyncErrors
(
'
submission
'
)(
state
),
submitFailed
:
hasSubmitFailed
(
'
submission
'
)(
state
),
})),
withStateHandlers
(
{
step
:
1
},
...
...
@@ -238,6 +279,7 @@ export default compose(
})),
reduxForm
({
form
:
'
submission
'
,
validate
,
onChange
:
debounce
(
onChange
,
1000
,
{
maxWait
:
5000
}),
onSubmit
:
(
values
,
dispatch
,
{
step
,
nextStep
})
=>
{
if
(
step
<
2
)
{
...
...
This diff is collapsed.
Click to expand it.
packages/components-faraday/src/components/UIComponents/FormItems.js
+
1
−
1
View file @
11bc7b01
...
...
@@ -114,7 +114,7 @@ export const Err = styled.span`
font-family:
${
th
(
'
fontReading
'
)}
;
font-size:
${
th
(
'
fontSizeBase
'
)}
;
margin-top: 0;
text-align: center;
text-align:
${({
align
})
=>
align
||
'
center
'
}
;
`
export
const
Textarea
=
styled
.
textarea
`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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