Skip to content

Commit

Permalink
Allow setting a note to show with layer filters (#11)
Browse files Browse the repository at this point in the history
* docs(changeset): Allow setting a note to show with layer filters

* Add optional note when setting layer filter
  • Loading branch information
tomhicks authored Dec 2, 2024
1 parent 6e911d9 commit 4bbde62
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-flowers-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@feltmaps/js-sdk": minor
---

Allow setting a note to show with layer filters
13 changes: 7 additions & 6 deletions docs/Layers/LayersController.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,18 @@ console.log(filters.combined, filters.style, filters.ephemeral, filters.componen

### setLayerFilters()

> **setLayerFilters**(`params`: \{`layerId`: `string`;`filters`: [`Filters`](Filters.md); }): `Promise`\<`void`>
> **setLayerFilters**(`params`: \{`layerId`: `string`;`filters`: [`Filters`](Filters.md);`note`: `string`; }): `Promise`\<`void`>
Sets the **ephemeral** filters for a layer.

#### Parameters

| Parameter | Type | Description |
| ---------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------- |
| `params` | `object` | - |
| `params.layerId` | `string` | The layer that you want to set the filters for. |
| `params.filters` | [`Filters`](Filters.md) | The filters to set for the layer. This will replace any ephemeral filters that are currently set for the layer. |
| Parameter | Type | Description |
| ---------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params` | `object` | - |
| `params.layerId` | `string` | The layer that you want to set the filters for. |
| `params.filters` | [`Filters`](Filters.md) | The filters to set for the layer. This will replace any ephemeral filters that are currently set for the layer. |
| `params.note`? | `string` | A note to display on the layer legend when this filter is applied. When the note is shown, a reset button will also be shown, allowing the user to clear the filter. |

#### Returns

Expand Down
13 changes: 7 additions & 6 deletions docs/Main/FeltController.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,17 +503,18 @@ console.log(filters.combined, filters.style, filters.ephemeral, filters.componen

### setLayerFilters()

> **setLayerFilters**(`params`: \{`layerId`: `string`;`filters`: [`Filters`](../Layers/Filters.md); }): `Promise`\<`void`>
> **setLayerFilters**(`params`: \{`layerId`: `string`;`filters`: [`Filters`](../Layers/Filters.md);`note`: `string`; }): `Promise`\<`void`>
Sets the **ephemeral** filters for a layer.

#### Parameters

| Parameter | Type | Description |
| ---------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `params` | `object` | - |
| `params.layerId` | `string` | The layer that you want to set the filters for. |
| `params.filters` | [`Filters`](../Layers/Filters.md) | The filters to set for the layer. This will replace any ephemeral filters that are currently set for the layer. |
| Parameter | Type | Description |
| ---------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params` | `object` | - |
| `params.layerId` | `string` | The layer that you want to set the filters for. |
| `params.filters` | [`Filters`](../Layers/Filters.md) | The filters to set for the layer. This will replace any ephemeral filters that are currently set for the layer. |
| `params.note`? | `string` | A note to display on the layer legend when this filter is applied. When the note is shown, a reset button will also be shown, allowing the user to clear the filter. |

#### Returns

Expand Down
1 change: 1 addition & 0 deletions etc/js-sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export interface LayersController {
setLayerFilters(params: {
layerId: string;
filters: Filters;
note?: string;
}): Promise<void>;
setLayerGroupVisibility(visibility: SetVisibilityRequest): Promise<void>;
setLayerStyle(params: {
Expand Down
7 changes: 7 additions & 0 deletions src/modules/layers/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ export interface LayersController {
* that are currently set for the layer.
*/
filters: Filters;

/**
* A note to display on the layer legend when this filter is applied. When the
* note is shown, a reset button will also be shown, allowing the user to clear
* the filter.
*/
note?: string;
}): Promise<void>;

/**
Expand Down
1 change: 1 addition & 0 deletions src/modules/layers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const SetFiltersMessage = methodMessage(
z.object({
layerId: z.string(),
filters: FiltersSchema,
note: z.string().optional(),
}),
);

Expand Down

0 comments on commit 4bbde62

Please sign in to comment.