mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 09:28:51 +00:00
Merge pull request #863 from getredash/fix/filters_datetime
Fix: properly show date/time in filters
This commit is contained in:
commit
3328de3462
@ -327,13 +327,15 @@
|
||||
QueryResult.prototype.prepareFilters = function () {
|
||||
var filters = [];
|
||||
var filterTypes = ['filter', 'multi-filter', 'multiFilter'];
|
||||
_.each(this.getColumnNames(), function (col) {
|
||||
var type = col.split('::')[1] || col.split('__')[1];
|
||||
_.each(this.getColumns(), function (col) {
|
||||
var name = col.name;
|
||||
var type = name.split('::')[1] || name.split('__')[1];
|
||||
if (_.contains(filterTypes, type)) {
|
||||
// filter found
|
||||
var filter = {
|
||||
name: col,
|
||||
friendlyName: this.getColumnFriendlyName(col),
|
||||
name: name,
|
||||
friendlyName: this.getColumnFriendlyName(name),
|
||||
column: col,
|
||||
values: [],
|
||||
multiple: (type=='multiFilter') || (type=='multi-filter')
|
||||
}
|
||||
|
@ -107,6 +107,27 @@
|
||||
};
|
||||
};
|
||||
|
||||
var FilterValueFilter = function() {
|
||||
return function(value, filter) {
|
||||
if (_.isArray(value)) {
|
||||
value = value[0];
|
||||
}
|
||||
|
||||
// TODO: deduplicate code with table.js:
|
||||
if (filter.column.type === 'date') {
|
||||
if (value && moment.isMoment(value)) {
|
||||
return value.format(clientConfig.dateFormat);
|
||||
}
|
||||
} else if (filter.column.type === 'datetime') {
|
||||
if (value && moment.isMoment(value)) {
|
||||
return value.format(clientConfig.dateTimeFormat);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
};
|
||||
|
||||
var EditVisualizationForm = function (Events, Visualization, growl) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
@ -219,5 +240,6 @@
|
||||
.directive('visualizationName', ['Visualization', VisualizationName])
|
||||
.directive('embedCode', EmbedCode)
|
||||
.directive('filters', Filters)
|
||||
.filter('filterValue', FilterValueFilter)
|
||||
.directive('editVisulatizationForm', ['Events', 'Visualization', 'growl', EditVisualizationForm]);
|
||||
})();
|
||||
|
@ -1,16 +1,16 @@
|
||||
<div class="well well-sm filters-container" ng-show="filters">
|
||||
<div class="filter" ng-repeat="filter in filters">
|
||||
<ui-select ng-model="filter.current" ng-if="!filter.multiple">
|
||||
<ui-select-match placeholder="Select value for {{filter.friendlyName}}...">{{filter.friendlyName}}: {{$select.selected}}</ui-select-match>
|
||||
<ui-select-match placeholder="Select value for {{filter.friendlyName}}...">{{filter.friendlyName}}: {{$select.selected | filterValue:filter}}</ui-select-match>
|
||||
<ui-select-choices repeat="value in filter.values | filter: $select.search">
|
||||
{{value}}
|
||||
{{value | filterValue:filter }}
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
|
||||
<ui-select ng-model="filter.current" multiple ng-if="filter.multiple">
|
||||
<ui-select-match placeholder="Select value for {{filter.friendlyName}}...">{{filter.friendlyName}}: {{$item}}</ui-select-match>
|
||||
<ui-select-match placeholder="Select value for {{filter.friendlyName}}...">{{filter.friendlyName}}: {{$item | filterValue:filter}}</ui-select-match>
|
||||
<ui-select-choices repeat="value in filter.values | filter: $select.search">
|
||||
{{value}}
|
||||
{{value | filterValue:filter }}
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user