Adding exclusive lists feature

Major new feature, currently testing in a branch right now. Fixes #1
This commit is contained in:
Darius Kazemi
2019-07-26 01:51:20 -07:00
parent dc15521b3a
commit bfc0fbab2c
14 changed files with 76 additions and 23 deletions

View File

@ -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'

View File

@ -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 />