Commit 86007275 by hfpp2012 yinsigan

fix typo

1 parent 0cdbcdba
import React from 'react' import React from 'react'
import { Modal, Button } from 'react-bootstrap' import { Modal, Button } from 'react-bootstrap'
import EventEmitter from '../libs/eventEmitter'
import $ from 'jquery'
import autobind from 'autobind-decorator' import autobind from 'autobind-decorator'
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
@inject(["modalRepoFormStore"]) @observer @inject(["modalRepoFormStore"])
@inject(["headerStore"])
@observer
@autobind @autobind
export default class ModalRepoForm extends React.Component { export default class ModalRepoForm extends React.Component {
store() { store() {
...@@ -17,7 +17,6 @@ export default class ModalRepoForm extends React.Component { ...@@ -17,7 +17,6 @@ export default class ModalRepoForm extends React.Component {
} }
open() { open() {
console.log(this);
this.store().open(); this.store().open();
} }
...@@ -26,18 +25,7 @@ export default class ModalRepoForm extends React.Component { ...@@ -26,18 +25,7 @@ export default class ModalRepoForm extends React.Component {
} }
save(e) { save(e) {
if (this.refs.name.value.trim().length === 0) { this.store().save(e, this.refs.name, this.props.headerStore)
this.setState({ showNameError: true })
return false
} else {
this.setState({ showNameError: false })
e.preventDefault()
$.post('/regional_design/repos.json', { repo: this.state }, function(data) {
this.props.handleNewRepo(data)
this.setState(this.init_state)
EventEmitter.dispatch('alert', '操作成功')
}.bind(this), 'JSON')
}
} }
render() { render() {
......
import { observable, useStrict, action } from 'mobx' import { observable, useStrict, action } from 'mobx'
import EventEmitter from '../libs/eventEmitter'
import $ from 'jquery'
useStrict(true) useStrict(true)
class ModalRepoFormStore { class ModalRepoFormStore {
@observable showNameError = false
@observable showModal = false @observable showModal = false
@observable name = '' @observable name = ''
...@@ -12,14 +15,30 @@ class ModalRepoFormStore { ...@@ -12,14 +15,30 @@ class ModalRepoFormStore {
@action close() { @action close() {
this.showModal = false this.showModal = false
this.name = ""
} }
@action handleChange(e) { @action handleChange(e) {
this.name = e.target.value this.name = e.target.value
} }
@action save() { addRepo(headerStore, data) {
headerStore.addRepo(data)
}
@action save(e, name, headerStore) {
if (name.value.trim().length === 0) {
this.showNameError = true
return false
} else {
this.showNameError = false
e.preventDefault()
$.post('/regional_design/repos.json', { repo: {name: this.name} }, (data) => {
this.close()
this.addRepo(headerStore, data)
EventEmitter.dispatch('alert', '操作成功')
}, 'JSON')
}
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!