starting to add batch code heading
This commit is contained in:
@@ -1,15 +1,28 @@
|
|||||||
class BatchCodeSelectInitializer {
|
class BatchCodeSelectInitializer {
|
||||||
|
|
||||||
static initialize({batchCodeSelectElement, batchCodeDetailsElement}) {
|
static initialize({ batchCodeSelectElement, batchCodeDetailsElement, batchCodeHeadingElement }) {
|
||||||
const batchCodeDetailsView = new BatchCodeDetailsView(batchCodeDetailsElement);
|
const batchCodeDetailsView = new BatchCodeDetailsView(batchCodeDetailsElement);
|
||||||
batchCodeSelectElement.select2({ minimumInputLength: 4 });
|
batchCodeSelectElement.select2({ minimumInputLength: 4 });
|
||||||
batchCodeSelectElement.on(
|
batchCodeSelectElement.on(
|
||||||
'select2:select',
|
'select2:select',
|
||||||
function (event) {
|
function (event) {
|
||||||
const batchcode = event.params.data.id;
|
BatchCodeSelectInitializer.#onBatchCodeSelected(
|
||||||
batchCodeDetailsView.displayBatchCodeDetails(batchcode);
|
{
|
||||||
GoogleAnalytics.click_batchcode(batchcode);
|
batchcode: event.params.data.id,
|
||||||
|
batchCodeHeadingElement: batchCodeHeadingElement,
|
||||||
|
batchCodeDetailsView: batchCodeDetailsView
|
||||||
|
});
|
||||||
});
|
});
|
||||||
batchCodeSelectElement.select2('open');
|
batchCodeSelectElement.select2('open');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static #onBatchCodeSelected({ batchcode, batchCodeHeadingElement, batchCodeDetailsView }) {
|
||||||
|
CompanyByBatchcodeProvider
|
||||||
|
.getCompany(batchcode)
|
||||||
|
.then(company => {
|
||||||
|
batchCodeHeadingElement.innerText = `Batch ${batchcode} (${company})`;
|
||||||
|
batchCodeDetailsView.displayBatchCodeDetails(batchcode);
|
||||||
|
GoogleAnalytics.click_batchcode(batchcode);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
docs/CompanyByBatchcodeProvider.js
Normal file
8
docs/CompanyByBatchcodeProvider.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class CompanyByBatchcodeProvider {
|
||||||
|
|
||||||
|
static getCompany(batchcode) {
|
||||||
|
return fetch(`data/histograms/Global/${batchcode}.json`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(histoDescrs => histoDescrs.Company);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user