argh!!
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class BatchCodeTableInitializer {
|
||||
|
||||
#batchCodeTableElement;
|
||||
#batchCodeTable;
|
||||
#columnSearch;
|
||||
#barChartDescriptions;
|
||||
|
||||
constructor(batchCodeTableElement) {
|
||||
@@ -8,19 +10,20 @@ class BatchCodeTableInitializer {
|
||||
}
|
||||
|
||||
initialize() {
|
||||
const self = this;
|
||||
this.#batchCodeTable = this.#createEmptyBatchCodeTable();
|
||||
this.#columnSearch = new ColumnSearch(this.#batchCodeTable.column(this.#getColumnIndex('Company')));
|
||||
this.#displayCountry();
|
||||
BarChartDescriptionsProvider
|
||||
.getBarChartDescriptions()
|
||||
.then(barChartDescriptions => {
|
||||
this.#barChartDescriptions = barChartDescriptions;
|
||||
this.#batchCodeTableElement.DataTable(
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
#createEmptyBatchCodeTable() {
|
||||
return this.#batchCodeTableElement.DataTable(
|
||||
{
|
||||
ajax: 'data/batchCodeTables/Global.json',
|
||||
initComplete: function (settings) {
|
||||
batchCodeTable = settings.oInstance.api();
|
||||
const columnSearch = new ColumnSearch(batchCodeTable.column(self.#getColumnIndex('Company')));
|
||||
columnSearch.columnContentUpdated();
|
||||
},
|
||||
language:
|
||||
{
|
||||
searchPlaceholder: "Enter Batch Code"
|
||||
@@ -80,7 +83,6 @@ class BatchCodeTableInitializer {
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#getColumnIndex(columnName) {
|
||||
@@ -105,4 +107,36 @@ class BatchCodeTableInitializer {
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
// FK-TODO: rename
|
||||
#displayCountry() {
|
||||
// FK-TODO: show "Loading.." message or spinning wheel.
|
||||
BarChartDescriptionsProvider
|
||||
.getBarChartDescriptions()
|
||||
.then(barChartDescriptions => {
|
||||
this.#barChartDescriptions = barChartDescriptions;
|
||||
fetch('data/batchCodeTables/Global.json')
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
this.#_addCountriesColumn(json);
|
||||
return json;
|
||||
})
|
||||
.then(json => {
|
||||
this.#setTableRows(json.data);
|
||||
this.#columnSearch.columnContentUpdated();
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
#_addCountriesColumn(json) {
|
||||
json.columns.push('Countries');
|
||||
json.data.forEach(row => row.push(null));
|
||||
}
|
||||
|
||||
#setTableRows(rows) {
|
||||
this.#batchCodeTable
|
||||
.clear()
|
||||
.rows.add(rows)
|
||||
.draw();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user