continuing

This commit is contained in:
frankknoll
2023-04-12 19:14:53 +02:00
parent 6c1f43e32b
commit b1166236b7
5 changed files with 18 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ class HistogramView {
this.#uiContainer = uiContainer this.#uiContainer = uiContainer
} }
// FK-TODO: unbind all events here and in HistogramChartView
displayHistogramView(batchcode) { displayHistogramView(batchcode) {
this this
.#loadHistoDescrs(batchcode) .#loadHistoDescrs(batchcode)
@@ -13,6 +14,7 @@ class HistogramView {
} }
#loadHistoDescrs(batchcode) { #loadHistoDescrs(batchcode) {
UIUtils.clear(this.#uiContainer);
const loadingText = document.createTextNode('Loading...'); const loadingText = document.createTextNode('Loading...');
this.#uiContainer.appendChild(loadingText); this.#uiContainer.appendChild(loadingText);
return HistoDescrsProvider return HistoDescrsProvider

View File

@@ -8,6 +8,10 @@ class UIUtils {
return UIUtils.instantiateTemplate('template-canvas'); return UIUtils.instantiateTemplate('template-canvas');
} }
static clear(container) {
container.replaceChildren();
}
static createChartViewElementWithHeading(heading) { static createChartViewElementWithHeading(heading) {
const chartViewElement = UIUtils.instantiateTemplate('template-ChartView'); const chartViewElement = UIUtils.instantiateTemplate('template-ChartView');
chartViewElement.querySelector(".heading").textContent = heading; chartViewElement.querySelector(".heading").textContent = heading;

View File

@@ -60,6 +60,7 @@
</p> </p>
<p> <p>
<select id="batchCodeSelect" name="batchCode"> <select id="batchCodeSelect" name="batchCode">
<option disabled="" hidden="" selected="" value="">Select Batch</option>
<option value="FE6208">FE6208</option> <option value="FE6208">FE6208</option>
<option value="FD6840">FD6840</option> <option value="FD6840">FD6840</option>
<option value="FD4555">FD4555</option> <option value="FD4555">FD4555</option>
@@ -49764,6 +49765,7 @@
<option value="RL8095">RL8095</option> <option value="RL8095">RL8095</option>
<option value="Ø94F21A">Ø94F21A</option> <option value="Ø94F21A">Ø94F21A</option>
</select> </select>
<div id="batchCodeDetails"></div>
</p> </p>
<table class="display" id="batchCodeTable"> <table class="display" id="batchCodeTable">
<thead> <thead>

View File

@@ -16,7 +16,6 @@ class BatchCodeTableInitializer {
this.#initializeBatchCodeSelect(); this.#initializeBatchCodeSelect();
this.#display(); this.#display();
this.#initializeHistogramView(); this.#initializeHistogramView();
this.#trackSearchWithGoogleAnalytics();
} }
#createEmptyBatchCodeTable() { #createEmptyBatchCodeTable() {
@@ -105,7 +104,6 @@ class BatchCodeTableInitializer {
.then(json => { .then(json => {
this.#setTableRows(json.data); this.#setTableRows(json.data);
this.#columnSearch.columnContentUpdated(); this.#columnSearch.columnContentUpdated();
this.#selectInput();
}); });
} }
@@ -121,20 +119,16 @@ class BatchCodeTableInitializer {
.draw(); .draw();
} }
#selectInput() {
const input = document.querySelector(".dataTables_filter input");
input.focus();
input.select();
}
#initializeBatchCodeSelect() { #initializeBatchCodeSelect() {
this.#batchCodeSelect.select2({ minimumInputLength: 3 }); this.#batchCodeSelect.select2({ minimumInputLength: 4 });
this.#batchCodeSelect.on( this.#batchCodeSelect.on(
'select2:select', 'select2:select',
function (e) { function (event) {
var data = e.params.data; const batchcode = event.params.data.id;
console.log(data.id); new HistogramView(document.querySelector("#batchCodeDetails")).displayHistogramView(batchcode);
GoogleAnalytics.click_batchcode(batchcode);
}); });
this.#batchCodeSelect.select2('open');
} }
#initializeHistogramView() { #initializeHistogramView() {
@@ -159,14 +153,4 @@ class BatchCodeTableInitializer {
} }
}); });
} }
#trackSearchWithGoogleAnalytics() {
const thisClassInstance = this;
$(`#${this.#batchCodeTableElement[0].id}`)
.on(
'search.dt',
function () {
GoogleAnalytics.view_search_results(thisClassInstance.#batchCodeTable.search().toUpperCase());
});
}
} }

View File

@@ -3,6 +3,10 @@ def getBatchcodes(batchCodeTable):
def getBatchcodeOptions(batchcodes): def getBatchcodeOptions(batchcodes):
return ['<option hidden disabled selected value>Select Batch</option>'] + _getBatchcodeOptions(batchcodes)
def _getBatchcodeOptions(batchcodes):
return [_getBatchcodeOption(batchcode) for batchcode in batchcodes] return [_getBatchcodeOption(batchcode) for batchcode in batchcodes]