mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-27 15:52:39 +00:00
Save button is functional
This commit is contained in:
@@ -2,7 +2,7 @@ var React = require('react');
|
||||
var Nav = require('naturalcrit/nav/nav.jsx');
|
||||
|
||||
module.exports = function(props){
|
||||
return <Nav.item newTab={true} href={'/homebrew/print/' + props.sharedId} color='purple' icon='fa-print'>
|
||||
return <Nav.item newTab={true} href={'/homebrew/print/' + props.shareId} color='purple' icon='fa-print'>
|
||||
print
|
||||
</Nav.item>
|
||||
};
|
||||
@@ -85,7 +85,7 @@ var EditPage = React.createClass({
|
||||
handleTitleChange : function(title){
|
||||
this.setState({
|
||||
title : title,
|
||||
pending : true
|
||||
isPending : true
|
||||
});
|
||||
|
||||
(this.hasChanges() ? this.debounceSave() : this.debounceSave.cancel());
|
||||
@@ -94,7 +94,7 @@ var EditPage = React.createClass({
|
||||
handleTextChange : function(text){
|
||||
this.setState({
|
||||
text : text,
|
||||
pending : true
|
||||
isPending : true
|
||||
});
|
||||
|
||||
(this.hasChanges() ? this.debounceSave() : this.debounceSave.cancel());
|
||||
@@ -125,6 +125,10 @@ var EditPage = React.createClass({
|
||||
save : function(){
|
||||
console.log('saving!');
|
||||
this.debounceSave.cancel();
|
||||
this.setState({
|
||||
isSaving : true
|
||||
});
|
||||
|
||||
request
|
||||
.put('/homebrew/api/update/' + this.props.brew.editId)
|
||||
.send({text : this.state.text})
|
||||
@@ -132,19 +136,28 @@ var EditPage = React.createClass({
|
||||
console.log('done', res.body);
|
||||
this.savedBrew = res.body;
|
||||
this.setState({
|
||||
pending : false,
|
||||
isPending : false,
|
||||
isSaving : false,
|
||||
lastUpdated : res.body.updatedAt
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
renderSaveButton : function(){
|
||||
|
||||
if(this.state.isSaving){
|
||||
|
||||
return <Nav.item icon="fa-spinner fa-spin">saving...</Nav.item>
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(!this.state.isPending && !this.state.isSaving){
|
||||
//saved
|
||||
}else if(this.state.isPending && this.hasChanges()){
|
||||
//save now
|
||||
}else if(this.state.isSaving){
|
||||
//saving
|
||||
return <Nav.item>saved.</Nav.item>
|
||||
}
|
||||
|
||||
if(this.state.isPending && this.hasChanges()){
|
||||
return <Nav.item onClick={this.save} color='blue'>Save Now</Nav.item>
|
||||
}
|
||||
|
||||
},
|
||||
@@ -158,6 +171,8 @@ var EditPage = React.createClass({
|
||||
</Nav.section>
|
||||
|
||||
<Nav.section>
|
||||
{this.renderSaveButton()}
|
||||
|
||||
<Nav.item newTab={true} href={'/homebrew/share/' + this.props.brew.shareId} color='teal' icon='fa-share'>
|
||||
Share
|
||||
</Nav.item>
|
||||
|
||||
@@ -86,7 +86,7 @@ var NewPage = React.createClass({
|
||||
|
||||
renderSaveButton : function(){
|
||||
if(this.state.isSaving){
|
||||
return <Nav.item icon='fa-spinner sa-spin' className='saveButton'>
|
||||
return <Nav.item icon='fa-spinner fa-spin' className='saveButton'>
|
||||
save...
|
||||
</Nav.item>
|
||||
}else{
|
||||
|
||||
@@ -5,6 +5,8 @@ var cx = require('classnames');
|
||||
var Nav = require('naturalcrit/nav/nav.jsx');
|
||||
var Navbar = require('../../navbar/navbar.jsx');
|
||||
|
||||
var PrintLink = require('../../navbar/print.navitem.jsx');
|
||||
|
||||
var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
||||
|
||||
var replaceAll = function(str, find, replace) {
|
||||
@@ -34,9 +36,6 @@ var SharePage = React.createClass({
|
||||
|
||||
|
||||
render : function(){
|
||||
|
||||
console.log('brew', this.props.brew);
|
||||
|
||||
return <div className='sharePage page'>
|
||||
<Navbar>
|
||||
<Nav.section>
|
||||
@@ -44,9 +43,7 @@ var SharePage = React.createClass({
|
||||
</Nav.section>
|
||||
|
||||
<Nav.section>
|
||||
<Nav.item newTab={true} href={'/homebrew/print/' + this.props.brew.sharedId} color='orange' icon='fa-print'>
|
||||
print
|
||||
</Nav.item>
|
||||
<PrintLink shareId={this.props.brew.shareId} />
|
||||
<Nav.item onClick={this.openSourceWindow} color='teal' icon='fa-code'>
|
||||
source
|
||||
</Nav.item>
|
||||
|
||||
Reference in New Issue
Block a user