mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-13 15:12:43 +00:00
Added new navitems
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
const React = require('react');
|
||||
const _ = require('lodash');
|
||||
|
||||
|
||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||
const Navbar = require('../../navbar/navbar.jsx');
|
||||
const Account = require('../../navbar/account.navitem.jsx');
|
||||
const Issue = require('../../navbar/issue.navitem.jsx');
|
||||
const Save = require('../../navbar/staticSave.navitem.jsx');
|
||||
const Items = require('../../navbar/navitems.js');
|
||||
|
||||
const Store = require('homebrewery/brew.store.js');
|
||||
const Actions = require('homebrewery/brew.actions.js');
|
||||
@@ -14,27 +11,24 @@ const Actions = require('homebrewery/brew.actions.js');
|
||||
const BrewInterface = require('homebrewery/brewInterface/brewInterface.jsx');
|
||||
const Utils = require('homebrewery/utils.js');
|
||||
|
||||
|
||||
const KEY = 'homebrewery-new';
|
||||
|
||||
const NewPage = React.createClass({
|
||||
componentDidMount: function() {
|
||||
const storage = localStorage.getItem(KEY);
|
||||
|
||||
|
||||
//TODO: add a store listener for updates and dump to lcoal storage
|
||||
|
||||
|
||||
if(storage){
|
||||
this.setState({
|
||||
text : storage
|
||||
})
|
||||
}
|
||||
try{
|
||||
Actions.setBrew(JSON.parse(localStorage.getItem(KEY)));
|
||||
}catch(e){}
|
||||
Store.updateEmitter.on('change', this.saveToLocal);
|
||||
document.addEventListener('keydown', this.handleControlKeys);
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
Store.updateEmitter.removeListener('change', this.saveToLocal);
|
||||
document.removeEventListener('keydown', this.handleControlKeys);
|
||||
},
|
||||
|
||||
saveToLocal : function(){
|
||||
localStorage.setItem(KEY, JSON.stringify(Store.getBrew()));
|
||||
},
|
||||
handleControlKeys : Utils.controlKeys({
|
||||
s : Actions.saveNew,
|
||||
p : Actions.localPrint
|
||||
@@ -44,16 +38,16 @@ const NewPage = React.createClass({
|
||||
return <div className='newPage page'>
|
||||
<Navbar>
|
||||
<Nav.section>
|
||||
<Nav.item className='brewTitle'>{Store.getMetaData().title}</Nav.item>
|
||||
<Items.BrewTitle />
|
||||
</Nav.section>
|
||||
|
||||
<Nav.section>
|
||||
<Save />
|
||||
<Items.StaticSave />
|
||||
<Nav.item color='purple' icon='fa-file-pdf-o' onClick={Actions.localPrint}>
|
||||
get PDF
|
||||
</Nav.item>
|
||||
<Issue />
|
||||
<Account />
|
||||
<Items.Issue />
|
||||
<Items.Account />
|
||||
</Nav.section>
|
||||
</Navbar>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user