From 79156123d70353b8513d773529fbfd4114f8fdca Mon Sep 17 00:00:00 2001 From: frankknoll Date: Fri, 9 Jun 2023 22:47:21 +0200 Subject: [PATCH] batchCodes.html?showCountriesColumn=yes or batchCodes.html?showCountriesColumn=no --- docs/BatchCodeTableInitializer.js | 16 ++++++++-------- docs/UIUtils.js | 6 ++++++ docs/batchCodes.html | 2 +- src/help.txt | 1 - 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/BatchCodeTableInitializer.js b/docs/BatchCodeTableInitializer.js index 4c7781fe69d..aaa06bf0807 100644 --- a/docs/BatchCodeTableInitializer.js +++ b/docs/BatchCodeTableInitializer.js @@ -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) { diff --git a/docs/UIUtils.js b/docs/UIUtils.js index f8ef25f6425..337352522a4 100644 --- a/docs/UIUtils.js +++ b/docs/UIUtils.js @@ -58,4 +58,10 @@ class UIUtils { } } } + + static getSearchParam(urlParams, searchParam, defaultValue) { + return urlParams.has(searchParam) ? + urlParams.get(searchParam) : + defaultValue; + } } diff --git a/docs/batchCodes.html b/docs/batchCodes.html index 853c1437129..acf468b13e9 100644 --- a/docs/batchCodes.html +++ b/docs/batchCodes.html @@ -40,7 +40,7 @@ new BatchCodeTableInitializer().initialize( { batchCodeTableElement: $('#batchCodeTable'), - showCountries: false + showCountriesColumn: UIUtils.getSearchParam(new URLSearchParams(window.location.search), 'showCountriesColumn', '').toUpperCase() == 'YES' }); }); diff --git a/src/help.txt b/src/help.txt index 4c8143ff559..d06173d2974 100644 --- a/src/help.txt +++ b/src/help.txt @@ -5,7 +5,6 @@ FK-FIXME: FK-TODO: - add google captcha to batchCodeTable.html - Symptomhistogramm -- batchCodes.html?showCountries=yes oder batchCodes.html?showCountries=no als Default dazufügen. anacron job: sudo cp src/intensivstationen_howbadismybatch.sh /etc/cron.daily/intensivstationen_howbadismybatch