diff --git a/packages/component-wizard/src/components/SortableList.js b/packages/component-wizard/src/components/SortableList.js index 9004e49454aae4125b4c982e8b0209c4fca38e59..1273b9e12bf1ef63d4b4747a1f000f0e79791986 100644 --- a/packages/component-wizard/src/components/SortableList.js +++ b/packages/component-wizard/src/components/SortableList.js @@ -31,7 +31,6 @@ const itemTarget = { if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) { return } - moveItem(dragIndex, hoverIndex) monitor.getItem().index = hoverIndex }, diff --git a/packages/component-wizard/src/components/Steps.local.scss b/packages/component-wizard/src/components/Steps.local.scss index 0977a8f01a589a4abe30b1aca355199a73e60844..b02d38008a85111d12e7d65c701c74de051fa72f 100644 --- a/packages/component-wizard/src/components/Steps.local.scss +++ b/packages/component-wizard/src/components/Steps.local.scss @@ -8,14 +8,14 @@ } .separator { - background-color: #555; + background-color: #000; flex: 1; height: 2px; } .step { align-items: center; - border: 2px solid #555; + border: 2px solid #000; border-radius: 50%; display: flex; height: 16px; @@ -25,7 +25,7 @@ } .bullet { - background-color: #555; + background-color: #000; border-radius: 50%; height: 10px; width: 10px; @@ -42,7 +42,7 @@ .success { align-items: center; - background-color: #555; + background-color: #000; border-radius: 50%; color: #fff; display: flex; diff --git a/packages/component-wizard/src/components/Wizard.js b/packages/component-wizard/src/components/Wizard.js index b25bc55dffa5711c94ed770d2ad13a18ff4450ce..b14fbc60a995548fbb0ad640b5ded0c30ef93d36 100644 --- a/packages/component-wizard/src/components/Wizard.js +++ b/packages/component-wizard/src/components/Wizard.js @@ -1,9 +1,10 @@ import React from 'react' import classnames from 'classnames' import { withJournal } from 'xpub-journal' -import { compose, withHandlers, withState } from 'recompose' -import { TextField, YesOrNo } from '@pubsweet/ui' import { AbstractEditor } from 'xpub-edit' +import { reduxForm, Field } from 'redux-form' +import { TextField, YesOrNo, Menu, Checkbox } from '@pubsweet/ui' +import { compose, withHandlers, withState } from 'recompose' import classes from './Wizard.local.scss' import { Dropdown, Steps, SortableList, ButtonGroup } from './' @@ -18,46 +19,76 @@ const items = [ { name: '5gicuta' }, ] +const renderField = ({ renderComponent, input, ...rest }) => { + console.log('Render field', input, rest) + return React.createElement(renderComponent, { ...rest, ...input }) +} + +const WizardStep = ({ + children: stepChildren, + title, + buttons, + nextStep, + prevStep, + onSubmit, + ...rest +}) => ( + <div className={classnames(classes.step)}> + <form onSubmit={onSubmit}> + <h3>{title}</h3> + {stepChildren && + stepChildren.map((child, index) => ( + <Field + component={renderField} + key={child.fieldId} + name={child.fieldId} + {...child} + /> + ))} + </form> + <ButtonGroup buttons={buttons} onBack={prevStep} onNext={nextStep} /> + </div> +) + +const FormStep = compose( + reduxForm({ + form: 'wizard', + onSubmit: () => console.log('am dat surmit'), + destroyOnUnmount: false, + forceUnregisterOnUnmount: true, + }), +)(WizardStep) + const Wizard = ({ journal: { wizard }, getSteps, step, - incrementStep, - decrementStep, - moveItem, + nextStep, + prevStep, listItems, - renderStep, renderChild, - disabled, - toggleBtn, -}) => { - const { title, children: stepChildren, buttons: stepButtons } = wizard[step] - return ( - <div className={classnames(classes.container)}> - <Steps currentStep={step}> - {getSteps().map((step, index) => ( - <Step index={index} key={step} title={step} /> - ))} - </Steps> - <button onClick={toggleBtn}>Toggle</button> - <div className={classnames(classes.step)}> - <h3>{title}</h3> - {stepChildren && stepChildren.map((sc, index) => renderChild(sc))} - <ButtonGroup - buttons={stepButtons} - disabled={disabled} - onBack={decrementStep} - onNext={incrementStep} - /> - </div> - </div> - ) -} + handleSubmit, + ...rest +}) => ( + <div className={classnames(classes.container)}> + <Steps currentStep={step}> + {getSteps().map((step, index) => ( + <Step index={index} key={step} title={step} /> + ))} + </Steps> + <FormStep + {...wizard[step]} + nextStep={nextStep} + onSubmit={handleSubmit} + prevStep={prevStep} + renderChild={renderChild} + /> + </div> +) export default compose( withJournal, withState('step', 'changeStep', 0), - withState('disabled', 'changeBtn', true), withState('listItems', 'changeItems', items), withHandlers({ moveItem: ({ changeItems }) => (dragIndex, hoverIndex) => { @@ -66,57 +97,9 @@ export default compose( }), withHandlers({ getSteps: ({ journal: { wizard } }) => () => wizard.map(w => w.label), - toggleBtn: ({ changeBtn }) => () => changeBtn(v => !v), - incrementStep: ({ changeStep, journal: { wizard } }) => () => + nextStep: ({ changeStep, journal: { wizard } }) => () => changeStep(step => (step === wizard.length ? step : step + 1)), - decrementStep: ({ changeStep }) => () => + prevStep: ({ changeStep }) => () => changeStep(step => (step <= 0 ? step : step - 1)), - renderChild: ({ listItems, moveItem }) => data => { - switch (data.type) { - case 'dropdown': - return ( - <Dropdown - key={data.label} - label={data.label} - options={data.values} - /> - ) - case 'checkbox': - return ( - <div key={data.label}> - <input type="checkbox" /> - <label>{data.label}</label> - </div> - ) - case 'text': - return <TextField label={data.label} /> - case 'abstract': - return ( - <div> - <span>{data.label}</span> - <AbstractEditor /> - </div> - ) - case 'yesno': - return ( - <div> - <span>{data.label}</span> - <YesOrNo name={data.label} /> - </div> - ) - case 'sortable-list': - return ( - <SortableList - items={listItems} - listItem={({ name, isDragging }) => ( - <div style={{ opacity: isDragging ? 0.5 : 1 }}>{name}</div> - )} - moveItem={moveItem} - /> - ) - default: - return <div>sorry</div> - } - }, }), )(Wizard) diff --git a/packages/xpub-faraday/_build/config/client-config.json b/packages/xpub-faraday/_build/config/client-config.json index 5ff1882d200d00e927111b530cc2258d4af49b6d..f745f9ab7c33a0ede7be7b48fc3fb32c8eeb87cd 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": false + "redux-log": true }, "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 cacca7574c0344589df56801fa8248e207854647..875cf233554c73694e75e98fe8a8c22c8493af9e 100644 --- a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/CURRENT +++ b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/CURRENT @@ -1 +1 @@ -MANIFEST-000004 +MANIFEST-000007 diff --git a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG index 08df6d5d0a2680a9e46f96a6e518cfc22b627373..241afc923cd8179630c7382aa5c827ea20f10800 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/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-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG.old b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG.old index 6e96e3ba8b9c16fdd1ad69081f3bea02ed048843..08df6d5d0a2680a9e46f96a6e518cfc22b627373 100644 --- a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG.old +++ b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/LOG.old @@ -1 +1,5 @@ -2018/01/09-16:57:26.656703 70000fc1f000 Delete type=3 #1 +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 diff --git a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/MANIFEST-000004 b/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/MANIFEST-000004 deleted file mode 100644 index 4597cc10f5be066e7c0dbeeb78e75869d6b194ea..0000000000000000000000000000000000000000 Binary files a/packages/xpub-faraday/api/db/development-mrview-fe0ff9878713e4fffce6b37f75b19960/MANIFEST-000004 and /dev/null differ diff --git a/packages/xpub-faraday/api/db/development/CURRENT b/packages/xpub-faraday/api/db/development/CURRENT index ffd4a0108662b7b9c85f6f06319a1083cb5812fb..c16f179ffd3840d2c86f839bb557cbb748255b5b 100644 --- a/packages/xpub-faraday/api/db/development/CURRENT +++ b/packages/xpub-faraday/api/db/development/CURRENT @@ -1 +1 @@ -MANIFEST-000146 +MANIFEST-000156 diff --git a/packages/xpub-faraday/api/db/development/LOG b/packages/xpub-faraday/api/db/development/LOG index 7594fbc0ad6d30b712770ebddd87c954365e9d5c..176c0c324df518187da46029e7a9359c63b3b056 100644 --- a/packages/xpub-faraday/api/db/development/LOG +++ b/packages/xpub-faraday/api/db/development/LOG @@ -1,5 +1,5 @@ -2018/01/11-16:23:32.284236 700012094000 Recovering log #145 -2018/01/11-16:23:32.285724 700012094000 Level-0 table #147: started -2018/01/11-16:23:32.286392 700012094000 Level-0 table #147: 237 bytes OK -2018/01/11-16:23:32.287918 700012094000 Delete type=3 #143 -2018/01/11-16:23:32.288226 700012094000 Delete type=0 #145 +2018/01/12-13:50:08.231595 70000c302000 Recovering log #154 +2018/01/12-13:50:08.232541 70000c302000 Level-0 table #157: started +2018/01/12-13:50:08.233098 70000c302000 Level-0 table #157: 237 bytes OK +2018/01/12-13:50:08.233908 70000c302000 Delete type=3 #152 +2018/01/12-13:50:08.234059 70000c302000 Delete type=0 #154 diff --git a/packages/xpub-faraday/api/db/development/LOG.old b/packages/xpub-faraday/api/db/development/LOG.old index 36a570ab09c89680492402ac22aa1b302e9a92f5..afc31de34e65db2261ea06d7e6e2f3ec5fc657ec 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/11-16:21:42.691976 70000ed05000 Recovering log #141 -2018/01/11-16:21:42.692731 70000ed05000 Level-0 table #144: started -2018/01/11-16:21:42.693203 70000ed05000 Level-0 table #144: 237 bytes OK -2018/01/11-16:21:42.694106 70000ed05000 Delete type=3 #139 -2018/01/11-16:21:42.694255 70000ed05000 Delete type=0 #141 +2018/01/12-13:39:21.891350 70000d8d6000 Recovering log #151 +2018/01/12-13:39:21.892244 70000d8d6000 Level-0 table #153: started +2018/01/12-13:39:21.892709 70000d8d6000 Level-0 table #153: 237 bytes OK +2018/01/12-13:39:21.894383 70000d8d6000 Delete type=0 #151 +2018/01/12-13:39:21.894571 70000d8d6000 Delete type=3 #149 +2018/01/12-13:39:21.895409 70000d959000 Compacting 4@0 + 1@1 files +2018/01/12-13:39:21.896309 70000d959000 Generated table #155@0: 11 keys, 1463 bytes +2018/01/12-13:39:21.896335 70000d959000 Compacted 4@0 + 1@1 files => 1463 bytes +2018/01/12-13:39:21.896502 70000d959000 compacted to: files[ 0 1 0 0 0 0 0 ] +2018/01/12-13:39:21.896617 70000d959000 Delete type=2 #142 +2018/01/12-13:39:21.897278 70000d959000 Delete type=2 #147 +2018/01/12-13:39:21.898247 70000d959000 Delete type=2 #153 +2018/01/12-13:39:21.898532 70000d959000 Delete type=2 #150 +2018/01/12-13:39:21.898768 70000d959000 Delete type=2 #144 diff --git a/packages/xpub-faraday/app/config/journal/declarations.js b/packages/xpub-faraday/app/config/journal/declarations.js index 012e4d46c2bfe3b20da969a9277a391d61c18094..2f25fbee2e499dcc09f87585cc28e7b9b8af302b 100644 --- a/packages/xpub-faraday/app/config/journal/declarations.js +++ b/packages/xpub-faraday/app/config/journal/declarations.js @@ -25,4 +25,34 @@ export default { legend: 'Pre-registered?', }, ], + options: [ + { + value: 'step2-1', + label: `I have the email addresses of all the co-authors of the manuscript.`, + }, + { + value: 'step2-2', + label: + 'I have the manuscript file in Microsoft Word or Adobe PDF format with the tables and figures integrated in the manuscript body.', + }, + { + value: 'step2-3', + label: + 'I have the electronic files of any supplementary materials (e.g., datasets, images, audio, video) that I want to submit with the manuscript.', + }, + { + value: 'step2-4', + label: + 'I am aware that accepted manuscripts are subject to Article Processing Charges.', + }, + { + value: 'step2-5', + label: `I'm aware that an ORCID ID is required for the corresponding author before the article can be published (if accepted). The ORCID ID should added via your user account.`, + }, + { + value: 'step2-6', + label: + 'I am aware that if my submission is covered by an institutional membership, Hindawi will share details of the manuscript with the administrator of the membership.', + }, + ], } diff --git a/packages/xpub-faraday/app/config/journal/submit-wizard.js b/packages/xpub-faraday/app/config/journal/submit-wizard.js index d917f739c81aa11be5454f4a85d27b31b6c14cc5..fa278669c8c7fee2c17d0eb1203b250b1c2e5683 100644 --- a/packages/xpub-faraday/app/config/journal/submit-wizard.js +++ b/packages/xpub-faraday/app/config/journal/submit-wizard.js @@ -1,34 +1,32 @@ +import { AbstractEditor, TitleEditor } from 'xpub-edit' +import { Menu, Checkbox, CheckboxGroup, YesOrNo, TextField } from '@pubsweet/ui' + +import { articleSections, articleTypes, declarations } from './' + const wizard = [ { label: 'Journal details', title: 'Jounal & Field Selection', children: [ { - type: 'dropdown', - fullWidth: true, - label: 'Journal *', - values: [ - { label: 'Dropdown 1.1', value: 'dd11' }, - { label: 'Dropdown 1.2', value: 'dd12' }, - ], + fieldId: 'journal', + renderComponent: Menu, + label: 'Journal', + options: articleTypes, }, { - type: 'dropdown', - fullWidth: true, + fieldId: 'subject', + renderComponent: Menu, label: 'Subject area', - values: [ - { label: 'Dropdown 2.1', value: 'dd21' }, - { label: 'Dropdown 2.2', value: 'dd22' }, - ], + options: articleSections, }, { - type: 'dropdown', - fullWidth: true, + fieldId: 'specialIssue', + renderComponent: Menu, label: 'Special issue', - disabled: true, - values: [ - { label: 'Dropdown 2.1', value: 'dd21' }, - { label: 'Dropdown 2.2', value: 'dd22' }, + options: [ + { label: 'Special 2.1', value: 'dd21' }, + { label: 'Special 2.2', value: 'dd22' }, ], }, ], @@ -54,33 +52,9 @@ const wizard = [ 'Before moving forward make sure you have all the needed details prepared by reviewing and checking off the items on this list.', children: [ { - type: 'checkbox', - label: - 'I have the email addresses of all the co-authors of the manuscript.', - }, - { - type: 'checkbox', - label: - 'I have the manuscript file in Microsoft Word or Adobe PDF format with the tables and figures integrated in the manuscript body.', - }, - { - type: 'checkbox', - label: - 'I have the electronic files of any supplementary materials (e.g., datasets, images, audio, video) that I want to submit with the manuscript.', - }, - { - type: 'checkbox', - label: - 'I am aware that accepted manuscripts are subject to Article Processing Charges.', - }, - { - type: 'checkbox', - label: `I'm aware that an ORCID ID is required for the corresponding author before the article can be published (if accepted). The ORCID ID should added via your user account.`, - }, - { - type: 'checkbox', - label: - 'I am aware that if my submission is covered by an institutional membership, Hindawi will share details of the manuscript with the administrator of the membership.', + fieldId: 'declarations', + renderComponent: CheckboxGroup, + options: declarations.options, }, ], buttons: [ @@ -101,36 +75,39 @@ const wizard = [ 'Please provide the details of all the authors of this manuscript....', children: [ { - type: 'text', - label: 'Manuscript title', - fullWidth: false, + fieldId: 'step3-1', + renderComponent: TitleEditor, + placeholder: 'Manuscript title', + title: 'Manuscript title', }, { - type: 'dropdown', + fieldId: 'step3-2', + renderComponent: Menu, label: 'Manuscript type', - fullWidth: false, - values: [ + options: [ { label: 'Type 1', value: 'type1' }, { label: 'Type 2', value: 'type2' }, ], }, { - type: 'abstract', - label: 'Abstract', - fullWidth: true, - }, - { - key: 'authors', - type: 'sortable-list', - fullWidth: true, - label: 'Authors details', + fieldId: 'step3-3', + renderComponent: AbstractEditor, + title: 'Abstract', + placeholder: 'Write an abstract', }, + // { + // fieldId: 'authors', + // renderComponent: 'sortable-list', + // label: 'Authors details', + // }, { - type: 'yesno', + fieldId: 'step3-4', + renderComponent: YesOrNo, label: 'Is there a potential conflict of interest?', }, { - type: 'text', + fieldId: 'step3-5', + renderComponent: TextField, label: 'Conflict of interest details', }, ], @@ -145,6 +122,7 @@ const wizard = [ }, ], }, + /* { label: 'Files upload', title: 'Manuscript Files Upload', @@ -159,6 +137,7 @@ const wizard = [ }, ], }, + */ ] export default wizard diff --git a/packages/xpub-faraday/config/default.js b/packages/xpub-faraday/config/default.js index 36f785c3693194e7e9c1d5098f5f287f6f687de2..ac142cf190c5a2949aeb6142ab589fbb04fa27e3 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': false, + 'redux-log': true, theme: process.env.PUBSWEET_THEME, }, 'mail-transport': {