mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Fixed filter form data resetting when adding filter
This commit is contained in:
parent
180547e078
commit
54b95c1c0a
@ -468,7 +468,7 @@
|
||||
Highcharts.setOptions(Highcharts.theme);
|
||||
updateGraphs();
|
||||
} catch (e) {
|
||||
if (graphs !== undefined) console.error(e);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class MultipleChoiceFilter extends Filter {
|
||||
<label for="${this.id}">${select}${this.label}:</label>
|
||||
<button class="filter-remover btn btn-outline-secondary float-right"
|
||||
onclick="removeFilter('${this.id}')"><i class="far fa-fw fa-trash-alt"></i></button>
|
||||
<select class="form-control" multiple>`;
|
||||
<select class="form-control" multiple style="margin-bottom: 0.5rem;">`;
|
||||
|
||||
for (const option of this.options.options) {
|
||||
html += `<option>${option}</option>`;
|
||||
@ -42,8 +42,8 @@ class MultipleChoiceFilter extends Filter {
|
||||
|
||||
toObject() {
|
||||
let selected = [];
|
||||
for (let option of document.querySelector(`#${this.id} select`).selectedOptions) {
|
||||
selected.push(option.text);
|
||||
for (let option of document.querySelector(`#${this.id} select`).options) {
|
||||
if (option.selected) selected.push(option.text);
|
||||
}
|
||||
selected = JSON.stringify(selected);
|
||||
|
||||
|
@ -101,7 +101,9 @@ function addFilter(parentSelector, filterIndex) {
|
||||
const id = "f" + queryState.filterCount;
|
||||
const filter = createFilter(loadedFilters[filterIndex], id);
|
||||
queryState.filters.push(filter);
|
||||
document.querySelector(parentSelector).innerHTML += filter.render(queryState.filterCount);
|
||||
const inserting = document.createElement("template");
|
||||
inserting.innerHTML = filter.render(queryState.filterCount);
|
||||
document.querySelector(parentSelector).appendChild(inserting.content);
|
||||
queryState.filterCount++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user