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) {

View File

@@ -58,4 +58,10 @@ class UIUtils {
}
}
}
static getSearchParam(urlParams, searchParam, defaultValue) {
return urlParams.has(searchParam) ?
urlParams.get(searchParam) :
defaultValue;
}
}

View File

@@ -40,7 +40,7 @@
new BatchCodeTableInitializer().initialize(
{
batchCodeTableElement: $('#batchCodeTable'),
showCountries: false
showCountriesColumn: UIUtils.getSearchParam(new URLSearchParams(window.location.search), 'showCountriesColumn', '').toUpperCase() == 'YES'
});
});
</script>

View File

@@ -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