Skip to content

Commit

Permalink
Merge pull request #916 from JGreenlee/master
Browse files Browse the repository at this point in the history
consolidate filter buttons into dropdown <select>
  • Loading branch information
shankari authored Mar 25, 2023
2 parents dc3b274 + fb83c24 commit 17bc991
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
35 changes: 17 additions & 18 deletions www/js/diary/infinite_scroll_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ angular.module('emission.main.diary.infscrolllist',['ui-leaflet',
f.state = false;
});
$scope.filterInputs[0].state = true;
$scope.selFilter = $scope.filterInputs[0].key;
ClientStats.addReading(ClientStats.getStatKeys().LABEL_TAB_SWITCH, {"source": null, "dest": $scope.getActiveFilters()});
$scope.allTrips = false;
const ONE_WEEK = 7 * 24 * 60 * 60; // seconds
Expand Down Expand Up @@ -192,15 +193,24 @@ angular.module('emission.main.diary.infscrolllist',['ui-leaflet',
}
});

$scope.select = function(selF) {
$scope.updateFilterSel = function(selFilterKey) {
const prev = $scope.getActiveFilters();
selF.state = true;
$scope.filterInputs.forEach((f) => {
if (f !== selF) {
const selFilter = $scope.filterInputs.find(f => f.key == selFilterKey);
if (selFilter) {
selFilter.state = true;
$scope.filterInputs.forEach((f) => {
if (f !== selFilter) {
f.state = false;
}
});
$scope.allTrips = false;
} else {
$scope.filterInputs.forEach((f) => {
f.state = false;
}
});
$scope.allTrips = false;
});
$scope.allTrips = true;
}

$scope.recomputeDisplayTrips();
// scroll to the bottom while changing filters so users don't have to
// fixes the first of the fit-and-finish issues from
Expand All @@ -209,17 +219,6 @@ angular.module('emission.main.diary.infscrolllist',['ui-leaflet',
ClientStats.addReading(ClientStats.getStatKeys().LABEL_TAB_SWITCH, {"source": prev, "dest": $scope.getActiveFilters()});
}

$scope.resetSelection = function() {
const prev = $scope.getActiveFilters();
$scope.filterInputs.forEach((f) => {
f.state = false;
});
$scope.allTrips = true;
$scope.recomputeDisplayTrips();
$ionicScrollDelegate.scrollBottom();
ClientStats.addReading(ClientStats.getStatKeys().LABEL_TAB_SWITCH, {"source": prev, "dest": $scope.getActiveFilters()});
}

$scope.recomputeDisplayTrips = function() {
let alreadyFiltered = false;
$scope.filterInputs.forEach((f) => {
Expand Down
6 changes: 2 additions & 4 deletions www/js/survey/enketo/infinite_scroll_filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ angular.module('emission.survey.enketo.trip.infscrollfilters',[
sf.UNLABELED = {
key: "unlabeled",
text: $translate.instant(".unlabeled"),
filter: unlabeledCheck,
width: "col-50"
filter: unlabeledCheck
}

sf.TO_LABEL = {
key: "to_label",
text: $translate.instant(".to-label"),
filter: unlabeledCheck,
width: "col-50"
filter: unlabeledCheck
}

sf.configuredFilters = [
Expand Down
14 changes: 7 additions & 7 deletions www/templates/diary/infinite_scroll_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<button class="button button-icon" ng-click="increaseHeight()">
<i class="icon ion-arrow-resize"></i>
</button>
<div class="row buttons labelfilterlist">
<button ng-repeat="selF in filterInputs" ng-click="select(selF)" class="{{selF.width}} button labelfilter" ng-class="{on:selF.state}" style="text-align: center;font-size: 13px;font-weight: 600; border-radius: 10px;" translate>
{{selF.text}}
</button>
<button ng-click="resetSelection()" class="col-33 button labelfilter last" ng-class="{on:allTrips}" style="text-align: center;font-size: 13px;font-weight: 600; border-radius: 10px;" translate>
<select ng-model="selFilter" ng-change="updateFilterSel(selFilter)">
<option ng-repeat="filter in filterInputs" value="{{filter.key}}" translate>
{{filter.text}}
</option>
<option value="show-all" translate>
{{'.show-all'}}
</button>
</div>
</option>
</select>
</ion-nav-buttons>

<ion-nav-buttons side="right">
Expand Down

0 comments on commit 17bc991

Please sign in to comment.