mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 04:02:44 +00:00
add simple toggle to 'save status' field for auto-save
This commit is contained in:
@@ -62,7 +62,8 @@ const EditPage = createClass({
|
|||||||
confirmGoogleTransfer : false,
|
confirmGoogleTransfer : false,
|
||||||
errors : null,
|
errors : null,
|
||||||
htmlErrors : Markdown.validate(this.props.brew.text),
|
htmlErrors : Markdown.validate(this.props.brew.text),
|
||||||
url : ''
|
url : '',
|
||||||
|
autoSave : true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
savedBrew : null,
|
savedBrew : null,
|
||||||
@@ -142,7 +143,12 @@ const EditPage = createClass({
|
|||||||
return !_.isEqual(this.state.brew, this.savedBrew);
|
return !_.isEqual(this.state.brew, this.savedBrew);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleAutoSave : function(){
|
||||||
|
this.setState((prevState)=>({ autoSave: !prevState.autoSave }));
|
||||||
|
},
|
||||||
|
|
||||||
trySave : function(){
|
trySave : function(){
|
||||||
|
if(!this.state.autoSave){ console.log('Auto-save is now off.'); return };
|
||||||
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
|
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
|
||||||
if(this.hasChanges()){
|
if(this.hasChanges()){
|
||||||
this.debounceSave();
|
this.debounceSave();
|
||||||
@@ -336,7 +342,7 @@ const EditPage = createClass({
|
|||||||
return <Nav.item className='save' onClick={this.save} color='blue' icon='fas fa-save'>Save Now</Nav.item>;
|
return <Nav.item className='save' onClick={this.save} color='blue' icon='fas fa-save'>Save Now</Nav.item>;
|
||||||
}
|
}
|
||||||
if(!this.state.isPending && !this.state.isSaving){
|
if(!this.state.isPending && !this.state.isSaving){
|
||||||
return <Nav.item className='save saved'>saved.</Nav.item>;
|
return <Nav.item className='save saved' onClick={this.toggleAutoSave}>{this.state.autoSave ? `saved.` : `auto-save off`}</Nav.item>;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user