mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Do more filter panel generation in HTML, less in JS
This commit is contained in:
@@ -28,24 +28,14 @@ function allFilterOptionsSelected(parameter) {
|
||||
}
|
||||
|
||||
|
||||
// Generate a filter card with multiple toggle buttons plus All/None buttons
|
||||
function generateMultiToggleFilterCard(displayName, filterQuery, options) {
|
||||
let $col = $("<div class='col'>")
|
||||
let $card = $("<div class='card'>");
|
||||
let $card_body = $("<div class='card-body'>");
|
||||
$card_body.append(`<h5 class='card-title'>${displayName}</h5>`);
|
||||
$p = $("<p class='card-text spothole-card-text'>");
|
||||
// Generate a filter card with multiple toggle buttons plus All/None buttons.
|
||||
function generateMultiToggleFilterCard(elementID, filterQuery, options) {
|
||||
// Create a button for each option
|
||||
options.forEach(o => {
|
||||
$p.append(`<input type="checkbox" class="btn-check filter-button-${filterQuery} storeable-checkbox" name="options" id="filter-button-${filterQuery}-${o}" value="${o}" autocomplete="off" onClick="filtersUpdated()" checked><label class="btn btn-outline-primary" for="filter-button-${filterQuery}-${o}">${o}</label> `);
|
||||
$(elementID).append(`<input type="checkbox" class="btn-check filter-button-${filterQuery} storeable-checkbox" name="options" id="filter-button-${filterQuery}-${o}" value="${o}" autocomplete="off" onClick="filtersUpdated()" checked><label class="btn btn-outline-primary" for="filter-button-${filterQuery}-${o}">${o}</label> `);
|
||||
});
|
||||
// Create All/None buttons
|
||||
$p.append(` <span style="display: inline-block"><button id="filter-button-${filterQuery}-all" type="button" class="btn btn-outline-secondary" onclick="toggleFilterButtons('${filterQuery}', true);">All</button> <button id="filter-button-${filterQuery}-none" type="button" class="btn btn-outline-secondary" onclick="toggleFilterButtons('${filterQuery}', false);">None</button></span>`);
|
||||
// Compile HTML elements to return
|
||||
$card_body.append($p);
|
||||
$card.append($card_body);
|
||||
$col.append($card);
|
||||
return $col;
|
||||
$(elementID).append(` <span style="display: inline-block"><button id="filter-button-${filterQuery}-all" type="button" class="btn btn-outline-secondary" onclick="toggleFilterButtons('${filterQuery}', true);">All</button> <button id="filter-button-${filterQuery}-none" type="button" class="btn btn-outline-secondary" onclick="toggleFilterButtons('${filterQuery}', false);">None</button></span>`);
|
||||
}
|
||||
|
||||
// Method called when "All" or "None" is clicked
|
||||
|
||||
Reference in New Issue
Block a user