starting to add batch code heading

This commit is contained in:
Frank Knoll
2024-04-24 14:21:23 +02:00
parent 618fd89e7f
commit b0ec2683bc
3 changed files with 9706 additions and 129 deletions

View File

@@ -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);
});
}
}

View 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