mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-30 02:22:49 +00:00
Edit and sharing should be working, deploying for testing
This commit is contained in:
@@ -10,14 +10,22 @@ var request = require("superagent");
|
||||
var EditPage = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
text : "",
|
||||
id : null
|
||||
//text : "",
|
||||
pending : false,
|
||||
id : null,
|
||||
entry : {
|
||||
text : "",
|
||||
shareId : null,
|
||||
editId : null,
|
||||
createdAt : null,
|
||||
updatedAt : null,
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
text: this.props.text
|
||||
text: this.props.entry.text
|
||||
};
|
||||
},
|
||||
|
||||
@@ -29,14 +37,37 @@ var EditPage = React.createClass({
|
||||
//Ajax time
|
||||
},
|
||||
|
||||
handleSave : function(){
|
||||
this.setState({
|
||||
pending : true
|
||||
})
|
||||
request
|
||||
.put('/homebrew/update/' + this.props.id)
|
||||
.send({text : this.state.text})
|
||||
.end((err, res) => {
|
||||
|
||||
console.log('err', err);
|
||||
this.setState({
|
||||
pending : false
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
render : function(){
|
||||
var self = this;
|
||||
return(
|
||||
<div className='editPage'>
|
||||
<Editor text={this.state.text} onChange={this.handleTextChange} />
|
||||
<PHB text={this.state.text} />
|
||||
</div>
|
||||
);
|
||||
|
||||
console.log(this.props.entry);
|
||||
|
||||
var temp;
|
||||
if(this.state.pending){
|
||||
temp = <div>processing</div>
|
||||
}
|
||||
|
||||
|
||||
return <div className='editPage'>
|
||||
<button onClick={this.handleSave}>save</button> {temp}
|
||||
<Editor text={this.state.text} onChange={this.handleTextChange} />
|
||||
<PHB text={this.state.text} />
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -13,16 +13,23 @@ var Homebrew = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
url : "",
|
||||
text : ""
|
||||
text : "",
|
||||
entry : {
|
||||
text : "",
|
||||
shareId : null,
|
||||
editId : null,
|
||||
createdAt : null,
|
||||
updatedAt : null,
|
||||
}
|
||||
};
|
||||
},
|
||||
componentWillMount: function() {
|
||||
Router = CreateRouter({
|
||||
'/homebrew/edit/:id' : (args) => {
|
||||
return <EditPage id={args.id} text={this.props.text} />
|
||||
return <EditPage id={args.id} entry={this.props.entry} />
|
||||
},
|
||||
'/homebrew/share/:id' : (args) => {
|
||||
return <SharePage id={args.id} text={this.props.text} />
|
||||
return <SharePage id={args.id} entry={this.props.entry} />
|
||||
},
|
||||
'/homebrew*' : <HomePage />,
|
||||
});
|
||||
|
||||
@@ -2,13 +2,27 @@ var React = require('react');
|
||||
var _ = require('lodash');
|
||||
var cx = require('classnames');
|
||||
|
||||
var PHB = require('../phb/phb.jsx');
|
||||
|
||||
var SharePage = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
id : null,
|
||||
entry : {
|
||||
text : "",
|
||||
shareId : null,
|
||||
editId : null,
|
||||
createdAt : null,
|
||||
updatedAt : null,
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
render : function(){
|
||||
var self = this;
|
||||
console.log(this.props.entry);
|
||||
return(
|
||||
<div className='sharePage'>
|
||||
SharePage Ready!
|
||||
<PHB text={this.props.entry.text} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user