refactoring
This commit is contained in:
@@ -35,33 +35,15 @@ class HistogramView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#displaySelectBatchcodeCombination(histograms, histogramChartView, chartWithSlider) {
|
#displaySelectBatchcodeCombination(histograms, histogramChartView, chartWithSlider) {
|
||||||
const selectBatchcodeCombination = UIUtils.instantiateTemplate('template-selectBatchcodeCombination');
|
const selectBatchcodeCombination =
|
||||||
const batchcodesSelect = selectBatchcodeCombination.querySelector('#batchcodesSelect');
|
new BatchcodeCombinationSelection().getSelectBatchcodeCombination(
|
||||||
this.#addBatchcodeCombinationOptions(batchcodesSelect, histograms);
|
{
|
||||||
batchcodesSelect.addEventListener(
|
histograms: histograms,
|
||||||
'change',
|
onSelect: histoDescr => this.#displayHistogram(histoDescr, histogramChartView, chartWithSlider)
|
||||||
event => {
|
});
|
||||||
const histoDescr = histograms[event.target.value];
|
|
||||||
this.#displayHistogram(histoDescr, histogramChartView, chartWithSlider);
|
|
||||||
});
|
|
||||||
this.#uiContainer.appendChild(selectBatchcodeCombination);
|
this.#uiContainer.appendChild(selectBatchcodeCombination);
|
||||||
}
|
}
|
||||||
|
|
||||||
#addBatchcodeCombinationOptions(batchcodesSelect, histograms) {
|
|
||||||
this.#getBatchcodeCombinationOptions(histograms).forEach(option => batchcodesSelect.add(option));
|
|
||||||
}
|
|
||||||
|
|
||||||
#getBatchcodeCombinationOptions(histograms) {
|
|
||||||
return histograms.map(this.#getBatchcodeCombinationOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
#getBatchcodeCombinationOption(histoDescr, index) {
|
|
||||||
const option = document.createElement("option");
|
|
||||||
option.text = histoDescr.batchcodes.join(', ');
|
|
||||||
option.value = index;
|
|
||||||
return option;
|
|
||||||
}
|
|
||||||
|
|
||||||
#displayHistogram(histoDescr, histogramChartView, chartWithSlider) {
|
#displayHistogram(histoDescr, histogramChartView, chartWithSlider) {
|
||||||
histogramChartView.displayChart(histoDescr);
|
histogramChartView.displayChart(histoDescr);
|
||||||
this.#createSlider(
|
this.#createSlider(
|
||||||
@@ -109,4 +91,35 @@ class HistogramView {
|
|||||||
sliderElement.style.height = height;
|
sliderElement.style.height = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BatchcodeCombinationSelection {
|
||||||
|
|
||||||
|
getSelectBatchcodeCombination({ histograms, onSelect }) {
|
||||||
|
const selectBatchcodeCombination = UIUtils.instantiateTemplate('template-selectBatchcodeCombination');
|
||||||
|
const batchcodesSelect = selectBatchcodeCombination.querySelector('#batchcodesSelect');
|
||||||
|
this.#addBatchcodeCombinationOptions(batchcodesSelect, histograms);
|
||||||
|
batchcodesSelect.addEventListener(
|
||||||
|
'change',
|
||||||
|
event => {
|
||||||
|
const histoDescr = histograms[event.target.value];
|
||||||
|
onSelect(histoDescr);
|
||||||
|
});
|
||||||
|
return selectBatchcodeCombination;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addBatchcodeCombinationOptions(batchcodesSelect, histograms) {
|
||||||
|
this.#getBatchcodeCombinationOptions(histograms).forEach(option => batchcodesSelect.add(option));
|
||||||
|
}
|
||||||
|
|
||||||
|
#getBatchcodeCombinationOptions(histograms) {
|
||||||
|
return histograms.map(this.#getBatchcodeCombinationOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
#getBatchcodeCombinationOption(histoDescr, index) {
|
||||||
|
const option = document.createElement("option");
|
||||||
|
option.text = histoDescr.batchcodes.join(', ');
|
||||||
|
option.value = index;
|
||||||
|
return option;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user