|
@@ -2,19 +2,27 @@ var React = require('react'),
|
|
|
ReactDOM = require('react-dom'),
|
|
ReactDOM = require('react-dom'),
|
|
|
classNames = require('classnames'),
|
|
classNames = require('classnames'),
|
|
|
Core = require('./core.js').Core,
|
|
Core = require('./core.js').Core,
|
|
|
- NewThing = require('./NewThing.js'),
|
|
|
|
|
|
|
+ ThingModal = require('./ThingModal.js'),
|
|
|
ThingList = require('./ThingList.js'),
|
|
ThingList = require('./ThingList.js'),
|
|
|
- BootstrapButton = require('./BootstrapButton.js'),
|
|
|
|
|
SearchBox = require('./SearchBox.js');
|
|
SearchBox = require('./SearchBox.js');
|
|
|
|
|
|
|
|
var Application = React.createClass({
|
|
var Application = React.createClass({
|
|
|
- openNewThingModal: function () {
|
|
|
|
|
|
|
+ handleThingAdd: function () {
|
|
|
this.refs.modalAdd.openModal();
|
|
this.refs.modalAdd.openModal();
|
|
|
},
|
|
},
|
|
|
|
|
+ handleThingEdit: function (thing) {
|
|
|
|
|
+ this.refs.modalAdd.openModal(thing);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleThingDelete: function (thing) {
|
|
|
|
|
+ console.log('del', thing)
|
|
|
|
|
+ },
|
|
|
getInitialState: function () {
|
|
getInitialState: function () {
|
|
|
return { data: [], busy: false };
|
|
return { data: [], busy: false };
|
|
|
},
|
|
},
|
|
|
componentDidMount: function () {
|
|
componentDidMount: function () {
|
|
|
|
|
+ this.refresh();
|
|
|
|
|
+ },
|
|
|
|
|
+ refresh: function () {
|
|
|
var that = this;
|
|
var that = this;
|
|
|
|
|
|
|
|
that.setState({ data: [], busy: true });
|
|
that.setState({ data: [], busy: true });
|
|
@@ -25,16 +33,16 @@ var Application = React.createClass({
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
render: function () {
|
|
render: function () {
|
|
|
- var things = this.state.busy ? <center><i className="spinner"></i></center> : <ThingList data={this.state.data}/>;
|
|
|
|
|
|
|
+ var things = this.state.busy ? <center><i className="spinner"></i></center> : <ThingList data={this.state.data} onEdit={this.handleThingEdit} onDelete={this.handleThingDelete}/>;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
|
- <NewThing ref="modalAdd"/>
|
|
|
|
|
|
|
+ <ThingModal ref="modalAdd" onAdded={this.refresh} onUpdated={this.refresh}/>
|
|
|
<div className="container">
|
|
<div className="container">
|
|
|
<div className="row">
|
|
<div className="row">
|
|
|
<div className="col-md-4"></div>
|
|
<div className="col-md-4"></div>
|
|
|
<div className="col-md-4">
|
|
<div className="col-md-4">
|
|
|
- <BootstrapButton className="btn-success btn-block" onClick={this.openNewThingModal}>Add</BootstrapButton>
|
|
|
|
|
|
|
+ <button role="button" className="btn btn-success btn-block" onClick={this.handleThingAdd}>Add</button>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="col-md-4"></div>
|
|
<div className="col-md-4"></div>
|
|
|
</div>
|
|
</div>
|