Commit 86007275 by hfpp2012 yinsigan

fix typo

1 parent 0cdbcdba
import React from 'react'
import { Modal, Button } from 'react-bootstrap'
import EventEmitter from '../libs/eventEmitter'
import $ from 'jquery'
import autobind from 'autobind-decorator'
import { observer, inject } from 'mobx-react';
@inject(["modalRepoFormStore"]) @observer
@inject(["modalRepoFormStore"])
@inject(["headerStore"])
@observer
@autobind
export default class ModalRepoForm extends React.Component {
store() {
......@@ -17,7 +17,6 @@ export default class ModalRepoForm extends React.Component {
}
open() {
console.log(this);
this.store().open();
}
......@@ -26,18 +25,7 @@ export default class ModalRepoForm extends React.Component {
}
save(e) {
if (this.refs.name.value.trim().length === 0) {
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')
}
this.store().save(e, this.refs.name, this.props.headerStore)
}
render() {
......
import { observable, useStrict, action } from 'mobx'
import EventEmitter from '../libs/eventEmitter'
import $ from 'jquery'
useStrict(true)
class ModalRepoFormStore {
@observable showNameError = false
@observable showModal = false
@observable name = ''
......@@ -12,14 +15,30 @@ class ModalRepoFormStore {
@action close() {
this.showModal = false
this.name = ""
}
@action handleChange(e) {
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!