refactoring

This commit is contained in:
frankknoll
2023-01-30 23:38:39 +01:00
parent 2c462dd72a
commit cd2b6a2d80
3 changed files with 31 additions and 31 deletions

View File

@@ -0,0 +1,30 @@
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;
}
}