refactoring
This commit is contained in:
@@ -1,19 +1,18 @@
|
|||||||
class VaccineDistributionByZipcodeTableInitializer {
|
class VaccineDistributionByZipcodeTableInitializer {
|
||||||
|
|
||||||
#tableElement;
|
#tableElement;
|
||||||
#table;
|
|
||||||
|
|
||||||
constructor({ tableElement }) {
|
constructor({ tableElement }) {
|
||||||
this.#tableElement = tableElement;
|
this.#tableElement = tableElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
this.#table = this.#createEmptyTable();
|
this.#createTable();
|
||||||
this.#loadDataIntoTable();
|
this.#selectInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
#createEmptyTable() {
|
#createTable() {
|
||||||
return this.#tableElement.DataTable(
|
this.#tableElement.DataTable(
|
||||||
{
|
{
|
||||||
language:
|
language:
|
||||||
{
|
{
|
||||||
@@ -23,6 +22,7 @@ class VaccineDistributionByZipcodeTableInitializer {
|
|||||||
{
|
{
|
||||||
return: false
|
return: false
|
||||||
},
|
},
|
||||||
|
ajax: 'data/vaccineDistributionByZipcode/VaccineDistributionByZipcode.json',
|
||||||
processing: true,
|
processing: true,
|
||||||
deferRender: true,
|
deferRender: true,
|
||||||
columnDefs:
|
columnDefs:
|
||||||
@@ -56,23 +56,6 @@ class VaccineDistributionByZipcodeTableInitializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#loadDataIntoTable() {
|
|
||||||
// FK-TODO: show "Loading.." message or spinning wheel.
|
|
||||||
fetch('data/vaccineDistributionByZipcode/VaccineDistributionByZipcode.json')
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(json => {
|
|
||||||
this.#setTableRows(json.data);
|
|
||||||
this.#selectInput();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#setTableRows(rows) {
|
|
||||||
this.#table
|
|
||||||
.clear()
|
|
||||||
.rows.add(rows)
|
|
||||||
.draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
#selectInput() {
|
#selectInput() {
|
||||||
const input = document.querySelector(".dataTables_filter input");
|
const input = document.querySelector(".dataTables_filter input");
|
||||||
input.focus();
|
input.focus();
|
||||||
|
|||||||
Reference in New Issue
Block a user