Skip to content
Snippets Groups Projects
Commit 657eb08d authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

feat(SubmitionWizard): rename version to fragment and project to collection

parent 82ce3802
No related branches found
No related tags found
3 merge requests!108Hin 858 revision fix,!106Hin 858,!97HIN-858
......@@ -122,9 +122,8 @@ export default compose(
setFilesFetching(type, false)
})
},
downloadFile: ({ downloadFile, token }) => file => {
downloadFile(file)
},
previewFile: ({ previewFile }) => previewFile,
downloadFile: ({ downloadFile, token }) => downloadFile,
deleteFile: ({
files,
deleteFile,
......@@ -152,9 +151,6 @@ export default compose(
}
setFormFiles(newFiles)
},
previewFile: ({ previewFile }) => file => {
previewFile(file)
},
changeList: ({ files, setFormFiles }) => (from, to, fileId) => {
const swappedFile = files[from].find(f => f.id === fileId)
......
......@@ -15,7 +15,7 @@ const mapState = state => ({
const mapDispatch = (dispatch, props) => ({
hideModal: () => dispatch(hideModal()),
showModal: (modalProps = {}) =>
dispatch(showModal(get(props, 'modalKey', 'modal'), modalProps)),
dispatch(showModal(get(props, 'modalKey'), modalProps)),
setModalError: errorMessage => dispatch(setModalError(errorMessage)),
})
......
......@@ -9,8 +9,8 @@ import { Empty } from './'
const StepThree = ({
token,
version,
project,
fragment,
collection,
changeForm,
deleteFile,
uploadFile,
......@@ -36,13 +36,13 @@ const StepThree = ({
<Field component={Empty} name="files" />
<WizardFiles
changeForm={changeForm}
collection={collection}
deleteFile={deleteFile}
files={get(version, 'files', {})}
files={get(fragment, 'files', {})}
fragment={fragment}
getSignedUrl={getSignedUrl}
project={project}
token={token}
uploadFile={uploadFile}
version={version}
/>
{filesError && (
<Row justify="flex-start" mt={1}>
......
......@@ -20,10 +20,10 @@ import { H2, Menu, TextField, ValidatedField } from '@pubsweet/ui'
import { Empty } from './'
const StepTwo = ({
version,
project,
fragment,
journal,
addAuthor,
collection,
changeForm,
formValues,
isAuthorEdit,
......@@ -88,12 +88,12 @@ const StepTwo = ({
<Field component={Empty} name="authors" />
<WizardAuthors
addAuthor={addAuthor}
authors={get(version, 'authors', [])}
authors={get(fragment, 'authors', [])}
changeForm={changeForm}
collection={project}
collection={collection}
deleteAuthor={deleteAuthor}
error={authorsError}
fragment={version}
fragment={fragment}
isAuthorEdit={isAuthorEdit}
isAuthorsFetching={isAuthorsFetching}
journal={journal}
......
......@@ -116,14 +116,14 @@ export default compose(
(state, { match }) => ({
token: getUserToken(state),
isFetching: getAutosaveFetching(state),
isFilesFetching: getFileFetching(state),
reduxAuthorError: getAuthorError(state),
formValues: getFormValues('submission')(state),
submitFailed: hasSubmitFailed('submission')(state),
formSyncErrors: getFormSyncErrors('submission')(state),
version: selectFragment(state, get(match, 'params.version')),
project: selectCollection(state, get(match, 'params.project')),
isFilesFetching: getFileFetching(state),
fragment: selectFragment(state, get(match, 'params.version')),
collection: selectCollection(state, get(match, 'params.project')),
isAuthorsFetching: getAuthorFetching(state) || getAutosaveFetching(state),
reduxAuthorError: getAuthorError(state),
}),
{
changeForm,
......
......@@ -17,21 +17,21 @@ import {
} from '../redux/autosave'
import { SubmissionStatement } from './'
export const setInitialValues = ({ version }) => ({
export const setInitialValues = ({ fragment }) => ({
initialValues: {
files: get(version, 'files', {}),
authors: get(version, 'authors', []),
metadata: get(version, 'metadata', {}),
conflicts: get(version, 'conflicts', {
files: get(fragment, 'files', {}),
authors: get(fragment, 'authors', []),
metadata: get(fragment, 'metadata', {}),
conflicts: get(fragment, 'conflicts', {
hasConflicts: 'no',
hasDataAvailability: '',
hasFunding: '',
}),
declarations: get(version, 'declarations', { agree: false }),
declarations: get(fragment, 'declarations', { agree: false }),
},
})
export const validate = (values, props) => {
export const validate = values => {
const errors = {}
if (!get(values, 'declarations.agree')) {
......@@ -57,8 +57,12 @@ export const validate = (values, props) => {
return errors
}
const _onChange = (values, dispatch, { project, version, updateFragment }) => {
const previousValues = pick(version, [
const _onChange = (
values,
dispatch,
{ collection, fragment, updateFragment },
) => {
const previousValues = pick(fragment, [
'files',
'authors',
'metadata',
......@@ -68,8 +72,8 @@ const _onChange = (values, dispatch, { project, version, updateFragment }) => {
const newValues = omit(values, ['agree', 'authorForm'])
if (!isEqual(newValues, previousValues)) {
dispatch(autosaveRequest())
updateFragment(project, {
...version,
updateFragment(collection, {
...fragment,
...newValues,
}).then(
() => dispatch(autosaveSuccess()),
......@@ -92,8 +96,8 @@ export const onSubmit = (
isEditMode,
setModalError,
submitManuscript,
version: { id: fragmentId },
project: { id: collectionId, customId },
fragment: { id: fragmentId },
collection: { id: collectionId, customId },
},
) => {
if (step !== 2) {
......@@ -107,14 +111,14 @@ export const onSubmit = (
cancelText: 'BACK TO SUBMISSION',
onConfirm: () => {
dispatch(autosaveRequest())
submitManuscript(collectionId, fragmentId)
submitManuscript({ collectionId, fragmentId })
.then(r => {
hideModal()
dispatch(autosaveSuccess())
history.push('/confirmation-page', {
customId,
version: fragmentId,
project: collectionId,
fragment: fragmentId,
collection: collectionId,
})
})
.catch(err => {
......
import moment from 'moment'
import { pick, get } from 'lodash'
import { actions } from 'pubsweet-client'
import { create, update } from 'pubsweet-client/src/helpers/api'
import journalConfig from 'xpub-faraday/app/config/journal'
import { create, update } from 'pubsweet-client/src/helpers/api'
/* constants */
export const CREATE_DRAFT_REQUEST = 'CREATE_DRAFT_REQUEST'
......@@ -90,7 +90,7 @@ export const createDraftSubmission = history => (dispatch, getState) => {
})
}
export const submitManuscript = (collectionId, fragmentId) => dispatch =>
export const submitManuscript = ({ collectionId, fragmentId }) => dispatch =>
create(`/collections/${collectionId}/fragments/${fragmentId}/submit`)
export const createRevision = (
......
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