Skip to content
Snippets Groups Projects
Commit 6cd29fe9 authored by Sebastian's avatar Sebastian
Browse files

Merge branch 'faraday-master' of gitlab.coko.foundation:xpub/xpub into faraday-master

parents 72756b9f 9e05a375
No related branches found
No related tags found
No related merge requests found
...@@ -114,12 +114,30 @@ export default compose( ...@@ -114,12 +114,30 @@ export default compose(
'item', 'item',
{ {
drop( drop(
{ changeList, listId: toListId, maxFiles, files, setError }, {
changeList,
listId: toListId,
maxFiles,
files,
setError,
allowedFileExtensions,
...pm
},
monitor, monitor,
) { ) {
const { listId: fromListId, id } = monitor.getItem() const { listId: fromListId, id, name } = monitor.getItem()
const fileExtention = name.split('.')[1]
if (
allowedFileExtensions &&
!allowedFileExtensions.includes(fileExtention)
) {
setError('Invalid file type.')
return
}
if (files.length >= maxFiles) { if (files.length >= maxFiles) {
setError('No more files of this type can be added.') setError('No more files can be added to this section.')
return return
} }
...@@ -148,7 +166,7 @@ export default compose( ...@@ -148,7 +166,7 @@ export default compose(
const fileExtention = file.name.split('.')[1] const fileExtention = file.name.split('.')[1]
if (files.length >= maxFiles) { if (files.length >= maxFiles) {
setError('No more files of this type can be added.') setError('No more files can be added to this section.')
return return
} }
...@@ -158,7 +176,7 @@ export default compose( ...@@ -158,7 +176,7 @@ export default compose(
) { ) {
addFile(file) addFile(file)
} else { } else {
setError('File type not allowed for these kind of files.') setError('Invalid file type.')
} }
}, },
}, },
......
...@@ -66,7 +66,6 @@ export default ({ ...@@ -66,7 +66,6 @@ export default ({
) )
}, },
)} )}
<Files />
<div className={classnames(classes.buttons)}> <div className={classnames(classes.buttons)}>
<Button onClick={isFirst ? () => history.push('/') : prevStep}> <Button onClick={isFirst ? () => history.push('/') : prevStep}>
{isFirst {isFirst
......
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
requiredBasedOnType, requiredBasedOnType,
editModeEnabled, editModeEnabled,
parseEmptyHtml, parseEmptyHtml,
requiredFiles,
} from './wizard-validators' } from './wizard-validators'
const min3Chars = minChars(3) const min3Chars = minChars(3)
...@@ -174,37 +175,8 @@ export default { ...@@ -174,37 +175,8 @@ export default {
{ {
fieldId: 'file-upload', fieldId: 'file-upload',
renderComponent: Files, renderComponent: Files,
validate: [requiredFiles],
}, },
// {
// fieldId: 'label-manuscript',
// renderComponent: Label,
// label: 'Main Manuscript',
// },
// {
// fieldId: 'files.manuscripts',
// label: 'Main Manuscript',
// renderComponent: Supplementary,
// },
// {
// fieldId: 'label-supplementary',
// renderComponent: Label,
// label: 'Supplemental Files',
// },
// {
// fieldId: 'files.supplementary',
// label: 'Supplemental Files',
// renderComponent: Supplementary,
// },
// {
// fieldId: 'label-cover',
// renderComponent: Label,
// label: 'Cover Letter',
// },
// {
// fieldId: 'files.coverLetter',
// label: 'Cover Letter',
// renderComponent: Supplementary,
// },
], ],
}, },
], ],
......
...@@ -29,3 +29,10 @@ export const editModeEnabled = value => { ...@@ -29,3 +29,10 @@ export const editModeEnabled = value => {
} }
return undefined return undefined
} }
export const requiredFiles = (valus, formValues) => {
if (get(formValues, 'files.manuscripts').length === 0) {
return 'At least one main manuscript file is needed.'
}
return undefined
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment