Skip to content

Commit

Permalink
#1252 Take into account the new types of custom fields (integer and f…
Browse files Browse the repository at this point in the history
…loat) when dealing with filters and search
  • Loading branch information
nadouani committed Apr 30, 2020
1 parent 89c4778 commit 32185ba
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/app/scripts/directives/dashboard/filter-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
var type = field.type;

if ((type === 'string' || type === 'number') && field.values.length > 0) {
if ((type === 'string' || type === 'number' || type === 'integer' || type === 'float' ) && field.values.length > 0) {
return 'enumeration';
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/app/scripts/filters/filter-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
return _.map(value.list, function(item) {
return item.label || item.text;
}).join(', ');
} else if(angular.isObject(value) && value.operator !== undefined) {
return [value.operator, value.value].join(' ');
}

return value || 'Any';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/scripts/services/common/QueryBuilderSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
return this._buildQueryFromFreeTextFilter(fieldDef, filter);
} else if(filter.value.list || fieldDef.values.length > 0) {
return this._buildQueryFromListFilter(fieldDef, filter);
} else if(filter.type === 'number') {
} else if(filter.type === 'number' || filter.type === 'integer' || filter.type === 'float') {
return this._buildQueryFromNumberFilter(fieldDef, filter);
}

Expand Down
1 change: 1 addition & 0 deletions frontend/app/scripts/services/ui/GlobalSearchSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
} else {
switch(fieldDef.type) {
case 'number':
case 'integer':
return {
value: Number.parseInt(value.id)
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/views/directives/dashboard/filter-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- <input ng-switch-when="number" type="number" class="form-control" ng-model="filter.value"> -->
<input ng-switch-when="text" type="text" class="form-control" ng-model="filter.value">

<div ng-switch-when="number" class="row">
<div ng-switch-when="number|integer|float" ng-switch-when-separator="|" class="row">
<div class="col-xs-2 ph-0" uib-dropdown>
<button type="button" class="btn btn-block btn-default dropdown-toggle" uib-dropdown-toggle>
{{filter.value.operator || '='}} <span class="caret"></span>
Expand All @@ -17,7 +17,7 @@
</ul>
</div>
<div class="col-xs-10 pl-xxxs">
<input type="number" class="form-control" ng-model="filter.value.value">
<input type="number" step=".01" class="form-control" ng-model="filter.value.value">
</div>
</div>

Expand Down

0 comments on commit 32185ba

Please sign in to comment.