Commit 93d82e96 by hfpp2012 yinsigan

event bind

1 parent f4edc185
......@@ -24,6 +24,18 @@ export default class Element extends React.Component {
name: this.props.name,
prev_name: this.props.name
};
this.onMouseDown = this.onMouseDown.bind(this);
this.onMouseMove = this.onMouseMove.bind(this);
this.onMouseUp = this.onMouseUp.bind(this);
this.handleCloneElement = this.handleCloneElement.bind(this);
this.handleDeleteLastElement = this.handleDeleteLastElement.bind(this);
this.handleMoveDropZone = this.handleMoveDropZone.bind(this);
this.handleClick = this.handleClick.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleBlur = this.handleBlur.bind(this);
this.handleKeyPress = this.handleKeyPress.bind(this);
this.handleUpdateName = this.handleUpdateName.bind(this);
this.handleDoubleClick = this.handleDoubleClick.bind(this);
}
componentDidUpdate(props, state) {
......
......@@ -12,6 +12,9 @@ export default class ElementGroup extends React.Component {
{ id: 3, name: "药架格", initialPos: {x: 80, y: 70 + 60 * 2}, target_type: 'RegionalDesign::DrugBrandreth' }
]
};
this.cloneElement = this.cloneElement.bind(this);
this.deleteElement = this.deleteElement.bind(this);
this.deleteLastElement = this.deleteLastElement.bind(this);
}
cloneElement(element) {
......@@ -22,13 +25,13 @@ export default class ElementGroup extends React.Component {
deleteElement(element) {
const index = this.state.elements.indexOf(element)
const elements = ReactAddonsUpdate(this.state.elements, { $splice: [[index, 1]] })
this.replaceState({elements: elements})
this.setState({elements: elements})
}
// 返回element的index为-1, 删除最后一个元素
deleteLastElement() {
const elements = ReactAddonsUpdate(this.state.elements, { $splice: [[-1, 1]] })
this.replaceState({elements: elements})
this.setState({elements: elements})
}
sidebar() {
......
......@@ -10,6 +10,7 @@ export default class Header extends React.Component {
this.state = {
data: null, loading: true, error: null
};
this.addRepo = this.addRepo.bind(this);
}
componentDidMount() {
......@@ -20,7 +21,7 @@ export default class Header extends React.Component {
}
addRepo(repo) {
const data = ReactAddonsUpdate(this.state.data, { $push: [repo] })
let data = ReactAddonsUpdate(this.state.data, { $push: [repo] })
this.setState({ data: data })
}
......@@ -33,8 +34,8 @@ export default class Header extends React.Component {
result = <span>Error: {this.state.error.message}</span>;
}
else {
let data = this.state.data.map((repo) => {
let url = `/regional_design/${repo.id}?object=repo`
const data = this.state.data.map((repo) => {
const url = `/regional_design/${repo.id}?object=repo`
return (
<Link key={ repo.id } className='btn btn-default mr15' to={ url }>{ repo.name }</Link>
)
......
......@@ -10,6 +10,9 @@ export default class ModalRepoForm extends React.Component {
this.state = {
showModal: false, name: ''
};
this.close = this.close.bind(this);
this.open = this.open.bind(this);
this.handleChange = this.handleChange.bind(this);
}
close() {
......
......@@ -11,6 +11,9 @@ export default class RegionalDesign extends React.Component {
this.state = {
data: null, loading: true, error: null, object_name: '', object_type: '', children_object_type: ''
};
this.addElement = this.addElement.bind(this);
this.updateElement = this.updateElement.bind(this);
this.addElement = this.addElement.bind(this);
}
getConfig(props, key) {
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>React App Setup</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">
<style>
.meta-element {
border: 1px solid #eee;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!