Skip to content

Commit

Permalink
Merge pull request #130 from nzzdev/release-3.2.0
Browse files Browse the repository at this point in the history
Release 3.2.0
  • Loading branch information
philipkueng authored Nov 6, 2019
2 parents e989315 + 3b24493 commit c7f2f26
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 53 deletions.
9 changes: 7 additions & 2 deletions helpers/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function getColumnsType(data) {
const table = clone(data).slice(1);

Array2D.eachColumn(table, column => {
let withFormating = false;
let columnEmpty = column.every(cell => {
return cell === null || cell === "" || cell === "-" || cell === "–";
});
Expand All @@ -48,7 +49,11 @@ function getColumnsType(data) {
cell === "–")
);
});
columns.push({ isNumeric: isColumnNumeric });
if (isColumnNumeric) {
const numbersOfColumn = column.map(number => isNumeric(number) ? parseFloat(number) : null);
withFormating = Math.max(...numbersOfColumn) >= 10000 || Math.min(...numbersOfColumn) <= -10000
}
columns.push({ isNumeric: isColumnNumeric, withFormating });
});
return columns;
}
Expand Down Expand Up @@ -84,7 +89,7 @@ function getTableData(data, footnotes, options) {
cell != "-" &&
cell != enDash
) {
if (Math.abs(parseFloat(cell)) >= 10000) {
if (columns[columnIndex].withFormating) {
value = formatGrouping(cell);
} else {
value = formatNoGrouping(cell);
Expand Down
86 changes: 47 additions & 39 deletions package-lock.json

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

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "q-table",
"version": "3.1.8",
"version": "3.2.0",
"description": "",
"main": "index.js",
"scripts": {
Expand All @@ -20,17 +20,17 @@
"clone": "^2.1.2",
"d3-format": "^1.4.1",
"nunjucks": "^3.2.0",
"uglify-js": "^3.6.4"
"uglify-js": "^3.6.7"
},
"devDependencies": {
"@hapi/code": "^5.3.1",
"@hapi/lab": "^19.1.0",
"autoprefixer": "^9.7.0",
"autoprefixer": "^9.7.1",
"cssnano": "^4.1.10",
"html-minifier": "^4.0.0",
"jsdom": "^15.2.0",
"postcss": "^7.0.20",
"jsdom": "^15.2.1",
"postcss": "^7.0.21",
"postcss-import": "^12.0.1",
"sass": "^1.23.1"
"sass": "^1.23.3"
}
}
22 changes: 22 additions & 0 deletions resources/fixtures/data/formatted-numbers-mixed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"title": "FIXTURE: four column numeric card layout for small mixed",
"subtitle": "Subtitle",
"data": {
"table": [
["Kennzahlen", "2016", "2017"],
["Umsatz", "12000", "100"],
["Betriebsergebnis Ebit", "79123", "2000"],
["Ebit-Marge (%)", "12332", "300"],
["Konzernergebnis", "12331", "4000"],
["Cashflow aus Geschäftstätigkeit", "99999", "10000"]
],
"metaData": {
"cells": []
}
},
"sources": [],
"options": {
"cardLayout": false,
"cardLayoutIfSmall": true
}
}
22 changes: 22 additions & 0 deletions resources/fixtures/data/formatted-numbers-negative.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"title": "FIXTURE: four column numeric card layout for small negative",
"subtitle": "Subtitle",
"data": {
"table": [
["Kennzahlen", "2016", "2017"],
["Umsatz", "12000", "-10000"],
["Betriebsergebnis Ebit", "79123", "12333"],
["Ebit-Marge (%)", "12332", "32147"],
["Konzernergebnis", "12331", "10000"],
["Cashflow aus Geschäftstätigkeit", "99999", "12312"]
],
"metaData": {
"cells": []
}
},
"sources": [],
"options": {
"cardLayout": false,
"cardLayoutIfSmall": true
}
}
4 changes: 3 additions & 1 deletion routes/fixtures/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const fixtureData = [
require(`${fixtureDataDirectory}/cardlayout-mobile.json`),
require(`${fixtureDataDirectory}/lots-of-data.json`),
require(`${fixtureDataDirectory}/special-characters.json`),
require(`${fixtureDataDirectory}/formatted-numbers.json`)
require(`${fixtureDataDirectory}/formatted-numbers.json`),
require(`${fixtureDataDirectory}/formatted-numbers-mixed.json`),
require(`${fixtureDataDirectory}/formatted-numbers-negative.json`)
];

module.exports = {
Expand Down
12 changes: 12 additions & 0 deletions tasks/updateFixtureData.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ const fixtureData = [
[
`${fixtureDataDirectory}/lots-of-data.json`,
require(`${fixtureDataDirectory}/lots-of-data.json`)
],
[
`${fixtureDataDirectory}/formatted-number.json`,
require(`${fixtureDataDirectory}/formatted-number.json`)
],
[
`${fixtureDataDirectory}/formatted-number-mixed.json`,
require(`${fixtureDataDirectory}/formatted-number-mixed.json`)
],
[
`${fixtureDataDirectory}/formatted-number-negative.json`,
require(`${fixtureDataDirectory}/formatted-number-negative.json`)
]
];

Expand Down
Loading

0 comments on commit c7f2f26

Please sign in to comment.