From a872269086ca6423176ed504e95c6f1769bc8829 Mon Sep 17 00:00:00 2001 From: Bosn Date: Fri, 19 Jan 2018 11:41:31 +0800 Subject: [PATCH] fix bugs --- package.json | 2 +- src/components/account/LoginForm.jsx | 2 +- .../organization/OrganizationForm.jsx | 9 ++++ src/components/repository/RepositoryForm.jsx | 9 ++++ src/components/utils/RadioList.jsx | 44 +++++++++++++++++++ src/components/utils/RadioList.sass | 6 +++ src/family/UIConst.js | 10 +++++ src/relatives/effects/repository.js | 2 +- 8 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 src/components/utils/RadioList.jsx create mode 100644 src/components/utils/RadioList.sass create mode 100644 src/family/UIConst.js diff --git a/package.json b/package.json index 074fa1e..e421f45 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ ] }, "engines": { - "install-node": "9.2.0" + "install-node": "8.9.3" }, "devDependencies": { "babel-eslint": "7.2.3", diff --git a/src/components/account/LoginForm.jsx b/src/components/account/LoginForm.jsx index 03b2ec2..0b772e4 100644 --- a/src/components/account/LoginForm.jsx +++ b/src/components/account/LoginForm.jsx @@ -50,7 +50,7 @@ class LoginForm extends Component {
this.setState({ captcha: e.target.value })} className='form-control' placeholder='验证码' required /> - this.setState({ captchaId: Date.now() })} alt="captcha"/> + this.setState({ captchaId: Date.now() })} alt='captcha' />
diff --git a/src/components/organization/OrganizationForm.jsx b/src/components/organization/OrganizationForm.jsx index 77ec310..04782b3 100644 --- a/src/components/organization/OrganizationForm.jsx +++ b/src/components/organization/OrganizationForm.jsx @@ -4,6 +4,8 @@ import { connect } from 'react-redux' import { Link } from 'react-router-dom' import Mock from 'mockjs' import { SmartTextarea, MembersInput, RParsley } from '../utils' +import RadioList from '../utils/RadioList' +import { FORM } from '../../family/UIConst' // 模拟数据 const mockOrganization = process.env.NODE_ENV === 'development' @@ -67,6 +69,13 @@ class OrganizationForm extends Component {
} +
+ +
+ this.setState({ visibility })} /> +
+
diff --git a/src/components/repository/RepositoryForm.jsx b/src/components/repository/RepositoryForm.jsx index 2d57a85..9a608ff 100644 --- a/src/components/repository/RepositoryForm.jsx +++ b/src/components/repository/RepositoryForm.jsx @@ -5,6 +5,8 @@ import { Link } from 'react-router-dom' import { mock } from 'mockjs' import { SmartTextarea, MembersInput, RParsley } from '../utils' import { GoInfo } from 'react-icons/lib/go' +import RadioList from '../utils/RadioList' +import { FORM } from '../../family/UIConst' // 模拟数据 // DONE 2.1 各种表单的初始值混乱,待重构 @@ -72,6 +74,13 @@ class RepositoryForm extends Component {
} +
+ +
+ this.setState({ visibility })} /> +
+
diff --git a/src/components/utils/RadioList.jsx b/src/components/utils/RadioList.jsx new file mode 100644 index 0000000..e468f52 --- /dev/null +++ b/src/components/utils/RadioList.jsx @@ -0,0 +1,44 @@ +import React from 'react' +import { connect } from 'react-redux' +import './RadioList.css' + +/** + * + * @param {*} props { label : [String], value : [String] } + */ + +class RadioList extends React.Component { + constructor (props) { + super(props) + this.state = { curVal: props.curVal } + } + + handleChange (e) { + this.setState({ curVal: e.target.value === 'true' }) + this.props.onChange(e.target.value) + } + + render () { + let that = this + return ( +
+ { + this.props.data.map(item => + ) + } +
+ ) + } +} + +const mapStateToProps = (state) => ({}) +const mapDispatchToProps = ({}) + +export default connect( + mapStateToProps, + mapDispatchToProps +)(RadioList) diff --git a/src/components/utils/RadioList.sass b/src/components/utils/RadioList.sass new file mode 100644 index 0000000..84f9206 --- /dev/null +++ b/src/components/utils/RadioList.sass @@ -0,0 +1,6 @@ +.ctl-radio-list + line-height: 32px + + .label + .input + margin: 0 6px 0 3px \ No newline at end of file diff --git a/src/family/UIConst.js b/src/family/UIConst.js new file mode 100644 index 0000000..72e759b --- /dev/null +++ b/src/family/UIConst.js @@ -0,0 +1,10 @@ +const CONST = { + FORM: { + RADIO_LIST_DATA_VISIBILITY: [ + { 'label': '私有', 'value': false }, + { 'label': '公开', 'value': true } + ] + } +} + +module.exports = CONST diff --git a/src/relatives/effects/repository.js b/src/relatives/effects/repository.js index eaf4c4f..710e949 100644 --- a/src/relatives/effects/repository.js +++ b/src/relatives/effects/repository.js @@ -44,7 +44,7 @@ export function * deleteRepository (action) { export function * updateRepository (action) { try { let r = action.repository - let acceptedKeys = ['creatorId', 'organizationId', 'memberIds', 'id', 'collaboratorIds', 'description', 'ownerId'] + let acceptedKeys = ['creatorId', 'organizationId', 'memberIds', 'id', 'collaboratorIds', 'description', 'ownerId', 'visibility', 'name'] let params = {} acceptedKeys.forEach(x => { params[x] = r[x]