Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5b211bf
added spatial columns
ArnabChatterjee20k Aug 29, 2025
80c2ef5
added spatial index
ArnabChatterjee20k Sep 1, 2025
608a55e
updated console package version
ArnabChatterjee20k Sep 4, 2025
3c2802d
updated point column creation
ArnabChatterjee20k Sep 4, 2025
b6596db
updated point column
ArnabChatterjee20k Sep 4, 2025
83d9258
added a input shape component for adding coordinates
ArnabChatterjee20k Sep 4, 2025
b10916c
updated point with input shape component
ArnabChatterjee20k Sep 4, 2025
a019c99
updated spatial type and individual spatial input componet
ArnabChatterjee20k Sep 4, 2025
76d49ae
updated column types
ArnabChatterjee20k Sep 4, 2025
86a4c85
added rows in the spreadsheet and row creation
ArnabChatterjee20k Sep 4, 2025
85c1a14
add delete option for the points
ArnabChatterjee20k Sep 4, 2025
89a3323
Merge remote-tracking branch 'origin/main' into spatial-type-attributes
ArnabChatterjee20k Sep 5, 2025
966bc6b
added the spatial view in the spreadsheet
ArnabChatterjee20k Sep 5, 2025
0a03c56
* updated sdk
ArnabChatterjee20k Sep 6, 2025
8a5eca9
Refactor spatial input components to use nullable properties and defa…
ArnabChatterjee20k Sep 6, 2025
fe7ea41
Add InputPolygon component and enhance spatial input handling
ArnabChatterjee20k Sep 6, 2025
90fd508
Implement onChangePoint handlers for spatial input components and upd…
ArnabChatterjee20k Sep 6, 2025
f543fd3
Enhance spatial input handling by adding support for distance-based o…
ArnabChatterjee20k Sep 8, 2025
ae7c57b
Refactor spatial input components to improve delete point logic and e…
ArnabChatterjee20k Sep 8, 2025
c9f2395
Enhance layout of input components by adding gaps for better spacing …
ArnabChatterjee20k Sep 8, 2025
fb68793
Enhance spatial input components by adding default handling logic and…
ArnabChatterjee20k Sep 8, 2025
36cf38b
linting
ArnabChatterjee20k Sep 9, 2025
2530966
linting
ArnabChatterjee20k Sep 9, 2025
64ec31f
Merge remote-tracking branch 'origin/main' into spatial-type-attributes
ArnabChatterjee20k Sep 9, 2025
cd9f328
linting
ArnabChatterjee20k Sep 9, 2025
3eb3c2c
* svelte 5 migration
ArnabChatterjee20k Sep 9, 2025
74129b2
fixed reactivity issues for the updates
ArnabChatterjee20k Sep 10, 2025
e532775
added inline editing feature for spatial types
ArnabChatterjee20k Sep 10, 2025
a13b009
updated spatial index creation flow
ArnabChatterjee20k Sep 10, 2025
5f0facd
replaced nullable state with derived
ArnabChatterjee20k Sep 11, 2025
45f0ace
refactor: update pink-icons and pink-svelte dependencies; adjust rela…
ArnabChatterjee20k Sep 11, 2025
372d5a7
Merge remote-tracking branch 'origin/main' into spatial-type-attributes
ArnabChatterjee20k Sep 11, 2025
4b1bc65
pr followups
ArnabChatterjee20k Sep 12, 2025
f081620
feat: enhance spatial type handling in filters and add NotContains op…
ArnabChatterjee20k Sep 12, 2025
bf83c00
Merge remote-tracking branch 'origin' into spatial-type-attributes
ArnabChatterjee20k Sep 12, 2025
8a42ce8
improved index creation flow
ArnabChatterjee20k Sep 12, 2025
2feb2dd
added filteration of index while index creation
ArnabChatterjee20k Sep 12, 2025
0fe444a
added faker sample data gen for the spatial types
ArnabChatterjee20k Sep 15, 2025
4f7949a
fix method signature for the linestring update point
ArnabChatterjee20k Sep 15, 2025
20815ad
fixed external index creation
ArnabChatterjee20k Sep 15, 2025
afce403
* added faker columns
ArnabChatterjee20k Sep 16, 2025
324a5ed
Merge remote-tracking branch 'origin/main' into spatial-type-attributes
ArnabChatterjee20k Sep 17, 2025
b6835e9
updated svelte
ArnabChatterjee20k Sep 17, 2025
0d43ca0
updated types
ArnabChatterjee20k Sep 17, 2025
b102b8c
reverted and sticking with the pnpm lock of main to have a stable 4.1.5
ArnabChatterjee20k Sep 17, 2025
a335ecd
types update
ArnabChatterjee20k Sep 17, 2025
211649d
updated default state of the point and polygon
ArnabChatterjee20k Sep 17, 2025
7640efd
updated the step count for point to 0.0001
ArnabChatterjee20k Sep 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
"@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@6031134",
"@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@7747562",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@f4da718",
"@appwrite.io/pink-legacy": "^1.0.3",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 60 additions & 3 deletions src/lib/components/filters/content.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
InputText,
InputTags,
InputSelectCheckbox,
InputDateTime
InputDateTime,
InputPoint
} from '$lib/elements/forms';
import { onMount, createEventDispatcher } from 'svelte';
import { operators, addFilter, queries, tags } from './store';
import { operators, addFilter, queries, tags, ValidOperators } from './store';
import type { Column } from '$lib/helpers/types';
import type { Writable } from 'svelte/store';
import { TagList } from '.';
Expand All @@ -18,6 +19,7 @@
let {
value = $bindable(null),
distanceValue = $bindable(null),
columns,
columnId = $bindable(null),
arrayValues = $bindable([]),
Expand All @@ -27,6 +29,7 @@
// We cast to any to not cause type errors in the input components
/* eslint @typescript-eslint/no-explicit-any: 'off' */
value?: any;
distanceValue?: number | null;
columns: Writable<Column[]>;
columnId?: string | null;
arrayValues?: string[];
Expand Down Expand Up @@ -61,21 +64,57 @@
}));
});
// Check if the current operator is a distance-based operator
let isDistanceOperator = $derived(
operatorKey &&
[
ValidOperators.DistanceEqual,
ValidOperators.DistanceNotEqual,
ValidOperators.DistanceGreaterThan,
ValidOperators.DistanceLessThan
].includes(operatorKey as ValidOperators)
);
onMount(() => {
value = column?.array ? [] : null;
if (column?.type === 'datetime') {
const now = new Date();
value = now.toISOString().slice(0, 16);
}
// Initialize spatial data with default values
if (column?.type === 'point') {
value = [0, 0];
} else if (column?.type === 'linestring') {
value = [
[0, 0],
[1, 1]
];
} else if (column?.type === 'polygon') {
value = [
[
[0, 0],
[1, 1],
[2, 2],
[0, 0]
]
];
}
});
const dispatch = createEventDispatcher<{ clear: void; apply: { applied: number } }>();
function addFilterAndReset() {
addFilter(columnsArray, columnId, operatorKey, value, arrayValues);
// For distance operators, pass the distance as a separate parameter
if (isDistanceOperator && distanceValue !== null && value !== null) {
addFilter(columnsArray, columnId, operatorKey, value, arrayValues, distanceValue);
} else {
addFilter(columnsArray, columnId, operatorKey, value, arrayValues);
}
Comment on lines 106 to +113
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Don’t add distance filters without a geometry; guard the call to addFilter.

As written, distance operators fall back to the non-distance call when value is null, yielding an invalid filter. Block submission unless both are present.

-        // For distance operators, pass the distance as a separate parameter
-        if (isDistanceOperator && distanceValue !== null && value !== null) {
-            addFilter(columnsArray, columnId, operatorKey, value, arrayValues, distanceValue);
-        } else {
-            addFilter(columnsArray, columnId, operatorKey, value, arrayValues);
-        }
+        // For distance operators, require both geometry and distance
+        if (isDistanceOperator) {
+            if (distanceValue == null || value == null) return;
+            addFilter(columnsArray, columnId, operatorKey, value, arrayValues, distanceValue);
+        } else {
+            addFilter(columnsArray, columnId, operatorKey, value, arrayValues);
+        }

Optional UX: also disable the submit button when missing inputs:

<!-- change at the Button below -->
<Button text disabled={isDisabled || (isDistanceOperator && (distanceValue == null || value == null))} class="u-margin-block-start-4" submit>

Also applies to: 117-118

🤖 Prompt for AI Agents
In src/lib/components/filters/content.svelte around lines 106–113 (and similarly
at 117–118), the code sometimes calls addFilter without a geometry when using
distance operators, producing invalid filters; update addFilterAndReset to only
call the distance-variant when both distanceValue and value are non-null and
otherwise do not call addFilter (return early or show validation), and update
the submit Button to include a disabled condition for distance operators
(disabled when isDistanceOperator && (distanceValue == null || value == null))
so the user cannot submit until both inputs are present.

columnId = null;
operatorKey = null;
value = null;
distanceValue = null;
arrayValues = [];
dispatch('apply', { applied: appliedTags.length });
if (singleCondition) {
Expand Down Expand Up @@ -143,11 +182,29 @@
{#key value}
<InputDateTime id="value" bind:value step={60} type="datetime-local" />
{/key}
{:else if column.type === 'point' || column.type === 'linestring' || column.type === 'polygon'}
<InputPoint
values={value || [0, 0]}
onChangePoint={(index, newValue) => {
if (!value) value = [0, 0];
value[index] = newValue;
}} />
Comment on lines +185 to +191
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Wrong input component for linestring/polygon and non-reactive mutation

  • InputPoint is used for linestring/polygon, causing shape mismatch and likely runtime errors.
  • Direct mutation (value[index] = …) won’t trigger updates reliably; reassign to a new array.
-                    {:else if column.type === 'point' || column.type === 'linestring' || column.type === 'polygon'}
-                        <InputPoint
-                            values={value || [0, 0]}
-                            onChangePoint={(index, newValue) => {
-                                if (!value) value = [0, 0];
-                                value[index] = newValue;
-                            }} />
+                    {:else if column.type === 'point'}
+                        <InputPoint
+                            values={value ?? [0, 0]}
+                            onChangePoint={(index, newValue) => {
+                                const next = [...(value ?? [0, 0])];
+                                next[index] = newValue;
+                                value = next;
+                            }} />
+                    {:else if column.type === 'linestring'}
+                        <InputLine
+                            values={value ?? [[0, 0], [1, 0]]}
+                            onChangeLine={(next) => {
+                                value = next;
+                            }} />
+                    {:else if column.type === 'polygon'}
+                        <InputPolygon
+                            values={value ?? [[[0, 0],[1, 0],[1, 1],[0, 1],[0, 0]]]}
+                            onChangePolygon={(next) => {
+                                value = next;
+                            }} />

Run to confirm the event/prop API for these inputs (adjust handlers/bindings accordingly):


🏁 Script executed:

#!/bin/bash
# Inspect spatial input components for prop and event names
fd -t f 'input(point|line|polygon).svelte' src | xargs -I{} sh -c 'echo "---- {} ----"; rg -n "export let|createEventDispatcher|dispatch|onChange" -n {} -C2'

Length of output: 2774


Use correct spatial inputs and reassign arrays for reactivity (content.svelte:172-178)

  • point
    <InputPoint> is fine, but replace in-place mutation with:

    const next = [...(value ?? [0,0])];
    next[index] = newValue;
    value = next;
  • linestring
    • Swap to <InputLine values={value ?? [[0,0],[1,0]]}
    • Use its exported onChangePoint —not onChangeLine—e.g.:

    onChangePoint={(ptIdx, coordIdx, newVal) => {
      const next = value?.map(line => [...line]) ?? [[0,0],[1,0]];
      next[ptIdx][coordIdx] = newVal;
      value = next;
    }}

    • Wire up onAddPoint, onDeletePoint, disableDeleteLine, disableDeletePointsIndex per inputLine.svelte API.

  • polygon
    • Swap to <InputPolygon values={value ?? [[[0,0],[1,0],[1,1],[0,1],[0,0]]]}
    • Use its exported onChangePoint —not onChangePolygon—e.g.:

    onChangePoint={(lineIdx, ptIdx, coordIdx, newVal) => {
      const next = value
        ?.map(line => line.map(pt => [...pt]))
        ?? [[[0,0],[1,0],[1,1],[0,1],[0,0]]];
      next[lineIdx][ptIdx][coordIdx] = newVal;
      value = next;
    }}

    • Also supply onAddPoint, onAddLine, onDeletePoint, disableDeletePointsIndex per inputPolygon.svelte API.

Ensures correct component shapes and triggers Svelte reactivity by assigning new arrays.

🤖 Prompt for AI Agents
In src/lib/components/filters/content.svelte around lines 172-178, replace the
current in-place mutations and incorrect component/handler usage with the proper
spatial inputs and immutable updates: keep InputPoint but when handling
onChangePoint create a shallow-copied array and assign value = next; for
linestrings use InputLine with a default values fallback like [[0,0],[1,0]] and
use the exported onChangePoint (not onChangeLine) to clone the nested arrays,
update the specific coordinate, and reassign value to the new structure; for
polygons use InputPolygon with a default fallback like
[[[0,0],[1,0],[1,1],[0,1],[0,0]]] and use its exported onChangePoint (not
onChangePolygon) to deep-clone lines and points, update the specific coordinate,
reassign value, and also wire up the onAddPoint, onDeletePoint, onAddLine,
disableDeleteLine/disableDeletePointsIndex props per the inputLine/inputPolygon
APIs so all updates replace arrays (value = next) to trigger Svelte reactivity.

{:else}
<InputText id="value" bind:value placeholder="Enter value" />
{/if}
</ul>
{/if}

{#if isDistanceOperator}
<div class="u-margin-block-start-8">
<InputNumber
id="distance"
bind:value={distanceValue}
placeholder="Enter distance"
step={0.001}
required />
</div>
{/if}
{/if}
{#if !singleCondition}
<Button text disabled={isDisabled} class="u-margin-block-start-4" submit>
Expand Down
24 changes: 23 additions & 1 deletion src/lib/components/filters/filters.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

/* eslint @typescript-eslint/no-explicit-any: 'off' */
let value: any = null;
let distanceValue: number | null = null;
let selectedColumn: string | null = null;
let operatorKey: string | null = null;
let arrayValues: string[] = [];
Expand All @@ -46,6 +47,16 @@

$: filtersAppliedCount = $tags.length;

// Check if the current operator is a distance-based operator
$: isDistanceOperator =
operatorKey &&
[
ValidOperators.DistanceEqual,
ValidOperators.DistanceNotEqual,
ValidOperators.DistanceGreaterThan,
ValidOperators.DistanceLessThan
].includes(operatorKey as ValidOperators);

beforeNavigate(() => {
showFiltersDesktop = false;
showFiltersMobile = false;
Expand All @@ -54,6 +65,8 @@

function clearAll() {
selectedColumn = null;
value = null;
distanceValue = null;
queries.clearAll();
if (clearOnClick) {
trackEvent(Submit.FilterClear, { source: analyticsSource });
Expand All @@ -73,9 +86,15 @@
value ||
arrayValues.length)
) {
addFilter($columns, selectedColumn, operatorKey, value, arrayValues);
// For distance operators, pass the distance as a separate parameter
if (isDistanceOperator && distanceValue !== null && value !== null) {
addFilter($columns, selectedColumn, operatorKey, value, arrayValues, distanceValue);
} else {
addFilter($columns, selectedColumn, operatorKey, value, arrayValues);
}
Comment on lines +89 to +94
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Prevent adding distance filters without a distance parameter.
Else-branch currently calls addFilter even for distance operators missing distance; that can produce invalid queries.

-            // For distance operators, pass the distance as a separate parameter
-            if (isDistanceOperator && distanceValue !== null && value !== null) {
-                addFilter($columns, selectedColumn, operatorKey, value, arrayValues, distanceValue);
-            } else {
-                addFilter($columns, selectedColumn, operatorKey, value, arrayValues);
-            }
+            // Distance operators require both a geometry value and a distance
+            if (isDistanceOperator) {
+                if (distanceValue !== null && value !== null) {
+                    addFilter($columns, selectedColumn, operatorKey, value, arrayValues, distanceValue);
+                } else {
+                    return; // guard: incomplete distance filter
+                }
+            } else {
+                addFilter($columns, selectedColumn, operatorKey, value, arrayValues);
+            }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// For distance operators, pass the distance as a separate parameter
if (isDistanceOperator && distanceValue !== null && value !== null) {
addFilter($columns, selectedColumn, operatorKey, value, arrayValues, distanceValue);
} else {
addFilter($columns, selectedColumn, operatorKey, value, arrayValues);
}
// Distance operators require both a geometry value and a distance
if (isDistanceOperator) {
if (distanceValue !== null && value !== null) {
addFilter($columns, selectedColumn, operatorKey, value, arrayValues, distanceValue);
} else {
return; // guard: incomplete distance filter
}
} else {
addFilter($columns, selectedColumn, operatorKey, value, arrayValues);
}
🤖 Prompt for AI Agents
In src/lib/components/filters/filters.svelte around lines 87–92, the else branch
calls addFilter for distance operators even when distanceValue is missing;
change the control flow so distance operators are only passed to addFilter when
distanceValue (and value) are present, and do not call addFilter for distance
operators when distanceValue is null — instead return early or surface a
validation/error message. For non-distance operators keep the existing behavior
(call addFilter when value is present). Ensure the condition explicitly checks
isDistanceOperator first, and only uses the distance-parameter overload of
addFilter when distanceValue !== null.

selectedColumn = null;
value = null;
distanceValue = null;
operatorKey = null;
arrayValues = [];
}
Expand All @@ -97,6 +116,7 @@
$: if (!showFiltersDesktop && !showFiltersMobile) {
selectedColumn = null;
value = null;
distanceValue = null;
operatorKey = null;
arrayValues = [];
}
Expand Down Expand Up @@ -163,6 +183,7 @@
bind:columnId={selectedColumn}
bind:operatorKey
bind:value
bind:distanceValue
bind:arrayValues
Comment on lines +186 to 187
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify Content.svelte supports distanceValue two-way binding with proper typing.
Ensure Content exports distanceValue as number | null and propagates it to the input control.

Also applies to: 247-248


🏁 Script executed:

#!/bin/bash
rg -nP 'export\s+let\s+distanceValue' src/lib/components/filters/content.svelte -n
rg -nP 'bind:distanceValue' src/lib/components/filters -n

Length of output: 177


Export and type distanceValue in Content.svelte.
src/lib/components/filters/content.svelte currently lacks an exported distanceValue, so the bind:distanceValue in filters.svelte won’t work. Add at the top of your <script> block:

<script lang="ts">
  export let distanceValue: number | null = null;
  //
</script>

Ensure the input in this component is using bind:value={distanceValue} (or equivalent) so changes propagate back to filters.svelte.

🤖 Prompt for AI Agents
In src/lib/components/filters/content.svelte around the top of the <script>
block (corresponding to the bind usage in
src/lib/components/filters/filters.svelte lines 184–185), add an exported, typed
prop for distanceValue (e.g. export let distanceValue: number | null = null) so
bind:distanceValue can work across components; also ensure the input in this
component uses bind:value={distanceValue} (or equivalent two-way binding) so
changes propagate back to filters.svelte.

{columns}
{singleCondition}
Expand Down Expand Up @@ -225,6 +246,7 @@
bind:columnId={selectedColumn}
bind:operatorKey
bind:value
bind:distanceValue
bind:arrayValues
{singleCondition}
on:apply={afterApply}
Expand Down
Loading