mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-13 06:32:39 +00:00
newPage is now working, working on editpage
This commit is contained in:
@@ -19,15 +19,32 @@ const Actions = {
|
||||
|
||||
|
||||
|
||||
save : () => {
|
||||
const brew = Store.getBrew();
|
||||
dispatch('SET_STATUS', 'saving');
|
||||
request
|
||||
.put('/api/update/' + brew.editId)
|
||||
.send(brew)
|
||||
.end((err, res) => {
|
||||
if(err) return dispatch('SET_STATUS', 'error', err);
|
||||
dispatch('SET_STATUS', 'ready');
|
||||
dispatch('SET_BREW', res.body);
|
||||
});
|
||||
},
|
||||
|
||||
saveNew : () => {
|
||||
//TODO: Maybe set the status?
|
||||
dispatch('SET_STATUS', 'saving');
|
||||
request.post('/api')
|
||||
.send(Store.getBrew())
|
||||
.end((err, res)=>{
|
||||
if(err) return;
|
||||
if(err) return dispatch('SET_STATUS', 'error', err);
|
||||
const brew = res.body;
|
||||
window.location = '/edit/' + brew.editId;
|
||||
});
|
||||
},
|
||||
localPrint : ()=>{
|
||||
localStorage.setItem('print', Store.getBrewText());
|
||||
window.open('/print?dialog=true&local=print','_blank');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ let State = {
|
||||
systems : []
|
||||
},
|
||||
|
||||
errors : []
|
||||
errors : [],
|
||||
status : 'ready', //ready, pending, saving, error
|
||||
};
|
||||
|
||||
const Store = flux.createStore({
|
||||
@@ -34,6 +35,10 @@ const Store = flux.createStore({
|
||||
},
|
||||
UPDATE_META : (meta) => {
|
||||
State.brew = _.merge({}, State.brew, meta);
|
||||
},
|
||||
SET_STATUS : (status, error) => {
|
||||
State.status = status;
|
||||
if(error) State.errors = error;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -53,9 +58,12 @@ Store.getMetaData = ()=>{
|
||||
Store.getErrors = ()=>{
|
||||
return State.errors;
|
||||
};
|
||||
|
||||
Store.getVersion = ()=>{
|
||||
return State.version;
|
||||
};
|
||||
Store.getStatus = ()=>{
|
||||
return State.status;
|
||||
};
|
||||
|
||||
|
||||
module.exports = Store;
|
||||
@@ -66,6 +66,11 @@ const BrewEditor = React.createClass({
|
||||
})
|
||||
},
|
||||
|
||||
brewJump : function(){
|
||||
const currentPage = this.getCurrentPage();
|
||||
window.location.hash = 'p' + currentPage;
|
||||
},
|
||||
|
||||
//Called when there are changes to the editor's dimensions
|
||||
update : function(){
|
||||
this.refs.codeEditor.updateSize();
|
||||
@@ -113,6 +118,12 @@ const BrewEditor = React.createClass({
|
||||
onChange={this.handleTextChange}
|
||||
onCursorActivity={this.handleCursorActivty} />
|
||||
</div>
|
||||
|
||||
{/*
|
||||
<div className='brewJump' onClick={this.brewJump}>
|
||||
<i className='fa fa-arrow-right' />
|
||||
</div>
|
||||
*/}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,8 +5,23 @@
|
||||
.codeEditor{
|
||||
height : 100%;
|
||||
.pageLine{
|
||||
background-color : fade(#333, 30%);
|
||||
background-color : fade(#333, 15%);
|
||||
border-bottom : #333 solid 1px;
|
||||
}
|
||||
}
|
||||
|
||||
.brewJump{
|
||||
position: absolute;
|
||||
background-color: @teal;
|
||||
cursor: pointer;
|
||||
width : 30px;
|
||||
height : 30px;
|
||||
display : flex;
|
||||
align-items : center;
|
||||
bottom : 20px;
|
||||
right : 20px;
|
||||
z-index: 1000000;
|
||||
justify-content:center;
|
||||
.tooltipLeft("Jump to brew page");
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ const cx = require('classnames');
|
||||
const Markdown = require('homebrewery/markdown.js');
|
||||
const ErrorBar = require('./errorBar/errorBar.jsx');
|
||||
|
||||
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx')
|
||||
const Store = require('homebrewery/brew.store.js');
|
||||
|
||||
|
||||
@@ -130,6 +131,7 @@ const BrewRenderer = React.createClass({
|
||||
style={{height : this.state.height}}>
|
||||
|
||||
<ErrorBar errors={this.props.errors} />
|
||||
<RenderWarnings />
|
||||
|
||||
<div className='pages' ref='pages'>
|
||||
{this.renderPages()}
|
||||
|
||||
20
shared/homebrewery/utils.js
Normal file
20
shared/homebrewery/utils.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const _ = require('lodash');
|
||||
|
||||
|
||||
const Utils = {
|
||||
controlKeys : (mapping) => {
|
||||
return (e) => {
|
||||
if(!(e.ctrlKey || e.metaKey)) return;
|
||||
if(typeof mapping[e.key] === 'function'){
|
||||
mapping[e.key]();
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
module.exports = Utils;
|
||||
Reference in New Issue
Block a user