From b1f446da4df3609ede729c54a0cd639a3cc4faa7 Mon Sep 17 00:00:00 2001 From: mama Date: Mon, 5 Feb 2018 17:01:33 +0100 Subject: [PATCH] =?UTF-8?q?:bug:=20Certains=20navigateurs=20ne=20sont=20pa?= =?UTF-8?q?s=20encore=20internationalis=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Intl fait planter Safari sur certains iphones, e.g. le 6 --- source/components/ResultsGrid.js | 3 +- source/components/rule/Algorithm.js | 36 ++++++++++----------- source/components/rule/RuleValueVignette.js | 5 ++- source/utils.js | 6 ++++ source/webpack.config.js | 6 ++-- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/source/components/ResultsGrid.js b/source/components/ResultsGrid.js index 24a67c1dc..6cfc0905b 100644 --- a/source/components/ResultsGrid.js +++ b/source/components/ResultsGrid.js @@ -21,9 +21,8 @@ import { Link } from 'react-router-dom' import { formValueSelector } from 'redux-form' import './Results.css' import '../engine/mecanismViews/Somme.css' -import { humanFigure } from './rule/RuleValueVignette' -import { capitalise0 } from '../utils' +import { capitalise0, humanFigure } from '../utils' import { nameLeaf, encodeRuleName } from 'Engine/rules' // Filtered variables and rules can't be filtered in a uniform way, for now diff --git a/source/components/rule/Algorithm.js b/source/components/rule/Algorithm.js index 11698ffaa..665be9b70 100644 --- a/source/components/rule/Algorithm.js +++ b/source/components/rule/Algorithm.js @@ -5,7 +5,7 @@ import { AttachDictionary } from '../AttachDictionary' import knownMecanisms from 'Engine/known-mecanisms.yaml' import { makeJsx } from 'Engine/evaluation' import './Algorithm.css' -import { humanFigure } from './RuleValueVignette' +import { humanFigure } from '../../utils' let RuleWithoutFormula = () => [

@@ -29,24 +29,22 @@ export default class Algorithm extends React.Component { return (

- { - do { - // TODO ce let est incompréhensible ! - let applicabilityMecanisms = values(rule).filter( - v => v && v['rulePropType'] == 'cond' - ) - applicabilityMecanisms.length > 0 && ( -
-

Déclenchement

-
    - {applicabilityMecanisms.map(v => ( -
  • {makeJsx(v)}
  • - ))} -
-
- ) - } - } + {do { + // TODO ce let est incompréhensible ! + let applicabilityMecanisms = values(rule).filter( + v => v && v['rulePropType'] == 'cond' + ) + applicabilityMecanisms.length > 0 && ( +
+

Déclenchement

+
    + {applicabilityMecanisms.map(v => ( +
  • {makeJsx(v)}
  • + ))} +
+
+ ) + }}

Calcul diff --git a/source/components/rule/RuleValueVignette.js b/source/components/rule/RuleValueVignette.js index 98fd90dc1..e77b69bbb 100644 --- a/source/components/rule/RuleValueVignette.js +++ b/source/components/rule/RuleValueVignette.js @@ -2,9 +2,8 @@ import React from 'react' import { Link } from 'react-router-dom' import { encodeRuleName } from 'Engine/rules' import classNames from 'classnames' -let fmt = new Intl.NumberFormat('fr-FR').format -export let humanFigure = decimalDigits => value => - fmt(value.toFixed(decimalDigits)) +import { humanFigure } from '../../utils' + import './RuleValueVignette.css' import ReactCSSTransitionGroup from 'react-addons-css-transition-group' diff --git a/source/utils.js b/source/utils.js index 8781c7c88..bc08ef0c4 100644 --- a/source/utils.js +++ b/source/utils.js @@ -6,3 +6,9 @@ export let getIframeOption = optionName => { hasOption = url.includes(optionName + '=') return hasOption && url.split(optionName + '=')[1].split('&')[0] } + +export let fmt = + 'Intl' in window ? new Intl.NumberFormat('fr-FR').format : v => v + +export let humanFigure = decimalDigits => value => + fmt(value.toFixed(decimalDigits)) diff --git a/source/webpack.config.js b/source/webpack.config.js index 5c0b38bd6..7bb8e3a7e 100644 --- a/source/webpack.config.js +++ b/source/webpack.config.js @@ -75,9 +75,9 @@ module.exports = { }, { test: /\.(jpe?g|png|gif|svg)$/i, - loader: prodEnv ? - 'url-loader?limit=10000&name=images/[name].[ext]!img-loader?progressive=true' : - 'url-loader?limit=10000&name=images/[name].[ext]' + loader: prodEnv + ? 'url-loader?limit=10000&name=images/[name].[ext]!img-loader?progressive=true' + : 'url-loader?limit=10000&name=images/[name].[ext]' }, { test: /\.ne$/,