diff --git a/client/admin/admin.jsx b/client/admin/admin.jsx index 4fd8d55..5d581a8 100644 --- a/client/admin/admin.jsx +++ b/client/admin/admin.jsx @@ -1,39 +1,38 @@ -var React = require('react'); -var _ = require('lodash'); -var cx = require('classnames'); - -var HomebrewAdmin = require('./homebrewAdmin/homebrewAdmin.jsx'); - -var Admin = React.createClass({ - getDefaultProps: function() { - return { - url : "", - admin_key : "", - homebrews : [], - }; - }, - - render : function(){ - var self = this; - return( -
- -
-
- - naturalcrit admin -
-
- -
- - -
- - -
- ); - } -}); - -module.exports = Admin; +const React = require('react'); +const _ = require('lodash'); +const cx = require('classnames'); + +const HomebrewAdmin = require('./homebrewAdmin/homebrewAdmin.jsx'); + +const Admin = React.createClass({ + getDefaultProps : function() { + return { + url : '', + admin_key : '', + homebrews : [], + }; + }, + + render : function(){ + return ( +
+ +
+
+ + naturalcrit admin +
+
+ +
+ + +
+ + +
+ ); + } +}); + +module.exports = Admin; diff --git a/client/admin/homebrewAdmin/brewLookup/brewLookup.jsx b/client/admin/homebrewAdmin/brewLookup/brewLookup.jsx index ad43b13..1c1e817 100644 --- a/client/admin/homebrewAdmin/brewLookup/brewLookup.jsx +++ b/client/admin/homebrewAdmin/brewLookup/brewLookup.jsx @@ -7,35 +7,35 @@ const Moment = require('moment'); const BrewLookup = React.createClass({ - getDefaultProps: function() { + getDefaultProps : function() { return { adminKey : '', }; }, - getInitialState: function() { + getInitialState : function() { return { - query:'', + query : '', resultBrew : null, - searching : false + searching : false }; }, handleChange : function(e){ this.setState({ query : e.target.value - }) + }); }, lookup : function(){ - this.setState({ searching : true }); + this.setState({ searching: true }); request.get(`/admin/lookup/${this.state.query}`) - .query({ admin_key : this.props.adminKey }) - .end((err, res) => { + .query({ admin_key: this.props.adminKey }) + .end((err, res)=>{ this.setState({ - searching : false, + searching : false, resultBrew : (err ? null : res.body) }); - }) + }); }, renderFoundBrew : function(){ @@ -46,21 +46,21 @@ const BrewLookup = React.createClass({ return
{brew.title}
{brew.authors.join(', ')}
-
/edit/{brew.editId}
-
/share/{brew.shareId}
+
/edit/{brew.editId}
+
/share/{brew.shareId}
{Moment(brew.updatedAt).fromNow()}
{brew.views}
-
+ ; }, - render: function(){ + render : function(){ return

Brew Lookup

{this.renderFoundBrew()} -
+ ; } }); diff --git a/client/admin/homebrewAdmin/brewSearch.jsx b/client/admin/homebrewAdmin/brewSearch.jsx index f2334d7..7daeed1 100644 --- a/client/admin/homebrewAdmin/brewSearch.jsx +++ b/client/admin/homebrewAdmin/brewSearch.jsx @@ -1,72 +1,72 @@ -var React = require('react'); -var _ = require('lodash'); -var cx = require('classnames'); - -var request = require('superagent'); - -var BrewSearch = React.createClass({ - - getDefaultProps: function() { - return { - admin_key : '' - }; - }, - - getInitialState: function() { - return { - searchTerm: '', - brew : null, - searching : false - }; - }, - - - search : function(){ - this.setState({ - searching : true - }); - - request.get('/homebrew/api/search?id=' + this.state.searchTerm) - .query({ - admin_key : this.props.admin_key, - }) - .end((err, res)=>{ - console.log(err, res, res.body.brews[0]); - this.setState({ - brew : res.body.brews[0], - - searching : false - }) - }); - }, - - handleChange : function(e){ - this.setState({ - searchTerm : e.target.value - }); - }, - handleSearchClick : function(){ - this.search(); - }, - - renderBrew : function(){ - if(!this.state.brew) return null; - return
-
Edit id : {this.state.brew.editId}
-
Share id : {this.state.brew.shareId}
-
- }, - - render : function(){ - return
- - - - - {this.renderBrew()} -
- }, - -}); - +const React = require('react'); +const _ = require('lodash'); +const cx = require('classnames'); + +const request = require('superagent'); + +const BrewSearch = React.createClass({ + + getDefaultProps : function() { + return { + admin_key : '' + }; + }, + + getInitialState : function() { + return { + searchTerm : '', + brew : null, + searching : false + }; + }, + + + search : function(){ + this.setState({ + searching : true + }); + + request.get(`/homebrew/api/search?id=${this.state.searchTerm}`) + .query({ + admin_key : this.props.admin_key, + }) + .end((err, res)=>{ + console.log(err, res, res.body.brews[0]); + this.setState({ + brew : res.body.brews[0], + + searching : false + }); + }); + }, + + handleChange : function(e){ + this.setState({ + searchTerm : e.target.value + }); + }, + handleSearchClick : function(){ + this.search(); + }, + + renderBrew : function(){ + if(!this.state.brew) return null; + return
+
Edit id : {this.state.brew.editId}
+
Share id : {this.state.brew.shareId}
+
; + }, + + render : function(){ + return
+ + + + + {this.renderBrew()} +
; + }, + +}); + module.exports = BrewSearch; \ No newline at end of file diff --git a/client/admin/homebrewAdmin/homebrewAdmin.jsx b/client/admin/homebrewAdmin/homebrewAdmin.jsx index 70b593c..77257fb 100644 --- a/client/admin/homebrewAdmin/homebrewAdmin.jsx +++ b/client/admin/homebrewAdmin/homebrewAdmin.jsx @@ -1,172 +1,170 @@ -var React = require('react'); -var _ = require('lodash'); -var cx = require('classnames'); -var request = require('superagent'); - -var Moment = require('moment'); - -var BrewSearch = require('./brewSearch.jsx'); - -var BrewLookup = require('./brewLookup/brewLookup.jsx'); - - -var HomebrewAdmin = React.createClass({ - getDefaultProps: function() { - return { - admin_key : '' - }; - }, - - getInitialState: function() { - return { - page: 0, - count : 20, - brewCache : {}, - total : 0, - - processingOldBrews : false - }; - }, - - - fetchBrews : function(page){ - request.get('/api/search') - .query({ - admin_key : this.props.admin_key, - count : this.state.count, - page : page - }) - .end((err, res)=>{ - if(err || !res.body || !res.body.brews) return; - this.state.brewCache[page] = res.body.brews; - this.setState({ - brewCache : this.state.brewCache, - total : res.body.total, - count : res.body.count - }) - }) - }, - - componentDidMount: function() { - this.fetchBrews(this.state.page); - }, - - changePageTo : function(page){ - if(!this.state.brewCache[page]){ - this.fetchBrews(page); - } - this.setState({ - page : page - }) - }, - - - clearInvalidBrews : function(){ - request.get('/api/invalid') - .query({admin_key : this.props.admin_key}) - .end((err, res)=>{ - if(!confirm("This will remove " + res.body.count + " brews. Are you sure?")) return; - request.get('/api/invalid') - .query({admin_key : this.props.admin_key, do_it : true}) - .end((err, res)=>{ - alert("Done!") - }); - }); - }, - - - deleteBrew : function(brewId){ - if(!confirm("Are you sure you want to delete '" + brewId + "'?")) return; - request.get('/api/remove/' + brewId) - .query({admin_key : this.props.admin_key}) - .end(function(err, res){ - window.location.reload(); - }) - }, - - handlePageChange : function(dir){ - this.changePageTo(this.state.page + dir); - }, - - - renderPagnination : function(){ - var outOf; - if(this.state.total){ - outOf = this.state.page + ' / ' + Math.round(this.state.total/this.state.count); - } - return
- - {outOf} - -
- }, - - - renderBrews : function(){ - var brews = this.state.brewCache[this.state.page] || _.times(this.state.count); - return _.map(brews, (brew)=>{ - return - {brew.editId} - {brew.shareId} - {Moment(brew.createdAt).fromNow()} - {Moment(brew.updatedAt).fromNow()} - {Moment(brew.lastViewed).fromNow()} - {brew.views} - -
- -
- - - }); - }, - - renderBrewTable : function(){ - return
- - - - - - - - - - - - - {this.renderBrews()} - -
Edit IdShare IdCreated AtLast UpdatedLast ViewedViews
-
- }, - - render : function(){ - var self = this; - return
- - - - {/* -

- Homebrews - {this.state.total} -

- - - - - - {this.renderPagnination()} - {this.renderBrewTable()} - - - - - */} -
- } -}); - -module.exports = HomebrewAdmin; +const React = require('react'); +const _ = require('lodash'); +const cx = require('classnames'); +const request = require('superagent'); + +const Moment = require('moment'); + + +const BrewLookup = require('./brewLookup/brewLookup.jsx'); + + +const HomebrewAdmin = React.createClass({ + getDefaultProps : function() { + return { + admin_key : '' + }; + }, + + getInitialState : function() { + return { + page : 0, + count : 20, + brewCache : {}, + total : 0, + + processingOldBrews : false + }; + }, + + + fetchBrews : function(page){ + request.get('/api/search') + .query({ + admin_key : this.props.admin_key, + count : this.state.count, + page : page + }) + .end((err, res)=>{ + if(err || !res.body || !res.body.brews) return; + this.state.brewCache[page] = res.body.brews; + this.setState({ + brewCache : this.state.brewCache, + total : res.body.total, + count : res.body.count + }); + }); + }, + + componentDidMount : function() { + this.fetchBrews(this.state.page); + }, + + changePageTo : function(page){ + if(!this.state.brewCache[page]){ + this.fetchBrews(page); + } + this.setState({ + page : page + }); + }, + + + clearInvalidBrews : function(){ + request.get('/api/invalid') + .query({ admin_key: this.props.admin_key }) + .end((err, res)=>{ + if(!confirm(`This will remove ${res.body.count} brews. Are you sure?`)) return; + request.get('/api/invalid') + .query({ admin_key: this.props.admin_key, do_it: true }) + .end((err, res)=>{ + alert('Done!'); + }); + }); + }, + + + deleteBrew : function(brewId){ + if(!confirm(`Are you sure you want to delete '${brewId}'?`)) return; + request.get(`/api/remove/${brewId}`) + .query({ admin_key: this.props.admin_key }) + .end(function(err, res){ + window.location.reload(); + }); + }, + + handlePageChange : function(dir){ + this.changePageTo(this.state.page + dir); + }, + + + renderPagnination : function(){ + let outOf; + if(this.state.total){ + outOf = `${this.state.page} / ${Math.round(this.state.total/this.state.count)}`; + } + return
+ this.handlePageChange(-1)}/> + {outOf} + this.handlePageChange(1)}/> +
; + }, + + + renderBrews : function(){ + const brews = this.state.brewCache[this.state.page] || _.times(this.state.count); + return _.map(brews, (brew)=>{ + return + {brew.editId} + {brew.shareId} + {Moment(brew.createdAt).fromNow()} + {Moment(brew.updatedAt).fromNow()} + {Moment(brew.lastViewed).fromNow()} + {brew.views} + +
this.deleteBrew(brew.editId)}> + +
+ + ; + }); + }, + + renderBrewTable : function(){ + return
+ + + + + + + + + + + + + {this.renderBrews()} + +
Edit IdShare IdCreated AtLast UpdatedLast ViewedViews
+
; + }, + + render : function(){ + return
+ + + + {/* +

+ Homebrews - {this.state.total} +

+ + + + + + {this.renderPagnination()} + {this.renderBrewTable()} + + + + + */} +
; + } +}); + +module.exports = HomebrewAdmin; diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index d67c82e..5504cd6 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -6,54 +6,54 @@ const Markdown = require('naturalcrit/markdown.js'); const ErrorBar = require('./errorBar/errorBar.jsx'); //TODO: move to the brew renderer -const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx') +const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx'); const PAGE_HEIGHT = 1056; const PPR_THRESHOLD = 50; const BrewRenderer = React.createClass({ - getDefaultProps: function() { + getDefaultProps : function() { return { - text : '', + text : '', errors : [] }; }, - getInitialState: function() { + getInitialState : function() { const pages = this.props.text.split('\\page'); return { - viewablePageNumber: 0, - height : 0, - isMounted : false, + viewablePageNumber : 0, + height : 0, + isMounted : false, usePPR : true, - pages : pages, + pages : pages, usePPR : pages.length >= PPR_THRESHOLD, errors : [] }; }, - height : 0, + height : 0, pageHeight : PAGE_HEIGHT, lastRender :
, - componentDidMount: function() { + componentDidMount : function() { this.updateSize(); - window.addEventListener("resize", this.updateSize); + window.addEventListener('resize', this.updateSize); }, - componentWillUnmount: function() { - window.removeEventListener("resize", this.updateSize); + componentWillUnmount : function() { + window.removeEventListener('resize', this.updateSize); }, - componentWillReceiveProps: function(nextProps) { + componentWillReceiveProps : function(nextProps) { if(this.refs.pages && this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight; const pages = nextProps.text.split('\\page'); this.setState({ - pages : pages, + pages : pages, usePPR : pages.length >= PPR_THRESHOLD - }) + }); }, updateSize : function() { @@ -62,7 +62,7 @@ const BrewRenderer = React.createClass({ }, 1); this.setState({ - height : this.refs.main.parentNode.clientHeight, + height : this.refs.main.parentNode.clientHeight, isMounted : true }); }, @@ -76,7 +76,7 @@ const BrewRenderer = React.createClass({ shouldRender : function(pageText, index){ if(!this.state.isMounted) return false; - var viewIndex = this.state.viewablePageNumber; + const viewIndex = this.state.viewablePageNumber; if(index == viewIndex - 3) return true; if(index == viewIndex - 2) return true; if(index == viewIndex - 1) return true; @@ -94,7 +94,7 @@ const BrewRenderer = React.createClass({ renderPageInfo : function(){ return
{this.state.viewablePageNumber + 1} / {this.state.pages.length} -
+ ; }, renderPPRmsg : function(){ @@ -102,17 +102,17 @@ const BrewRenderer = React.createClass({ return
Partial Page Renderer enabled, because your brew is so large. May effect rendering. -
+ ; }, renderDummyPage : function(index){ return
-
+ ; }, renderPage : function(pageText, index){ - return
+ return
; }, renderPages : function(){ @@ -120,7 +120,7 @@ const BrewRenderer = React.createClass({ return _.map(this.state.pages, (page, index)=>{ if(this.shouldRender(page, index)){ return this.renderPage(page, index); - }else{ + } else { return this.renderDummyPage(index); } }); @@ -136,7 +136,7 @@ const BrewRenderer = React.createClass({ return
+ style={{ height: this.state.height }}> @@ -146,7 +146,7 @@ const BrewRenderer = React.createClass({
{this.renderPageInfo()} {this.renderPPRmsg()} -
+
; } }); diff --git a/client/homebrew/brewRenderer/errorBar/errorBar.jsx b/client/homebrew/brewRenderer/errorBar/errorBar.jsx index e9ff189..8c2e396 100644 --- a/client/homebrew/brewRenderer/errorBar/errorBar.jsx +++ b/client/homebrew/brewRenderer/errorBar/errorBar.jsx @@ -1,15 +1,15 @@ -var React = require('react'); -var _ = require('lodash'); -var cx = require('classnames'); +const React = require('react'); +const _ = require('lodash'); +const cx = require('classnames'); -var ErrorBar = React.createClass({ - getDefaultProps: function() { +const ErrorBar = React.createClass({ + getDefaultProps : function() { return { errors : [] }; }, - hasOpenError : false, + hasOpenError : false, hasCloseError : false, hasMatchError : false, @@ -19,20 +19,20 @@ var ErrorBar = React.createClass({ this.hasMatchError = false; - var errors = _.map(this.props.errors, (err, idx) => { + const errors = _.map(this.props.errors, (err, idx)=>{ if(err.id == 'OPEN') this.hasOpenError = true; if(err.id == 'CLOSE') this.hasCloseError = true; if(err.id == 'MISMATCH') this.hasMatchError = true; return
  • Line {err.line} : {err.text}, '{err.type}' tag -
  • + ; }); - return
      {errors}
    + return
      {errors}
    ; }, renderProtip : function(){ - var msg = []; + const msg = []; if(this.hasOpenError){ msg.push(
    An unmatched opening tag means there's an opened tag that isn't closed, you need to close a tag, like this {'
    '}. Make sure to match types! @@ -53,7 +53,7 @@ var ErrorBar = React.createClass({ return

    Protips!

    {msg} -
    + ; }, render : function(){ @@ -66,7 +66,7 @@ var ErrorBar = React.createClass({ {this.renderErrors()}
    {this.renderProtip()} - + ; } }); diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 2f79078..1351efd 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -1,145 +1,145 @@ -const React = require('react'); -const _ = require('lodash'); -const cx = require('classnames'); - -const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx'); -const SnippetBar = require('./snippetbar/snippetbar.jsx'); -const MetadataEditor = require('./metadataEditor/metadataEditor.jsx'); - - -const splice = function(str, index, inject){ - return str.slice(0, index) + inject + str.slice(index); -}; - -const SNIPPETBAR_HEIGHT = 25; - -const Editor = React.createClass({ - getDefaultProps: function() { - return { - value : '', - onChange : ()=>{}, - - metadata : {}, - onMetadataChange : ()=>{}, - }; - }, - getInitialState: function() { - return { - showMetadataEditor: false - }; - }, - cursorPosition : { - line : 0, - ch : 0 - }, - - componentDidMount: function() { - this.updateEditorSize(); - this.highlightPageLines(); - window.addEventListener("resize", this.updateEditorSize); - }, - componentWillUnmount: function() { - window.removeEventListener("resize", this.updateEditorSize); - }, - - updateEditorSize : function() { - let paneHeight = this.refs.main.parentNode.clientHeight; - paneHeight -= SNIPPETBAR_HEIGHT + 1; - this.refs.codeEditor.codeMirror.setSize(null, paneHeight); - }, - - handleTextChange : function(text){ - this.props.onChange(text); - }, - handleCursorActivty : function(curpos){ - this.cursorPosition = curpos; - }, - handleInject : function(injectText){ - const lines = this.props.value.split('\n'); - lines[this.cursorPosition.line] = splice(lines[this.cursorPosition.line], this.cursorPosition.ch, injectText); - - this.handleTextChange(lines.join('\n')); - this.refs.codeEditor.setCursorPosition(this.cursorPosition.line, this.cursorPosition.ch + injectText.length); - }, - handgleToggle : function(){ - this.setState({ - showMetadataEditor : !this.state.showMetadataEditor - }) - }, - - getCurrentPage : function(){ - const lines = this.props.value.split('\n').slice(0, this.cursorPosition.line + 1); - return _.reduce(lines, (r, line) => { - if(line.indexOf('\\page') !== -1) r++; - return r; - }, 1); - }, - - highlightPageLines : function(){ - if(!this.refs.codeEditor) return; - const codeMirror = this.refs.codeEditor.codeMirror; - - const lineNumbers = _.reduce(this.props.value.split('\n'), (r, line, lineNumber)=>{ - if(line.indexOf('\\page') !== -1){ - codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - r.push(lineNumber); - } - return r; - }, []); - return lineNumbers - }, - - - 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(); - }, - - renderMetadataEditor : function(){ - if(!this.state.showMetadataEditor) return; - return - }, - - render : function(){ - this.highlightPageLines(); - return( -
    - - {this.renderMetadataEditor()} - - - {/* -
    - -
    - */} -
    - ); - } -}); - -module.exports = Editor; - - - - - - +const React = require('react'); +const _ = require('lodash'); +const cx = require('classnames'); + +const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx'); +const SnippetBar = require('./snippetbar/snippetbar.jsx'); +const MetadataEditor = require('./metadataEditor/metadataEditor.jsx'); + + +const splice = function(str, index, inject){ + return str.slice(0, index) + inject + str.slice(index); +}; + +const SNIPPETBAR_HEIGHT = 25; + +const Editor = React.createClass({ + getDefaultProps : function() { + return { + value : '', + onChange : ()=>{}, + + metadata : {}, + onMetadataChange : ()=>{}, + }; + }, + getInitialState : function() { + return { + showMetadataEditor : false + }; + }, + cursorPosition : { + line : 0, + ch : 0 + }, + + componentDidMount : function() { + this.updateEditorSize(); + this.highlightPageLines(); + window.addEventListener('resize', this.updateEditorSize); + }, + componentWillUnmount : function() { + window.removeEventListener('resize', this.updateEditorSize); + }, + + updateEditorSize : function() { + let paneHeight = this.refs.main.parentNode.clientHeight; + paneHeight -= SNIPPETBAR_HEIGHT + 1; + this.refs.codeEditor.codeMirror.setSize(null, paneHeight); + }, + + handleTextChange : function(text){ + this.props.onChange(text); + }, + handleCursorActivty : function(curpos){ + this.cursorPosition = curpos; + }, + handleInject : function(injectText){ + const lines = this.props.value.split('\n'); + lines[this.cursorPosition.line] = splice(lines[this.cursorPosition.line], this.cursorPosition.ch, injectText); + + this.handleTextChange(lines.join('\n')); + this.refs.codeEditor.setCursorPosition(this.cursorPosition.line, this.cursorPosition.ch + injectText.length); + }, + handgleToggle : function(){ + this.setState({ + showMetadataEditor : !this.state.showMetadataEditor + }); + }, + + getCurrentPage : function(){ + const lines = this.props.value.split('\n').slice(0, this.cursorPosition.line + 1); + return _.reduce(lines, (r, line)=>{ + if(line.indexOf('\\page') !== -1) r++; + return r; + }, 1); + }, + + highlightPageLines : function(){ + if(!this.refs.codeEditor) return; + const codeMirror = this.refs.codeEditor.codeMirror; + + const lineNumbers = _.reduce(this.props.value.split('\n'), (r, line, lineNumber)=>{ + if(line.indexOf('\\page') !== -1){ + codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); + r.push(lineNumber); + } + return r; + }, []); + return lineNumbers; + }, + + + 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(); + }, + + renderMetadataEditor : function(){ + if(!this.state.showMetadataEditor) return; + return ; + }, + + render : function(){ + this.highlightPageLines(); + return ( +
    + + {this.renderMetadataEditor()} + + + {/* +
    + +
    + */} +
    + ); + } +}); + +module.exports = Editor; + + + + + + diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx index 694e9db..f1b5bfb 100644 --- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx +++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx @@ -1,21 +1,21 @@ const React = require('react'); const _ = require('lodash'); const cx = require('classnames'); -const request = require("superagent"); +const request = require('superagent'); -const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'] +const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder']; const MetadataEditor = React.createClass({ - getDefaultProps: function() { + getDefaultProps : function() { return { - metadata: { - editId : null, - title : '', + metadata : { + editId : null, + title : '', description : '', - tags : '', - published : false, - authors : [], - systems : [] + tags : '', + published : false, + authors : [], + systems : [] }, onChange : ()=>{} }; @@ -24,12 +24,12 @@ const MetadataEditor = React.createClass({ handleFieldChange : function(name, e){ this.props.onChange(_.merge({}, this.props.metadata, { [name] : e.target.value - })) + })); }, handleSystem : function(system, e){ if(e.target.checked){ this.props.metadata.systems.push(system); - }else{ + } else { this.props.metadata.systems = _.without(this.props.metadata.systems, system); } this.props.onChange(this.props.metadata); @@ -41,10 +41,10 @@ const MetadataEditor = React.createClass({ }, handleDelete : function(){ - if(!confirm("are you sure you want to delete this brew?")) return; - if(!confirm("are you REALLY sure? You will not be able to recover it")) return; + if(!confirm('are you sure you want to delete this brew?')) return; + if(!confirm('are you REALLY sure? You will not be able to recover it')) return; - request.get('/api/remove/' + this.props.metadata.editId) + request.get(`/api/remove/${this.props.metadata.editId}`) .send() .end(function(err, res){ window.location.href = '/'; @@ -67,21 +67,21 @@ const MetadataEditor = React.createClass({ + onChange={()=>this.handleSystem(val)} /> {val} - + ; }); }, renderPublish : function(){ if(this.props.metadata.published){ - return - }else{ - return ; + } else { + return + ; } }, @@ -95,7 +95,7 @@ const MetadataEditor = React.createClass({ delete brew - + ; }, renderAuthors : function(){ @@ -108,7 +108,7 @@ const MetadataEditor = React.createClass({
    {text}
    - + ; }, renderShareToReddit : function(){ @@ -123,7 +123,7 @@ const MetadataEditor = React.createClass({ - + ; }, render : function(){ @@ -132,18 +132,18 @@ const MetadataEditor = React.createClass({ + onChange={()=>this.handleFieldChange('title')} />