Optimisation : deuxième toLowerCase mal placé

pull/138/head
mama 2017-11-23 11:25:24 +01:00
parent 41d45164c8
commit 42f579fc8a
3 changed files with 11 additions and 6 deletions

View File

@ -18,11 +18,14 @@ export default class Explicable extends React.Component {
dottedName, hover, label,
explain, explained,
lightBackground
} = this.props,
rule = findRuleByDottedName(rules, dottedName)
} = this.props
// Rien à expliquer ici, ce n'est pas une règle
if (!rule) return <span>{label}</span>
if (dottedName == null)
return <span>{label}</span>
let rule = findRuleByDottedName(rules, dottedName)
let ruleLabel = (
label || rule.title

View File

@ -75,7 +75,7 @@ export default class Question extends Component {
return (<ul>
{choices.canGiveUp &&
<li key='aucun' className="variantLeaf aucun">
<RadioLabel {...{value: 'non', label: 'Aucun', input, submit, themeColours}}/>
<RadioLabel {...{value: 'non', label: 'Aucun', input, submit, themeColours, dottedName: null}}/>
</li>
}
{ choices.children && choices.children.map( ({name, title, dottedName, children}) =>

View File

@ -99,8 +99,10 @@ export let searchRules = searchInput =>
JSON.stringify(rule).toLowerCase().indexOf(searchInput) > -1)
.map(enrichRule)
export let findRuleByDottedName = (allRules, dottedName) =>
dottedName && allRules.find(rule => rule.dottedName == dottedName.toLowerCase())
export let findRuleByDottedName = (allRules, dottedName) => {
let query = dottedName.toLowerCase()
return allRules.find(rule => rule.dottedName == query)
}
/*********************************
Autres */