starting to add batch code heading
This commit is contained in:
@@ -1,15 +1,28 @@
|
||||
class BatchCodeSelectInitializer {
|
||||
|
||||
static initialize({batchCodeSelectElement, batchCodeDetailsElement}) {
|
||||
static initialize({ batchCodeSelectElement, batchCodeDetailsElement, batchCodeHeadingElement }) {
|
||||
const batchCodeDetailsView = new BatchCodeDetailsView(batchCodeDetailsElement);
|
||||
batchCodeSelectElement.select2({ minimumInputLength: 4 });
|
||||
batchCodeSelectElement.on(
|
||||
'select2:select',
|
||||
function (event) {
|
||||
const batchcode = event.params.data.id;
|
||||
batchCodeDetailsView.displayBatchCodeDetails(batchcode);
|
||||
GoogleAnalytics.click_batchcode(batchcode);
|
||||
BatchCodeSelectInitializer.#onBatchCodeSelected(
|
||||
{
|
||||
batchcode: event.params.data.id,
|
||||
batchCodeHeadingElement: batchCodeHeadingElement,
|
||||
batchCodeDetailsView: batchCodeDetailsView
|
||||
});
|
||||
});
|
||||
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