Skip to content

Commit

Permalink
Calculate number of results that are different, enable option to show…
Browse files Browse the repository at this point in the history
… or not
  • Loading branch information
nai888 committed Dec 30, 2018
1 parent 2a02441 commit 2d9d939
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/routes/Morph/MorphResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const MorphResults = props => {
}

const classes = result => {
if (result.changed) {
if (result.changed && props.showDiff) {
return classNames(props.styles.outText, props.styles.changed)
} else {
return props.styles.outText
Expand Down
20 changes: 15 additions & 5 deletions src/routes/Morph/MorphService.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,28 @@ class MorphService {
}

morph (data) {
return [
let results = [
{
input: 'lector',
output: 'leitor',
changed: true
output: 'leitor'
},
{
input: 'doctor',
output: 'doutor',
changed: false
output: 'doutor'
}
]
if (data.results !== undefined) {
for (let i = 0; i < results.length; i++) {
results[i].changed =
results[i].input !== data.results[i].input &&
results[i].output !== data.results[i].output
}
} else {
for (let i = 0; i < results.length; i++) {
results[i].changed = true
}
}
return results
}
}

Expand Down
1 change: 1 addition & 0 deletions src/routes/Morph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Morph extends React.Component {
styles={this.props.classes}
outputFormat={this.state.outputFormat}
results={this.state.results}
showDiff={this.state.showDiff}
/>
</Tool>
)
Expand Down

0 comments on commit 2d9d939

Please sign in to comment.