Skip to content

Commit

Permalink
Update UI filter
Browse files Browse the repository at this point in the history
  • Loading branch information
dexamundsen committed Feb 6, 2025
1 parent 12d2ef0 commit 3a474fe
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
41 changes: 34 additions & 7 deletions ui/src/criteria/filterableGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1190,16 +1190,43 @@ function generateFilters(
},
});
} else {
operands.push({
filterType: tanagra.FilterFilterTypeEnum.Attribute,
filterUnion: {
attributeFilter: {
attribute: vd.attribute,
operator: tanagra.AttributeFilterOperatorEnum.In,
values: vd.selected.map((s) => literalFromDataValue(s.value)),
const operandFilter: tanagra.Filter[] = [
{
filterType: tanagra.FilterFilterTypeEnum.Attribute,
filterUnion: {
attributeFilter: {
attribute: vd.attribute,
operator: tanagra.AttributeFilterOperatorEnum.In,
values: [],
},
},
},
];

vd.selected.forEach((s) => {
const sLiteral = literalFromDataValue(s.value);
if (s.value === null) {
// 'n/a' is selected: entries with no value for this attribute
operandFilter.push({
filterType: tanagra.FilterFilterTypeEnum.Attribute,
filterUnion: {
attributeFilter: {
attribute: vd.attribute,
operator: tanagra.AttributeFilterOperatorEnum.IsEmptyString,
},
},
});
} else {
operandFilter[0].filterUnion?.attributeFilter?.values?.push(sLiteral);
}
});

operands.push(
makeBooleanLogicFilter(
tanagra.BooleanLogicFilterOperatorEnum.Or,
operandFilter
) as tanagra.Filter
);
}
});

Expand Down
6 changes: 3 additions & 3 deletions ui/src/data/source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1606,9 +1606,9 @@ function isInternalAttribute(attribute: string): boolean {
}

export function literalFromDataValue(value: DataValue): tanagra.Literal {
let dataType = tanagra.DataType.String;
if (typeof value === "bigint") {
dataType = tanagra.DataType.Int64;
let dataType = tanagra.DataType.Int64;
if (typeof value === "string") {
dataType = tanagra.DataType.String;
} else if (typeof value === "boolean") {
dataType = tanagra.DataType.Boolean;
} else if (value instanceof Date) {
Expand Down

0 comments on commit 3a474fe

Please sign in to comment.