batchCodes.html?showCountriesColumn=yes or batchCodes.html?showCountriesColumn=no

This commit is contained in:
frankknoll
2023-06-09 22:47:21 +02:00
parent 39d4e47314
commit 79156123d7
4 changed files with 15 additions and 10 deletions

View File

@@ -1,11 +1,11 @@
class BatchCodeTableInitializer {
initialize({ batchCodeTableElement, showCountries }) {
initialize({ batchCodeTableElement, showCountriesColumn }) {
// FK-TODO: show "Loading.." message or spinning wheel.
this.#loadBarChartDescriptions(showCountries)
this.#loadBarChartDescriptions(showCountriesColumn)
.then(barChartDescriptions => {
const batchCodeTable = this.#createEmptyBatchCodeTable(batchCodeTableElement, showCountries, barChartDescriptions);
this.#setVisibilityOfCountriesColumn(batchCodeTable, showCountries);
const batchCodeTable = this.#createEmptyBatchCodeTable(batchCodeTableElement, showCountriesColumn, barChartDescriptions);
this.#setVisibilityOfCountriesColumn(batchCodeTable, showCountriesColumn);
fetch('data/batchCodeTables/Global.json')
.then(response => response.json())
.then(json => {
@@ -25,7 +25,7 @@ class BatchCodeTableInitializer {
Promise.resolve({});
}
#createEmptyBatchCodeTable(batchCodeTableElement, showCountries, barChartDescriptions) {
#createEmptyBatchCodeTable(batchCodeTableElement, showCountriesColumn, barChartDescriptions) {
return batchCodeTableElement.DataTable(
{
language:
@@ -78,7 +78,7 @@ class BatchCodeTableInitializer {
return null;
},
createdCell: (cell, cellData, row, rowIndex, colIndex) => {
if (showCountries) {
if (showCountriesColumn) {
this.#displayBatchcodeByCountryBarChart(
row[this.#getColumnIndex('Batch')],
barChartDescriptions,
@@ -124,10 +124,10 @@ class BatchCodeTableInitializer {
}
}
#setVisibilityOfCountriesColumn(batchCodeTable, showCountries) {
#setVisibilityOfCountriesColumn(batchCodeTable, showCountriesColumn) {
batchCodeTable
.column(this.#getColumnIndex('Countries'))
.visible(showCountries);
.visible(showCountriesColumn);
}
#addCountriesColumn(json) {