Skip to content

Commit

Permalink
Merge pull request metabase#5618 from metabase/issue-5237
Browse files Browse the repository at this point in the history
Show true/false options correctly for boolean field value filters
  • Loading branch information
attekei authored Jul 27, 2017
2 parents 4a06b2c + 0de68ed commit 4ef778d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/metabase/lib/query/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ export function getFieldValues(field: ?Field): FieldValues {

export function getHumanReadableValue(value: Value, fieldValues?: FieldValues = []) {
const fieldValue = _.findWhere(fieldValues, { [0]: value });
return fieldValue && fieldValue.length === 2 ? fieldValue[1] : value;
return fieldValue && fieldValue.length === 2 ? fieldValue[1] : String(value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class CategoryWidget extends Component {
})}
onClick={() => { setValue(rawValue); onClose(); }}
>
{humanReadableValue || rawValue}
{humanReadableValue || String(rawValue)}
</li>
)}
</ul>
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/metabase/selectors/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,17 @@ export const getSegments = createSelector(
// MISC

export const getParameterFieldValues = (state, props) => {
return getFieldValues(getIn(state, ["metadata", "fields", props.parameter.field_id]));
const fieldValues = getFieldValues(getIn(state, ["metadata", "fields", props.parameter.field_id]));

// HACK Atte Keinänen 7/27/17: Currently the field value analysis code only returns a single value for booleans,
// this will be addressed in analysis sync refactor
const isBooleanFieldValues =
fieldValues && fieldValues.length === 1 && fieldValues[0] && typeof(fieldValues[0][0]) === "boolean"
if (isBooleanFieldValues) {
return [[true], [false]];
} else {
return fieldValues;
}
}

// UTILS:
Expand Down

0 comments on commit 4ef778d

Please sign in to comment.