Skip to content

Commit

Permalink
Fix filtering on booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
stnguyen90 committed Oct 30, 2023
1 parent d4d9135 commit 1024034
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib/components/filters/content.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { tags, type Operator, queries } from './store';
import type { Column } from '$lib/helpers/types';
import type { Writable } from 'svelte/store';
import InputRadio from '$lib/elements/forms/inputRadio.svelte';
export let columns: Writable<Column[]>;
Expand Down Expand Up @@ -101,6 +102,9 @@
// This Map is keyed by tags, and has a query as the value
function addFilter() {
if (column && operator) {
if (column.type === 'boolean') {
value = value === 'true';
}
queries.addFilter({ column, operator, value: value ?? '' });
value = null;
}
Expand Down Expand Up @@ -137,6 +141,21 @@
<div class="u-margin-block-start-8">
{#if column.type === 'integer' || column.type === 'double'}
<InputNumber id="value" bind:value placeholder="Enter value" />
{:else if column.type === 'boolean'}
<div class="u-flex u-flex-horizontal u-gap-8">
<InputRadio
label="True"
id="value"
bind:group={value}
value="true"
name="value" />
<InputRadio
label="False"
id="value"
bind:group={value}
value="false"
name="value" />
</div>
{:else}
<InputText id="value" bind:value placeholder="Enter value" />
{/if}
Expand Down

0 comments on commit 1024034

Please sign in to comment.