Adding exclusive lists feature
Major new feature, currently testing in a branch right now. Fixes #1
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import { changeListEditorTitle, submitListEditor } from '../../../actions/lists';
|
||||
import { changeListEditorTitle, changeListEditorIsExclusive, submitListEditor } from '../../../actions/lists';
|
||||
import IconButton from '../../../components/icon_button';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
|
||||
import Toggle from 'react-toggle';
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'lists.edit.submit', defaultMessage: 'Change title' },
|
||||
@ -17,6 +18,7 @@ const mapStateToProps = state => ({
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onChange: value => dispatch(changeListEditorTitle(value)),
|
||||
onSubmit: () => dispatch(submitListEditor(false)),
|
||||
onToggle: value => dispatch(changeListEditorIsExclusive(value)),
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps, mapDispatchToProps)
|
||||
@ -26,6 +28,7 @@ class ListForm extends React.PureComponent {
|
||||
static propTypes = {
|
||||
value: PropTypes.string.isRequired,
|
||||
disabled: PropTypes.bool,
|
||||
isExclusive: PropTypes.bool,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
@ -44,8 +47,12 @@ class ListForm extends React.PureComponent {
|
||||
this.props.onSubmit();
|
||||
}
|
||||
|
||||
handleToggle = e => {
|
||||
this.props.onToggle(e.target.checked);
|
||||
}
|
||||
|
||||
render () {
|
||||
const { value, disabled, intl } = this.props;
|
||||
const { value, disabled, intl, isExclusive, hello } = this.props;
|
||||
|
||||
const title = intl.formatMessage(messages.title);
|
||||
|
||||
@ -57,6 +64,11 @@ class ListForm extends React.PureComponent {
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
|
||||
<label htmlFor='is-exclusive-checkbox'>
|
||||
<Toggle className='is-exclusive-checkbox' defaultChecked={isExclusive} onChange={this.handleToggle}/>
|
||||
<FormattedMessage id='lists.is-exclusive' defaultMessage='Exclusive?' />
|
||||
</label>
|
||||
|
||||
<IconButton
|
||||
disabled={disabled}
|
||||
icon='check'
|
||||
|
@ -28,6 +28,7 @@ class ListEditor extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
listId: PropTypes.string.isRequired,
|
||||
isExclusive: PropTypes.bool.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onInitialize: PropTypes.func.isRequired,
|
||||
@ -53,7 +54,7 @@ class ListEditor extends ImmutablePureComponent {
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal list-editor'>
|
||||
<EditListForm />
|
||||
<EditListForm isExclusive={this.props.isExclusive} />
|
||||
|
||||
<Search />
|
||||
|
||||
|
Reference in New Issue
Block a user