1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-15 21:55:57 +00:00

Fixing a distributing problem

This commit is contained in:
Scott Tolksdorf
2016-04-05 23:07:29 -04:00
parent cb5b63429e
commit 62b9400df1
6 changed files with 27 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ var Box = React.createClass({
mixins : [utils], mixins : [utils],
getDefaultProps: function() { getDefaultProps: function() {
return { return {
name : 'box', //name : 'box',
defaultData : {}, defaultData : {},
id : '', id : '',

View File

@@ -41,13 +41,11 @@ var Skill = React.createClass({
val : e.target.value val : e.target.value
}) })
}, },
renderExpert : function(){ renderExpert : function(){
if(this.props.showExpert){ if(this.props.showExpert){
return <input type="radio" className='expertToggle' onChange={this.handleToggleExpert} checked={this.data().expert} /> return <input type="radio" className='expertToggle' onChange={this.handleToggleExpert} checked={this.data().expert} />
} }
}, },
render : function(){ render : function(){
return <div className='skill'> return <div className='skill'>
{this.renderExpert()} {this.renderExpert()}

View File

@@ -16,14 +16,18 @@ module.exports = {
updateData : function(val){ updateData : function(val){
if(typeof this.props.onChange !== 'function') throw "No onChange handler set"; if(typeof this.props.onChange !== 'function') throw "No onChange handler set";
if(_.isObject(val)){ var newVal = val;
//Clone the data if it's an object to avoid mutation bugs
if(_.isObject(val)) newVal = _.extend({}, this.data(), val);
if(this.id()){
this.props.onChange({ this.props.onChange({
[this.id()] : _.extend({}, this.data(), val) [this.id()] : newVal
}); });
}else{ }else{
this.props.onChange({ //If the box has no id, don't add it to the chain
[this.id()] : val this.props.onChange(newVal)
});
} }
} }
} }

View File

@@ -33,7 +33,6 @@ var SheetRenderer = React.createClass({
}) })
}, },
renderSheet : function(){ renderSheet : function(){
try{ try{
var nodes = jsx2json(this.props.code); var nodes = jsx2json(this.props.code);
nodes = _.map(nodes, (node)=>{ nodes = _.map(nodes, (node)=>{
@@ -43,8 +42,6 @@ var SheetRenderer = React.createClass({
} }
return node return node
}) })
return this.renderChildren(nodes); return this.renderChildren(nodes);
}catch(e){ }catch(e){
return <div>Error bruh {e.toString()}</div> return <div>Error bruh {e.toString()}</div>

View File

@@ -16,13 +16,7 @@ var SplatSheet = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {
sheetCode: '', sheetCode: '',
characterData : { characterData : {}
playerInfo : {
name : 'scott',
race : 'human',
class : 'coder'
}
}
}; };
}, },

View File

@@ -187,7 +187,18 @@ var parser = function(tokens){
/*
var test1 = ` var test1 = `
<div test="hey there champ" more_cool=false size=0> <div test="hey there champ" more_cool=false size=0>
<span> <span>
@@ -205,7 +216,10 @@ var test2 = "<div cool=0 same>Hey there!</div>"
var tokens = tokenizer(test1); var tokens = tokenizer(test1);
console.log(test1, '\n---\n', tokens, '---\n', JSON.stringify(parser(tokens), null, ' ')); console.log(test1, '\n---\n', tokens, '---\n', JSON.stringify(parser(tokens), null, ' '));
*/
module.exports = function(input){ module.exports = function(input){
return parser(tokenizer(input)); return parser(tokenizer(input));