0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 21:52:43 +00:00
This commit is contained in:
Scott Tolksdorf
2018-04-08 22:23:03 -04:00
parent bf27250990
commit ed1b5252be
51 changed files with 2837 additions and 2852 deletions

View File

@@ -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({
<input
type='checkbox'
checked={_.includes(this.props.metadata.systems, val)}
onChange={this.handleSystem.bind(null, val)} />
onChange={()=>this.handleSystem(val)} />
{val}
</label>
</label>;
});
},
renderPublish : function(){
if(this.props.metadata.published){
return <button className='unpublish' onClick={this.handlePublish.bind(null, false)}>
return <button className='unpublish' onClick={()=>this.handlePublish(false)}>
<i className='fa fa-ban' /> unpublish
</button>
}else{
return <button className='publish' onClick={this.handlePublish.bind(null, true)}>
</button>;
} else {
return <button className='publish' onClick={()=>this.handlePublish(true)}>
<i className='fa fa-globe' /> publish
</button>
</button>;
}
},
@@ -95,7 +95,7 @@ const MetadataEditor = React.createClass({
<i className='fa fa-trash' /> delete brew
</button>
</div>
</div>
</div>;
},
renderAuthors : function(){
@@ -108,7 +108,7 @@ const MetadataEditor = React.createClass({
<div className='value'>
{text}
</div>
</div>
</div>;
},
renderShareToReddit : function(){
@@ -123,7 +123,7 @@ const MetadataEditor = React.createClass({
</button>
</a>
</div>
</div>
</div>;
},
render : function(){
@@ -132,18 +132,18 @@ const MetadataEditor = React.createClass({
<label>title</label>
<input type='text' className='value'
value={this.props.metadata.title}
onChange={this.handleFieldChange.bind(null, 'title')} />
onChange={()=>this.handleFieldChange('title')} />
</div>
<div className='field description'>
<label>description</label>
<textarea value={this.props.metadata.description} className='value'
onChange={this.handleFieldChange.bind(null, 'description')} />
onChange={()=>this.handleFieldChange('description')} />
</div>
{/*}
<div className='field tags'>
<label>tags</label>
<textarea value={this.props.metadata.tags}
onChange={this.handleFieldChange.bind(null, 'tags')} />
onChange={()=>this.handleFieldChange('tags')} />
</div>
*/}
@@ -168,7 +168,7 @@ const MetadataEditor = React.createClass({
{this.renderDelete()}
</div>
</div>;
}
});