diff --git a/packages/component-wizard/src/components/ButtonGroup.js b/packages/component-wizard/src/components/ButtonGroup.js deleted file mode 100644 index e9f3060072eda41d799992089e169f4c08d2e3ee..0000000000000000000000000000000000000000 --- a/packages/component-wizard/src/components/ButtonGroup.js +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react' -import { compose, withHandlers } from 'recompose' -import { Button } from '@pubsweet/ui' - -import classes from './ButtonGroup.local.scss' - -const BUTTON_ACTIONS = { - back: 'back', - cancel: 'cancel', - next: 'next', - finish: 'finish', -} - -const ButtonGroup = ({ buttons, handleOnClick, disabled }) => - buttons && buttons.length > 0 ? ( - <div className={classes.container}> - {buttons.map(btn => ( - <Button - key={btn.label} - onClick={handleOnClick(btn.action)} - primary={btn.action !== 'back' && btn.action !== 'cancel'} - > - {btn.label} - </Button> - ))} - </div> - ) : null - -export default compose( - withHandlers({ - handleOnClick: ({ onNext, onBack, onCancel, onFinish }) => btnAction => { - switch (btnAction) { - case BUTTON_ACTIONS.back: - return onBack - case BUTTON_ACTIONS.next: - return onNext - case BUTTON_ACTIONS.cancel: - return onCancel - case BUTTON_ACTIONS.finish: - return onFinish - default: - return null - } - }, - }), -)(ButtonGroup) diff --git a/packages/component-wizard/src/components/ButtonGroup.local.scss b/packages/component-wizard/src/components/ButtonGroup.local.scss deleted file mode 100644 index c84b6f2eec658982ffafa0af05d73b68518799c0..0000000000000000000000000000000000000000 --- a/packages/component-wizard/src/components/ButtonGroup.local.scss +++ /dev/null @@ -1,55 +0,0 @@ -.container { - align-self: center; - display: flex; - justify-content: space-around; - margin: 20px 0; - width: 400px; -} - -.button { - align-items: center; - border: 2px solid #444; - color: #444; - cursor: pointer; - display: flex; - font-size: 14px; - font-weight: 400; - height: 32px; - justify-content: center; - min-width: 120px; - text-transform: uppercase; - - &:hover { - border-color: #666; - color: #666; - } - - &:active, - &:focus { - outline: none; - } - - &.next { - background-color: #444; - color: #eee; - - &:hover { - background-color: #666; - } - } - - &.finish { - background-color: #888; - color: firebrick; - } - - &.disabled { - border-color: #999; - color: #999; - - &:hover { - border-color: #999; - color: #999; - } - } -} diff --git a/packages/component-wizard/src/components/Wizard.js b/packages/component-wizard/src/components/Wizard.js index 2348e53962c453edf7c3b23e730d2d9044cf2fc7..a5655d471b3d148595b2ee8d5cd097895c5e897d 100644 --- a/packages/component-wizard/src/components/Wizard.js +++ b/packages/component-wizard/src/components/Wizard.js @@ -1,13 +1,19 @@ import React from 'react' +import PropTypes from 'prop-types' import classnames from 'classnames' +import { reduxForm } from 'redux-form' import { withJournal } from 'xpub-journal' -import { reduxForm, Field } from 'redux-form' -import { compose, withHandlers, withState } from 'recompose' -import { ValidatedField } from '@pubsweet/ui' -import { required } from 'xpub-validators' +import { ValidatedField, Button } from '@pubsweet/ui' +import { + compose, + withHandlers, + withState, + getContext, + withContext, +} from 'recompose' import classes from './Wizard.local.scss' -import { Steps, SortableList, ButtonGroup } from './' +import { Steps, SortableList } from './' const { Step } = Steps @@ -24,15 +30,6 @@ const validate = values => { return errors } -const renderField = ({ renderComponent: Comp, input, ...rest }) => ( - <ValidatedField - component={() => <Comp {...input} {...rest} />} - name={rest.fieldId} - required - validate={[required]} - /> -) - const WizardStep = ({ children: stepChildren, title, @@ -40,23 +37,34 @@ const WizardStep = ({ nextStep, prevStep, handleSubmit, + isFinal, + isFirst, + goBack, ...rest }) => ( <div className={classnames(classes.step)}> - <form onSubmit={handleSubmit}> + <form className={classnames(classes.form)} onSubmit={handleSubmit}> <h3>{title}</h3> {stepChildren && - stepChildren.map((child, index) => ( - <Field - component={renderField} - key={child.fieldId} - name={child.fieldId} - {...child} - /> - ))} - <button type="submit">Next</button> + stepChildren.map( + ({ fieldId, validate, renderComponent: Comp, ...rest }, index) => ( + <ValidatedField + component={input => <Comp {...rest} {...input} />} + key={fieldId} + name={fieldId} + validate={validate} + /> + ), + )} + <div className={classnames(classes.buttons)}> + <Button onClick={isFirst ? goBack : prevStep}> + {isFirst ? 'Cancel' : 'Back'} + </Button> + <Button primary type="submit"> + {isFinal ? 'Finish' : 'Next'} + </Button> + </div> </form> - <ButtonGroup buttons={buttons} onBack={prevStep} onNext={nextStep} /> </div> ) @@ -72,10 +80,15 @@ const FormStep = compose( } }, }), + getContext({ + goBack: PropTypes.func, + isFinal: PropTypes.bool, + isFirst: PropTypes.bool, + }), )(WizardStep) const Wizard = ({ - journal: { wizard }, + journal: { wizard: { showProgress, steps } }, getSteps, step, nextStep, @@ -83,17 +96,14 @@ const Wizard = ({ ...rest }) => ( <div className={classnames(classes.container)}> - <Steps currentStep={step}> - {getSteps().map((step, index) => ( - <Step index={index} key={step} title={step} /> - ))} - </Steps> - <FormStep - {...wizard[step]} - isFinal={step === wizard.length - 1} - nextStep={nextStep} - prevStep={prevStep} - /> + {showProgress && ( + <Steps currentStep={step}> + {getSteps().map((step, index) => ( + <Step index={index} key={step} title={step} /> + ))} + </Steps> + )} + <FormStep {...steps[step]} nextStep={nextStep} prevStep={prevStep} /> </div> ) @@ -107,11 +117,24 @@ export default compose( }, }), withHandlers({ - getSteps: ({ journal: { wizard } }) => () => wizard.map(w => w.label), - nextStep: ({ changeStep, journal: { wizard } }) => () => { - changeStep(step => (step === wizard.length - 1 ? step : step + 1)) + getSteps: ({ journal: { wizard: { steps } } }) => () => + steps.map(w => w.label), + nextStep: ({ changeStep, journal: { wizard: { steps } } }) => () => { + changeStep(step => (step === steps.length - 1 ? step : step + 1)) }, prevStep: ({ changeStep }) => () => changeStep(step => (step <= 0 ? step : step - 1)), }), + withContext( + { + goBack: PropTypes.func, + isFinal: PropTypes.bool, + isFirst: PropTypes.bool, + }, + ({ history: { goBack }, step, journal: { wizard: { steps } } }) => ({ + goBack, + isFinal: step === steps.length - 1, + isFirst: step === 0, + }), + ), )(Wizard) diff --git a/packages/component-wizard/src/components/Wizard.local.scss b/packages/component-wizard/src/components/Wizard.local.scss index 0b8cbc74cab9c7b65a314f28bc80dd8bcc7ffdf5..f108dfb46bb426557ebc716d51e4b5e67abd6936 100644 --- a/packages/component-wizard/src/components/Wizard.local.scss +++ b/packages/component-wizard/src/components/Wizard.local.scss @@ -15,3 +15,17 @@ padding: 0 20px; width: 700px; } + +.form { + display: flex; + flex-direction: column; +} + +.buttons { + align-items: center; + align-self: center; + display: flex; + justify-content: space-around; + margin: 15px 0; + width: 400px; +} diff --git a/packages/component-wizard/src/components/index.js b/packages/component-wizard/src/components/index.js index b7c6a170e405705ded6d7f868003501d0b012b6c..e51f2b7f2ffa168113acd18b9894682b93cc8c69 100644 --- a/packages/component-wizard/src/components/index.js +++ b/packages/component-wizard/src/components/index.js @@ -1,5 +1,4 @@ export { default as Steps } from './Steps' export { default as Wizard } from './Wizard' export { default as Dropdown } from './Dropdown' -export { default as ButtonGroup } from './ButtonGroup' export { default as SortableList } from './SortableList' diff --git a/packages/xpub-faraday/_build/config/client-config.json b/packages/xpub-faraday/_build/config/client-config.json index f745f9ab7c33a0ede7be7b48fc3fb32c8eeb87cd..5ff1882d200d00e927111b530cc2258d4af49b6d 100644 --- a/packages/xpub-faraday/_build/config/client-config.json +++ b/packages/xpub-faraday/_build/config/client-config.json @@ -2,7 +2,7 @@ "pubsweet-client": { "API_ENDPOINT": "/api", "login-redirect": "/", - "redux-log": true + "redux-log": false }, "authsome": { "mode": "/Users/alexandrumunt/Projects/Hindawi/xpub/packages/xpub-faraday/config/authsome.js", diff --git a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/CURRENT b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/CURRENT index 875cf233554c73694e75e98fe8a8c22c8493af9e..3051f81a611ab26f20bdab2ca00873c5ff4ce709 100644 --- a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/CURRENT +++ b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/CURRENT @@ -1 +1 @@ -MANIFEST-000007 +MANIFEST-000010 diff --git a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG index 241afc923cd8179630c7382aa5c827ea20f10800..3633bdd4032ed44d55b8b95695704cfefb0c9deb 100644 --- a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG +++ b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG @@ -1,5 +1,5 @@ -2018/01/12-10:37:25.695488 700004273000 Recovering log #6 -2018/01/12-10:37:25.697023 700004273000 Level-0 table #8: started -2018/01/12-10:37:25.697468 700004273000 Level-0 table #8: 692 bytes OK -2018/01/12-10:37:25.698638 700004273000 Delete type=0 #6 -2018/01/12-10:37:25.699530 700004273000 Delete type=3 #4 +2018/01/15-11:16:04.172115 700008d13000 Recovering log #9 +2018/01/15-11:16:04.172334 700008d13000 Level-0 table #11: started +2018/01/15-11:16:04.172677 700008d13000 Level-0 table #11: 237 bytes OK +2018/01/15-11:16:04.173405 700008d13000 Delete type=3 #7 +2018/01/15-11:16:04.173527 700008d13000 Delete type=0 #9 diff --git a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG.old b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG.old index 08df6d5d0a2680a9e46f96a6e518cfc22b627373..241afc923cd8179630c7382aa5c827ea20f10800 100644 --- a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG.old +++ b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG.old @@ -1,5 +1,5 @@ -2018/01/09-16:57:47.142452 70000509e000 Recovering log #3 -2018/01/09-16:57:47.142855 70000509e000 Level-0 table #5: started -2018/01/09-16:57:47.143583 70000509e000 Level-0 table #5: 339 bytes OK -2018/01/09-16:57:47.144913 70000509e000 Delete type=0 #3 -2018/01/09-16:57:47.145131 70000509e000 Delete type=3 #2 +2018/01/12-10:37:25.695488 700004273000 Recovering log #6 +2018/01/12-10:37:25.697023 700004273000 Level-0 table #8: started +2018/01/12-10:37:25.697468 700004273000 Level-0 table #8: 692 bytes OK +2018/01/12-10:37:25.698638 700004273000 Delete type=0 #6 +2018/01/12-10:37:25.699530 700004273000 Delete type=3 #4 diff --git a/packages/xpub-faraday/api/db/development/CURRENT b/packages/xpub-faraday/api/db/development/CURRENT index f405c4b597b9cfe33e2975bb9f3b949cc51f1e95..b0fe36ef847afeb6c7a516529b07bfce002ecb5e 100644 --- a/packages/xpub-faraday/api/db/development/CURRENT +++ b/packages/xpub-faraday/api/db/development/CURRENT @@ -1 +1 @@ -MANIFEST-000162 +MANIFEST-000169 diff --git a/packages/xpub-faraday/api/db/development/LOG b/packages/xpub-faraday/api/db/development/LOG index 3bd35ff65bb432b82574c891a466a521ddb72d69..d05f2fd716af2824469d932e0fcdb4fcb65c5c0c 100644 --- a/packages/xpub-faraday/api/db/development/LOG +++ b/packages/xpub-faraday/api/db/development/LOG @@ -1,5 +1,5 @@ -2018/01/12-14:35:19.911319 70001307d000 Recovering log #161 -2018/01/12-14:35:19.912463 70001307d000 Level-0 table #163: started -2018/01/12-14:35:19.912996 70001307d000 Level-0 table #163: 237 bytes OK -2018/01/12-14:35:19.913780 70001307d000 Delete type=3 #159 -2018/01/12-14:35:19.913972 70001307d000 Delete type=0 #161 +2018/01/15-11:43:30.224354 70000fc12000 Recovering log #167 +2018/01/15-11:43:30.225277 70000fc12000 Level-0 table #170: started +2018/01/15-11:43:30.225698 70000fc12000 Level-0 table #170: 237 bytes OK +2018/01/15-11:43:30.226457 70000fc12000 Delete type=0 #167 +2018/01/15-11:43:30.226694 70000fc12000 Delete type=3 #165 diff --git a/packages/xpub-faraday/api/db/development/LOG.old b/packages/xpub-faraday/api/db/development/LOG.old index dfc75080e9e867d524fc28a21bfa1f3dcb6040d8..22d3e70056b18214a6ea787afcac860833a26a09 100644 --- a/packages/xpub-faraday/api/db/development/LOG.old +++ b/packages/xpub-faraday/api/db/development/LOG.old @@ -1,5 +1,14 @@ -2018/01/12-14:32:13.255236 70000e0f3000 Recovering log #158 -2018/01/12-14:32:13.256323 70000e0f3000 Level-0 table #160: started -2018/01/12-14:32:13.256930 70000e0f3000 Level-0 table #160: 237 bytes OK -2018/01/12-14:32:13.258255 70000e0f3000 Delete type=0 #158 -2018/01/12-14:32:13.258600 70000e0f3000 Delete type=3 #156 +2018/01/15-11:15:26.115293 700008d13000 Recovering log #164 +2018/01/15-11:15:26.116155 700008d13000 Level-0 table #166: started +2018/01/15-11:15:26.116639 700008d13000 Level-0 table #166: 237 bytes OK +2018/01/15-11:15:26.117729 700008d13000 Delete type=0 #164 +2018/01/15-11:15:26.117926 700008d13000 Delete type=3 #162 +2018/01/15-11:15:26.118145 700009599000 Compacting 4@0 + 1@1 files +2018/01/15-11:15:26.119425 700009599000 Generated table #168@0: 11 keys, 1463 bytes +2018/01/15-11:15:26.119451 700009599000 Compacted 4@0 + 1@1 files => 1463 bytes +2018/01/15-11:15:26.119586 700009599000 compacted to: files[ 0 1 0 0 0 0 0 ] +2018/01/15-11:15:26.119707 700009599000 Delete type=2 #160 +2018/01/15-11:15:26.119877 700009599000 Delete type=2 #163 +2018/01/15-11:15:26.120014 700009599000 Delete type=2 #166 +2018/01/15-11:15:26.120143 700009599000 Delete type=2 #155 +2018/01/15-11:15:26.120392 700009599000 Delete type=2 #157 diff --git a/packages/xpub-faraday/app/config/journal/submit-wizard.js b/packages/xpub-faraday/app/config/journal/submit-wizard.js index 03e86b7ec272935061973d882e4efc227570ecb6..ec2b0ff861746d5e2b00cf70eb6d6db763cefb24 100644 --- a/packages/xpub-faraday/app/config/journal/submit-wizard.js +++ b/packages/xpub-faraday/app/config/journal/submit-wizard.js @@ -8,9 +8,11 @@ import { Supplementary, } from '@pubsweet/ui' import uploadFile from 'xpub-upload' +import { required, minChars } from 'xpub-validators' import { articleSections, articleTypes, declarations } from './' +const min3Chars = minChars(3) const yesNoWithLabel = ({ label, ...rest }) => ( <div> <label>{label}</label> @@ -18,156 +20,119 @@ const yesNoWithLabel = ({ label, ...rest }) => ( </div> ) -const wizard = [ - { - label: 'Journal details', - title: 'Jounal & Field Selection', - children: [ - { - fieldId: 'journal', - renderComponent: Menu, - label: 'Journal', - options: articleTypes, - required: true, - }, - { - fieldId: 'subject', - renderComponent: Menu, - label: 'Subject area', - options: articleSections, - }, - { - fieldId: 'specialIssue', - renderComponent: Menu, - label: 'Special issue', - options: [ - { label: 'Special 2.1', value: 'dd21' }, - { label: 'Special 2.2', value: 'dd22' }, - ], - }, - ], - buttons: [ - { - label: 'Cancel', - action: 'cancel', - }, - { - label: 'Next step', - action: 'next', - }, - ], - }, - { - label: 'Pre-submission checklist', - title: 'Pre-submission Checklist', - subtitle: - 'Before moving forward make sure you have all the needed details prepared by reviewing and checking off the items on this list.', - children: [ - { - fieldId: 'declarations', - renderComponent: CheckboxGroup, - options: declarations.options, - }, - ], - buttons: [ - { - label: 'Back', - action: 'back', - }, - { - label: 'Next step', - action: 'next', - }, - ], - }, - { - label: 'Manuscript & Authors Details', - title: 'Manuscript & Authors Details', - subtitle: - 'Please provide the details of all the authors of this manuscript....', - children: [ - { - fieldId: 'step3-1', - renderComponent: TitleEditor, - placeholder: 'Manuscript title', - title: 'Manuscript title', - }, - { - fieldId: 'step3-2', - renderComponent: Menu, - label: 'Manuscript type', - options: [ - { label: 'Type 1', value: 'type1' }, - { label: 'Type 2', value: 'type2' }, - ], - }, - { - fieldId: 'step3-3', - renderComponent: AbstractEditor, - title: 'Abstract', - placeholder: 'Write an abstract', - }, - // { - // fieldId: 'authors', - // renderComponent: 'sortable-list', - // label: 'Authors details', - // }, - { - fieldId: 'step3-4', - renderComponent: yesNoWithLabel, - label: 'Is there a potential conflict of interest?', - }, - { - fieldId: 'step3-5', - renderComponent: TextField, - label: 'Conflict of interest details', - }, - ], - buttons: [ - { - label: 'Back', - action: 'back', - }, - { - label: 'Next step', - action: 'next', - }, - ], - }, - { - label: 'Files upload', - title: 'Manuscript Files Upload', - children: [ - { - fieldId: 'mainManuscripts', - label: 'Main Manuscript', - renderComponent: Supplementary, - uploadFile, - }, - { - fieldId: 'supplementalFiles', - label: 'Supplemental Files', - renderComponent: Supplementary, - uploadFile, - }, - { - fieldId: 'coverLetter', - label: 'Cover Letter', - renderComponent: Supplementary, - uploadFile, - }, - ], - buttons: [ - { - label: 'Back', - action: 'back', - }, - { - label: 'Finish', - action: 'finish', - }, - ], - }, -] - -export default wizard +export default { + showProgress: false, + steps: [ + { + label: 'Journal details', + title: 'Jounal & Field Selection', + children: [ + { + fieldId: 'journal', + renderComponent: Menu, + label: 'Journal', + options: articleTypes, + validate: [required], + }, + { + fieldId: 'subject', + renderComponent: Menu, + label: 'Subject area', + options: articleSections, + }, + { + fieldId: 'specialIssue', + renderComponent: Menu, + label: 'Special issue', + options: [ + { label: 'Special 2.1', value: 'dd21' }, + { label: 'Special 2.2', value: 'dd22' }, + ], + validate: [required], + }, + ], + }, + { + label: 'Pre-submission checklist', + title: 'Pre-submission Checklist', + subtitle: + 'Before moving forward make sure you have all the needed details prepared by reviewing and checking off the items on this list.', + children: [ + { + fieldId: 'declarations', + renderComponent: CheckboxGroup, + options: declarations.options, + }, + ], + }, + { + label: 'Manuscript & Authors Details', + title: 'Manuscript & Authors Details', + subtitle: + 'Please provide the details of all the authors of this manuscript....', + children: [ + { + fieldId: 'step3-1', + renderComponent: TitleEditor, + placeholder: 'Manuscript title', + title: 'Manuscript title', + }, + { + fieldId: 'step3-2', + renderComponent: Menu, + label: 'Manuscript type', + options: [ + { label: 'Type 1', value: 'type1' }, + { label: 'Type 2', value: 'type2' }, + ], + }, + { + fieldId: 'step3-3', + renderComponent: AbstractEditor, + title: 'Abstract', + placeholder: 'Write an abstract', + }, + // { + // fieldId: 'authors', + // renderComponent: 'sortable-list', + // label: 'Authors details', + // }, + { + fieldId: 'step3-4', + renderComponent: yesNoWithLabel, + label: 'Is there a potential conflict of interest?', + }, + { + fieldId: 'step3-5', + renderComponent: TextField, + label: 'Conflict of interest details', + validate: [required, min3Chars], + }, + ], + }, + { + label: 'Files upload', + title: 'Manuscript Files Upload', + children: [ + { + fieldId: 'mainManuscripts', + label: 'Main Manuscript', + renderComponent: Supplementary, + uploadFile, + }, + { + fieldId: 'supplementalFiles', + label: 'Supplemental Files', + renderComponent: Supplementary, + uploadFile, + }, + { + fieldId: 'coverLetter', + label: 'Cover Letter', + renderComponent: Supplementary, + uploadFile, + }, + ], + }, + ], +} diff --git a/packages/xpub-faraday/config/default.js b/packages/xpub-faraday/config/default.js index ac142cf190c5a2949aeb6142ab589fbb04fa27e3..36f785c3693194e7e9c1d5098f5f287f6f687de2 100644 --- a/packages/xpub-faraday/config/default.js +++ b/packages/xpub-faraday/config/default.js @@ -24,7 +24,7 @@ module.exports = { 'pubsweet-client': { API_ENDPOINT: '/api', 'login-redirect': '/', - 'redux-log': true, + 'redux-log': false, theme: process.env.PUBSWEET_THEME, }, 'mail-transport': {