Skip to content

Commit

Permalink
show the current filter values
Browse files Browse the repository at this point in the history
  • Loading branch information
slead committed Sep 22, 2020
1 parent 28206e7 commit a4208e9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.html
Expand Up @@ -275,6 +275,7 @@ <h5 class="modal-title">Share URL</h5>
</div>
<button id="btnRemoveFilter" class="btn btn-secondary">Remove filter</button>
<button id="btnApplyFilter" class="btn btn-warning">Apply filter</button>
<p class="btn-secondary" id="filterOutput"><span id="filterText"></span></p>
</div>
</script>

Expand Down
34 changes: 32 additions & 2 deletions src/js/app.js
Expand Up @@ -1679,7 +1679,8 @@ function updateOperator(evt){
var filterTask = bootleaf.filterTasks.find(x => x.layerId === layerId);
var filter = filterTask.filters.find(x => x.name === fieldName);
filter.operator = evt.target.value;
console.log("update operator", filter)
console.log("update operator", filter);
updateFilterText();
}

function updateValue(evt){
Expand All @@ -1692,7 +1693,8 @@ function updateValue(evt){
var operator = $("#filterWidgetOperator option:selected").val();
filter.operator = operator;
}
console.log("update value", filter)
console.log("update value", filter);
updateFilterText();
}

function updateFilterParams(control){
Expand Down Expand Up @@ -1726,6 +1728,7 @@ function updateFilterParams(control){
}
}

updateFilterText();
}

function updateFilterOperator(option){
Expand Down Expand Up @@ -1764,6 +1767,32 @@ function updateFilterOperator(option){
});
$("#filterWidgetOperator").append(operatorOptions);

updateFilterText();
}

function updateFilterText(){
var layerId = $("#filterWidgetLayer option:selected").val()
var filterTask = bootleaf.filterTasks.find(x => x.layerId === layerId);
var filterText;
for (var i = 0; i < filterTask.filters.length; i++){
var filter = filterTask.filters[i];
if (filter.operator && filter.value) {
if (!filterText) {
filterText = filter.alias + " " + filter.operator + " " + filter.value;
} else {
filterText += " and " + filter.alias + " " + filter.operator + " " + filter.value;
}
$("#filterText").html(filterText);
console.log("update filter text", filter)
}
}

if (filterText !== undefined){
applyFilter();
} else {
$("#filterOutput").hide();
}

}

function applyFilter() {
Expand Down Expand Up @@ -1880,6 +1909,7 @@ function applyFilter() {
}
}

$("#filterOutput").show();
}

function removeFilter() {
Expand Down
9 changes: 9 additions & 0 deletions style.css
Expand Up @@ -77,3 +77,12 @@ div.dataTables_wrapper div.dataTables_paginate {
.leaflet-draw-toolbar .leaflet-draw-draw-circlemarker {
display: none;
}

#filterOutput {
margin-top: 15px;
font-style: italic;
font-size: 14px;
color: white;
padding: 15px;
display: none;
}

0 comments on commit a4208e9

Please sign in to comment.