diff --git a/packages/components-faraday/src/components/AuthorList/AuthorAdder.js b/packages/components-faraday/src/components/AuthorList/AuthorAdder.js index cd1fc2563375add271adb6145c8da9a5f1cb836c..5a11c7c6c95f732146a7d0d338dc53f750485b8a 100644 --- a/packages/components-faraday/src/components/AuthorList/AuthorAdder.js +++ b/packages/components-faraday/src/components/AuthorList/AuthorAdder.js @@ -51,7 +51,7 @@ const AuthorAdder = ({ label="Affiliation*" name="affiliation" /> - <MenuItem label="Country" name="country" options={countries} /> + <MenuItem label="Country*" name="country" options={countries} /> </Row> <ButtonsContainer> <Button onClick={setEditMode(false)}>Cancel</Button> diff --git a/packages/components-faraday/src/components/AuthorList/AuthorEditor.js b/packages/components-faraday/src/components/AuthorList/AuthorEditor.js index 5eed9cd35b81cea7ea8fb706c24c766e6f391a34..6c3eda8479f8101460f89aba91773d7fd0768a34 100644 --- a/packages/components-faraday/src/components/AuthorList/AuthorEditor.js +++ b/packages/components-faraday/src/components/AuthorList/AuthorEditor.js @@ -85,7 +85,7 @@ const AuthorEdit = ({ label="Affiliation*" name="edit.affiliation" /> - <MenuItem label="Country" name="edit.country" options={countries} /> + <MenuItem label="Country*" name="edit.country" options={countries} /> </Row> </Root> ) @@ -101,6 +101,7 @@ export default compose( initialValues: { edit: pick(props, [ 'isCorresponding', + 'isSubmitting', 'firstName', 'lastName', 'middleName', diff --git a/packages/components-faraday/src/components/UIComponents/CheckboxGroup.js b/packages/components-faraday/src/components/UIComponents/CheckboxGroup.js new file mode 100644 index 0000000000000000000000000000000000000000..59906f1308b8d4f849f528fa984baa3c14a4442c --- /dev/null +++ b/packages/components-faraday/src/components/UIComponents/CheckboxGroup.js @@ -0,0 +1,52 @@ +import React from 'react' +import { Checkbox } from '@pubsweet/ui' + +class CheckboxGroup extends React.Component { + constructor(props) { + super(props) + + this.state = { + values: props.value || [], + } + } + + handleChange = event => { + const values = [...this.state.values] + + const { value } = event.target + + if (event.target.checked) { + values.push(value) + } else { + values.splice(values.indexOf(value), 1) + } + + this.setState({ values }) + + this.props.onChange(values) + } + + render() { + const { inline, name, options, required } = this.props + const { values } = this.state + + return ( + <div> + {options.map(option => ( + <Checkbox + checked={values.includes(option.value)} + inline={inline} + key={option.value} + label={option.label} + name={name} + onChange={this.handleChange} + required={required} + value={option.value} + /> + ))} + </div> + ) + } +} + +export default CheckboxGroup diff --git a/packages/components-faraday/src/components/UIComponents/index.js b/packages/components-faraday/src/components/UIComponents/index.js index 0f79f62b6f773549c5da460c041232e47820dfb3..607aa47b3a80c7b28df1c3fdfa6976a7c7b599c8 100644 --- a/packages/components-faraday/src/components/UIComponents/index.js +++ b/packages/components-faraday/src/components/UIComponents/index.js @@ -1,3 +1,4 @@ export { default as Logo } from './Logo' export { default as Spinner } from './Spinner' export { default as Dropdown } from './Dropdown' +export { default as CheckboxGroup } from './CheckboxGroup' diff --git a/packages/components-faraday/src/components/index.js b/packages/components-faraday/src/components/index.js index 93791801a0d9b164825524d90a60699d4fc3d0d1..241cd9712fbaf8676b45d7cf1f97353ba0f69b9a 100644 --- a/packages/components-faraday/src/components/index.js +++ b/packages/components-faraday/src/components/index.js @@ -5,4 +5,4 @@ export { default as AuthorList } from './AuthorList/AuthorList' export { default as SortableList } from './SortableList/SortableList' export { DragHandle } from './AuthorList/FormItems' -export { Dropdown, Logo, Spinner } from './UIComponents' +export { Dropdown, Logo, Spinner, CheckboxGroup } from './UIComponents' diff --git a/packages/xpub-faraday/app/config/journal/submit-wizard.js b/packages/xpub-faraday/app/config/journal/submit-wizard.js index c0aaa8b4299fe203aadd3e8657f7b98388690d3f..2387b5adc444d9e5f5734a0c2249008e1d44f680 100644 --- a/packages/xpub-faraday/app/config/journal/submit-wizard.js +++ b/packages/xpub-faraday/app/config/journal/submit-wizard.js @@ -2,9 +2,13 @@ import React from 'react' import styled from 'styled-components' import uploadFileFn from 'xpub-upload' import { AbstractEditor, TitleEditor } from 'xpub-edit' -import { Menu, CheckboxGroup, YesOrNo, TextField } from '@pubsweet/ui' +import { Menu, YesOrNo, TextField } from '@pubsweet/ui' import { required, minChars, minSize } from 'xpub-validators' -import { AuthorList, Files } from 'pubsweet-components-faraday/src/components' +import { + AuthorList, + Files, + CheckboxGroup, +} from 'pubsweet-components-faraday/src/components' import { declarations } from './' import issueTypes from './issues-types'