Skip to content

Commit

Permalink
#1630 Sort field names in filter form dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Nov 9, 2020
1 parent af5c389 commit 8b57ae5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions frontend/app/scripts/controllers/SearchCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@
};

$scope.filterFields = function(entity) {
return _.filter($scope.metadata[entity].attributes, function(value, key) {
return _.pluck(_.filter($scope.metadata[entity].attributes, function(value, key) {
return !key.startsWith('computed.');
});
}), 'name').sort();
};

$scope.search = function() {
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/scripts/services/common/ui/FilteringSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
this.config = config;
this.defaults = config.defaults || {};
this.defaultFilter = config.defaultFilter || {};
this.attributeKeys = [];

this.initContext = function(state) {
self.state = state;
Expand All @@ -22,6 +23,8 @@
_.each(self.config.excludes || [], function(exclude) {
delete self.attributes[exclude];
});

self.attributeKeys = _.keys(self.attributes).sort();
})
.then(function() {
var storedContext = localStorageService.get(self.sectionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h4>Filters</h4>
</button>
</span>
<select class="form-control" ng-model="filter.field"
ng-options="item.name as item.name for (key, item) in $vm.filtering.attributes"
ng-options="item for item in $vm.filtering.attributeKeys"
ng-change="$vm.filtering.setFilterField(filter, config.entity)"></select>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/partials/alert/list/filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h4>Filters</h4>
</button>
</span>
<select class="form-control" ng-model="filter.field"
ng-options="item.name as item.name for (key, item) in $vm.filtering.attributes"
ng-options="item for item in $vm.filtering.attributeKeys"
ng-change="$vm.filtering.setFilterField(filter, config.entity)"></select>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/partials/case/list/filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h4>Filters</h4>
</button>
</span>
<select class="form-control" ng-model="filter.field"
ng-options="item.name as item.name for (key, item) in $vm.filtering.attributes"
ng-options="item for item in $vm.filtering.attributeKeys"
ng-change="$vm.filtering.setFilterField(filter, config.entity)"></select>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/partials/observables/list/filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h4>Filters</h4>
</button>
</span>
<select class="form-control" ng-model="filter.field"
ng-options="item.name as item.name for (key, item) in filtering.attributes"
ng-options="item for item in filtering.attributeKeys"
ng-change="filtering.setFilterField(filter, config.entity)"></select>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/partials/search/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3>Search filters <small ng-show="config.entity !== 'all'">{{config[config.enti
</button>
</span>
<select class="form-control" ng-model="filter.field"
ng-options="item.name as item.name for (key, item) in filterFields(config.entity)"
ng-options="item for item in filterFields(config.entity)"
ng-change="setFilterField(filter, config.entity)"></select>
</div>
</div>
Expand Down

0 comments on commit 8b57ae5

Please sign in to comment.