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
9e998751
Commit
9e998751
authored
6 years ago
by
Alexandru Munteanu
Browse files
Options
Downloads
Patches
Plain Diff
feat(submit-revision): move things to utils
parent
28602415
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-manuscript/src/components/SubmitRevision.js
+16
-37
16 additions, 37 deletions
...ges/component-manuscript/src/components/SubmitRevision.js
packages/component-manuscript/src/components/utils.js
+37
-0
37 additions, 0 deletions
packages/component-manuscript/src/components/utils.js
with
53 additions
and
37 deletions
packages/component-manuscript/src/components/SubmitRevision.js
+
16
−
37
View file @
9e998751
import
React
from
'
react
'
import
React
from
'
react
'
import
{
get
}
from
'
lodash
'
import
PropTypes
from
'
prop-types
'
import
PropTypes
from
'
prop-types
'
import
{
connect
}
from
'
react-redux
'
import
{
connect
}
from
'
react-redux
'
import
{
th
}
from
'
@pubsweet/ui-toolkit
'
import
{
th
}
from
'
@pubsweet/ui-toolkit
'
import
{
actions
}
from
'
pubsweet-client
'
import
{
required
}
from
'
xpub-validators
'
import
{
required
}
from
'
xpub-validators
'
import
{
DragDropContext
}
from
'
react-dnd
'
import
{
DragDropContext
}
from
'
react-dnd
'
import
{
get
,
omit
,
debounce
}
from
'
lodash
'
import
styled
,
{
css
}
from
'
styled-components
'
import
styled
,
{
css
}
from
'
styled-components
'
import
HTML5Backend
from
'
react-dnd-html5-backend
'
import
HTML5Backend
from
'
react-dnd-html5-backend
'
import
{
ValidatedField
,
Button
}
from
'
@pubsweet/ui
'
import
{
ValidatedField
,
Button
}
from
'
@pubsweet/ui
'
...
@@ -35,24 +34,15 @@ import {
...
@@ -35,24 +34,15 @@ import {
deleteFile
,
deleteFile
,
getRequestStatus
,
getRequestStatus
,
}
from
'
pubsweet-components-faraday/src/redux/files
'
}
from
'
pubsweet-components-faraday/src/redux/files
'
import
{
requiredHTML
,
requiredFiles
,
onRevisionSubmit
,
onRevisionChange
,
}
from
'
./utils
'
import
{
Expandable
}
from
'
../molecules/
'
import
{
Expandable
}
from
'
../molecules/
'
const
parseEmptyHtml
=
value
=>
{
if
(
value
&&
value
.
replace
(
'
<p></p>
'
,
''
).
replace
(
'
<h1></h1>
'
,
''
))
{
return
undefined
}
return
'
Required
'
}
const
requiredFiles
=
(
values
,
formValues
)
=>
{
const
manuscripts
=
get
(
formValues
,
'
files.manuscripts
'
)
if
(
!
manuscripts
||
manuscripts
.
length
===
0
)
{
return
'
At least one main manuscript file is needed.
'
}
return
undefined
}
const
TextAreaField
=
input
=>
<
Textarea
{...
input
}
height
=
{
70
}
rows
=
{
6
}
/
>
const
TextAreaField
=
input
=>
<
Textarea
{...
input
}
height
=
{
70
}
rows
=
{
6
}
/
>
const
SubmitRevision
=
({
const
SubmitRevision
=
({
addFile
,
addFile
,
...
@@ -65,18 +55,18 @@ const SubmitRevision = ({
...
@@ -65,18 +55,18 @@ const SubmitRevision = ({
})
=>
(
})
=>
(
<
Root
>
<
Root
>
<
Expandable
label
=
"
Submit Revision
"
startExpanded
>
<
Expandable
label
=
"
Submit Revision
"
startExpanded
>
<
Expandable
label
=
"
DETAILS & AUTHORS
"
>
<
Expandable
label
=
"
DETAILS & AUTHORS
"
startExpanded
>
<
Title
>
MANUSCRIPT
TITLE
*<
/Title
>
<
Title
>
MANUSCRIPT
TITLE
*<
/Title
>
<
ValidatedField
<
ValidatedField
component
=
{
input
=>
<
TitleEditor
{...
input
}
/>
}
component
=
{
input
=>
<
TitleEditor
{...
input
}
/>
}
name
=
"
metadata.title
"
name
=
"
metadata.title
"
validate
=
{[
parseEmptyHtml
]}
validate
=
{[
requiredHTML
]}
/
>
/
>
<
Title
>
ABSTRACT
*<
/Title
>
<
Title
>
ABSTRACT
*<
/Title
>
<
ValidatedField
<
ValidatedField
component
=
{
input
=>
<
AbstractEditor
{...
input
}
/>
}
component
=
{
input
=>
<
AbstractEditor
{...
input
}
/>
}
name
=
"
metadata.abstract
"
name
=
"
metadata.abstract
"
validate
=
{[
parseEmptyHtml
]}
validate
=
{[
requiredHTML
]}
/
>
/
>
<
Title
>
AUTHORS
DETAILS
*<
/Title
>
<
Title
>
AUTHORS
DETAILS
*<
/Title
>
<
CustomValidatedField
>
<
CustomValidatedField
>
...
@@ -89,7 +79,7 @@ const SubmitRevision = ({
...
@@ -89,7 +79,7 @@ const SubmitRevision = ({
/
>
/
>
<
/CustomValidatedField
>
<
/CustomValidatedField
>
<
/Expandable
>
<
/Expandable
>
<
Expandable
label
=
"
FILES
"
>
<
Expandable
label
=
"
FILES
"
startExpanded
>
<
CustomValidatedField
>
<
CustomValidatedField
>
<
ValidatedField
<
ValidatedField
component
=
{()
=>
(
component
=
{()
=>
(
...
@@ -140,16 +130,6 @@ const SubmitRevision = ({
...
@@ -140,16 +130,6 @@ const SubmitRevision = ({
<
/Root
>
<
/Root
>
)
)
const
onChange
=
(
values
,
dispatch
,
{
project
,
version
})
=>
{
const
newValues
=
omit
(
values
,
'
authorForm
'
)
dispatch
(
actions
.
updateFragment
(
project
,
{
...
version
,
revision
:
newValues
,
}),
)
}
export
default
compose
(
export
default
compose
(
withContext
(
withContext
(
{
{
...
@@ -219,10 +199,8 @@ export default compose(
...
@@ -219,10 +199,8 @@ export default compose(
})),
})),
reduxForm
({
reduxForm
({
form
:
'
revision
'
,
form
:
'
revision
'
,
onChange
:
debounce
(
onChange
,
1000
,
{
maxWait
:
5000
}),
onChange
:
onRevisionChange
,
onSubmit
:
(
values
,
dispatch
,
{
submitRevision
,
version
,
project
})
=>
{
onSubmit
:
onRevisionSubmit
,
// submitRevision(project.id, version.id)
},
}),
}),
DragDropContext
(
HTML5Backend
),
DragDropContext
(
HTML5Backend
),
toClass
,
toClass
,
...
@@ -298,8 +276,9 @@ const Root = styled.div`
...
@@ -298,8 +276,9 @@ const Root = styled.div`
const
Title
=
styled
.
span
`
const
Title
=
styled
.
span
`
align-self: center;
align-self: center;
font-size:
${
th
(
'
fontSizeBase
'
)}
;
font-family:
${
th
(
'
fontHeading
'
)}
;
margin-bottom: 10px;
font-size:
${
th
(
'
fontSizeBaseSmall
'
)}
;
text-transform: uppercase;
`
`
const
SubmitContainer
=
styled
.
div
`
const
SubmitContainer
=
styled
.
div
`
...
...
This diff is collapsed.
Click to expand it.
packages/component-manuscript/src/components/utils.js
+
37
−
0
View file @
9e998751
...
@@ -186,3 +186,40 @@ export const onReviewSubmit = (
...
@@ -186,3 +186,40 @@ export const onReviewSubmit = (
onCancel
:
hideModal
,
onCancel
:
hideModal
,
})
})
}
}
const
_onRevisionChange
=
(
values
,
dispatch
,
{
project
,
version
})
=>
{
const
newValues
=
omit
(
values
,
'
authorForm
'
)
dispatch
(
actions
.
updateFragment
(
project
,
{
...
version
,
revision
:
newValues
,
}),
)
}
export
const
onRevisionChange
=
debounce
(
_onRevisionChange
,
1000
,
{
maxWait
:
5000
,
})
export
const
onRevisionSubmit
=
(
values
,
dispatch
,
{
submitRevision
,
version
,
project
},
)
=>
{
// submitRevision(project.id, version.id)
}
// revision validators
export
const
requiredHTML
=
value
=>
{
if
(
value
&&
value
.
replace
(
'
<p></p>
'
,
''
).
replace
(
'
<h1></h1>
'
,
''
))
{
return
undefined
}
return
'
Required
'
}
export
const
requiredFiles
=
(
values
,
formValues
)
=>
{
const
manuscripts
=
get
(
formValues
,
'
files.manuscripts
'
)
if
(
!
manuscripts
||
manuscripts
.
length
===
0
)
{
return
'
At least one main manuscript file is needed.
'
}
return
undefined
}
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