Skip to content

Commit

Permalink
fixed some bugs in five token editors
Browse files Browse the repository at this point in the history
1. fixed the typo of question mark in puncuation editor
2. added type determine statement in 5 token editors
3. added determine statement of the values in length array
  • Loading branch information
KimQ0126 committed Jul 25, 2018
1 parent d829542 commit e21c753
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 19 deletions.
4 changes: 2 additions & 2 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"main.css": "static/css/main.35bdd23a.css",
"main.css.map": "static/css/main.35bdd23a.css.map",
"main.js": "static/js/main.cde7e942.js",
"main.js.map": "static/js/main.cde7e942.js.map"
"main.js": "static/js/main.bb996afb.js",
"main.js.map": "static/js/main.bb996afb.js.map"
}
2 changes: 1 addition & 1 deletion build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="./manifest.json"><link rel="shortcut icon" href="./favicon.ico"><title>React App</title><link href="./static/css/main.35bdd23a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"/><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/><div id="root"></div><script type="text/javascript" src="./static/js/main.cde7e942.js"></script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="./manifest.json"><link rel="shortcut icon" href="./favicon.ico"><title>React App</title><link href="./static/css/main.35bdd23a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"/><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/><div id="root"></div><script type="text/javascript" src="./static/js/main.bb996afb.js"></script></body></html>
2 changes: 1 addition & 1 deletion build/service-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/static/js/main.bb996afb.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion build/static/js/main.cde7e942.js.map

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/LineBreakEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ class LineBreakEditor extends Component {
}

componentWillMount() {
if (this.props.is_new === 0) {
if (this.props.token_data.type === 'linebreak' && this.props.is_new === 0) {
this.setState({
token_data: this.props.token_data,
output: this.props.token_data.is_in_output,
required: this.props.token_data.is_required,
length: this.props.token_data.length[0]
? this.props.token_data.length[0]
: ''
});
} else {
this.resetState();
Expand Down
20 changes: 16 additions & 4 deletions src/components/NumberEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,21 @@ class NumberEditor extends Component {
}

componentWillMount() {
if (this.props.is_new === 0) {
if (this.props.token_data.type === 'number' && this.props.is_new === 0) {
this.setState({
token_data: this.props.token_data,
output: this.props.token_data.is_in_output,
required: this.props.token_data.is_required,
numbers: this.props.token_data.numbers.join(' '),
length1: this.props.token_data.length[0],
length2: this.props.token_data.length[1],
length3: this.props.token_data.length[2],
length1: this.props.token_data.length[0]
? this.props.token_data.length[0]
: '',
length2: this.props.token_data.length[1]
? this.props.token_data.length[1]
: '',
length3: this.props.token_data.length[2]
? this.props.token_data.length[2]
: '',
max: this.props.token_data.maximum,
min: this.props.token_data.minimum
});
Expand Down Expand Up @@ -126,12 +132,18 @@ class NumberEditor extends Component {
} else {
if (this.state.length1 !== '') {
temp['length'][0] = this.state.length1;
} else {
temp['length'][0] = '';
}
if (this.state.length2 !== '') {
temp['length'][1] = this.state.length2;
} else {
temp['length'][1] = '';
}
if (this.state.length3 !== '') {
temp['length'][2] = this.state.length3;
} else {
temp['length'][2] = '';
}
}
temp['type'] = 'number';
Expand Down
7 changes: 5 additions & 2 deletions src/components/PuncEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ class PuncEditor extends Component {
}

componentWillMount() {
if (this.props.is_new === 0) {
if (
this.props.token_data.type === 'punctuation' &&
this.props.is_new === 0
) {
this.setState({
token_data: this.props.token_data,
output: this.props.token_data.is_in_output,
Expand Down Expand Up @@ -184,7 +187,7 @@ class PuncEditor extends Component {
if (this.state.punctuation_comma) allPunct.push(',');
if (this.state.punctuation_period) allPunct.push('.');
if (this.state.punctuation_semicomma) allPunct.push(';');
if (this.state.punctuation_qmark) allPunct.push(')');
if (this.state.punctuation_qmark) allPunct.push('?');
if (this.state.punctuation_tilde) allPunct.push('~');
if (this.state.punctuation_colon) allPunct.push(':');
if (this.state.punctuation_2quote) allPunct.push('"');
Expand Down
2 changes: 1 addition & 1 deletion src/components/ShapeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class ShapeEditor extends Component {
}

componentWillMount() {
if (this.props.is_new === 0) {
if (this.props.token_data.type === 'shape' && this.props.is_new === 0) {
this.setState({
token_data: this.props.token_data,
output: this.props.token_data.is_in_output,
Expand Down
23 changes: 19 additions & 4 deletions src/components/WordEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class WordEditor extends Component {
}

componentWillMount() {
if (this.props.is_new === 0) {
if (this.props.token_data.type === 'word' && this.props.is_new === 0) {
this.setState({
token_data: this.props.token_data,
output: this.props.token_data.is_in_output,
Expand Down Expand Up @@ -238,9 +238,15 @@ class WordEditor extends Component {
this.props.token_data.capitalization.indexOf('mixed') > -1
? true
: false,
length1: this.props.token_data.length[0],
length2: this.props.token_data.length[1],
length3: this.props.token_data.length[2],
length1: this.props.token_data.length[0]
? this.props.token_data.length[0]
: '',
length2: this.props.token_data.length[1]
? this.props.token_data.length[1]
: '',
length3: this.props.token_data.length[2]
? this.props.token_data.length[2]
: '',
prefix: this.props.token_data.prefix,
suffix: this.props.token_data.suffix,
notinvocabulary:
Expand Down Expand Up @@ -282,12 +288,18 @@ class WordEditor extends Component {
} else {
if (this.state.length1 !== '') {
temp['length'][0] = this.state.length1;
} else {
temp['length'][0] = '';
}
if (this.state.length2 !== '') {
temp['length'][1] = this.state.length2;
} else {
temp['length'][1] = '';
}
if (this.state.length3 !== '') {
temp['length'][2] = this.state.length3;
} else {
temp['length'][2] = '';
}
}
temp['type'] = 'word';
Expand Down Expand Up @@ -600,20 +612,23 @@ class WordEditor extends Component {
value={this.state.length1}
className={classes.textField}
margin="normal"
onChange={this.handleValChange('length1')}
/>
<TextField
label="Length 2"
id="margin-normal"
value={this.state.length2}
className={classes.textField}
margin="normal"
onChange={this.handleValChange('length2')}
/>
<TextField
label="Length 3"
id="margin-normal"
value={this.state.length3}
className={classes.textField}
margin="normal"
onChange={this.handleValChange('length3')}
/>
</FormGroup>
</FormControl>
Expand Down

0 comments on commit e21c753

Please sign in to comment.