2 creates and populates select menu with lists and datasets for analysis tools.
6 constructor(menuDivId, selectId, menuClass, label) {
7 menuDivId = menuDivId.replace(/#/, "");
8 selectId = selectId.replace(/#/, "");
10 menuClass = menuClass.replace(/\./, "");
13 this.menuDivId = menuDivId;
14 this.selectId = selectId;
15 this.menuClass = menuClass || "form-control";
16 this.label = label || ''; // || "Select a population";
21 var menu = document.createElement("select");
22 menu.id = this.selectId;
23 menu.className = this.menuClass;
25 var option = document.createElement("option");
26 option.selected = this.label;
28 option.innerHTML = this.label;
29 // option.disabled = true;
31 menu.appendChild(option);
37 getSelectMenuOptions() {
38 var selectMenu = document.getElementById(this.selectId);
42 options = selectMenu.options;
48 createOptionElement(dt) {
49 var option = document.createElement("option");
52 option.dataset.pop = JSON.stringify(dt);
53 option.innerHTML = dt.name;
62 menu = this.createSelectMenu();
65 data.forEach(function (dt) {
66 var option = this.createOptionElement(dt);
67 menu.appendChild(option);
73 updateOptions(newPop) {
74 var options = this.getSelectMenuOptions();
77 var newOption = this.createOptionElement(newPop);
78 options.add(newOption);
84 displayMenu(menuElems) {
85 document.querySelector(`#${this.menuDivId}`).appendChild(menuElems);
88 addOptionsSeparator (text) {
89 var option = document.createElement("option");
90 option.innerHTML = `-------- ${text.toUpperCase()} --------`;
91 option.disabled = true;
93 this.menu.appendChild(option);
99 this.createSelectMenu();
100 var menuElems = this.createOptions(pops);
101 this.displayMenu(menuElems);