From c8260123e74dbe7b958ce090f766b86647dc498f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20ROU=C3=8BN=C3=89?= Date: Tue, 31 Dec 2024 09:14:02 +0100 Subject: [PATCH] [4352] Add support to range column filters in table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-web/issues/4352 Signed-off-by: Florian ROUËNÉ --- CHANGELOG.adoc | 2 +- .../sirius/components/core/URLParser.java | 27 ++++++-- .../components/core/URLParserTests.java | 58 +++++++++++++++++ ...ableRepresentationDescriptionProvider.java | 62 +++++++++++++++++-- ...TableColumnControllerIntegrationTests.java | 8 +-- ...PapayaTableControllerIntegrationTests.java | 7 ++- .../tables/TableIconURLControllerTests.java | 12 ++-- .../backend/sirius-components-tables/pom.xml | 6 +- .../components/tables/ColumnFilterMapped.java | 29 +++++++++ .../tables/components/TableComponent.java | 25 +++++++- .../src/columns/useTableColumnFiltering.ts | 14 ++++- .../src/representation/tableIdProvider.ts | 2 +- 12 files changed, 220 insertions(+), 32 deletions(-) create mode 100644 packages/core/backend/sirius-components-core/src/test/java/org/eclipse/sirius/components/core/URLParserTests.java create mode 100644 packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/ColumnFilterMapped.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index c8806953ae..6d21de2afb 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -25,7 +25,7 @@ === Improvements - +- https://github.com/eclipse-sirius/sirius-web/issues/4352[#4352] [table] Add support to range column filters in table == v2025.1.0 diff --git a/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/URLParser.java b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/URLParser.java index f31bf7938e..6a39395a97 100644 --- a/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/URLParser.java +++ b/packages/core/backend/sirius-components-core/src/main/java/org/eclipse/sirius/components/core/URLParser.java @@ -16,7 +16,6 @@ import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -56,10 +55,30 @@ public Map> getParameterValues(String kind) { @Override public List getParameterEntries(String value) { if (value.startsWith("[") && value.endsWith("]") && value.length() >= 3) { - var rawValue = value.substring(1); - rawValue = rawValue.substring(0, rawValue.indexOf("]")); - return Arrays.stream(rawValue.split(",")).toList(); + var rawValue = value.substring(1, value.length() - 1); + return this.parseEntries(rawValue); } return List.of(); } + + private List parseEntries(String rawValue) { + List entries = new ArrayList<>(); + int start = 0; + int level = 0; + + for (int i = 0; i < rawValue.length(); i++) { + char c = rawValue.charAt(i); + if (c == '[') { + level++; + } else if (c == ']') { + level--; + } else if (c == ',' && level == 0) { + entries.add(rawValue.substring(start, i).trim()); + start = i + 1; + } + } + entries.add(rawValue.substring(start).trim()); + + return entries; + } } diff --git a/packages/core/backend/sirius-components-core/src/test/java/org/eclipse/sirius/components/core/URLParserTests.java b/packages/core/backend/sirius-components-core/src/test/java/org/eclipse/sirius/components/core/URLParserTests.java new file mode 100644 index 0000000000..83c2d358a2 --- /dev/null +++ b/packages/core/backend/sirius-components-core/src/test/java/org/eclipse/sirius/components/core/URLParserTests.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2024 CEA LIST. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.core; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.junit.jupiter.api.Test; + +/** + * Tests of the URLParser. + * + * @author frouene + */ +public class URLParserTests { + + @Test + public void testGetParameterEntriesWithNestedLists() { + URLParser parser = new URLParser(); + String value = "[467ec1c3-8ba7-32dc-9d72-71a2ccad161b:[\"1\",\"\"],4752c1c3-8ba7-32dc-9d72-71a2ccad161b:[\"1\",\"2\"]]"; + List expected = List.of( + "467ec1c3-8ba7-32dc-9d72-71a2ccad161b:[\"1\",\"\"]", + "4752c1c3-8ba7-32dc-9d72-71a2ccad161b:[\"1\",\"2\"]" + ); + List result = parser.getParameterEntries(value); + assertThat(expected).isEqualTo(result); + } + + @Test + public void testGetParameterEntriesWithEmptyList() { + URLParser parser = new URLParser(); + String value = "[]"; + List expected = List.of(); + List result = parser.getParameterEntries(value); + assertThat(expected).isEqualTo(result); + } + + @Test + public void testGetParameterEntriesWithSingleElement() { + URLParser parser = new URLParser(); + String value = "[467ec1c3-8ba7-32dc-9d72-71a2ccad161b:[\"1\",\"\"]]"; + List expected = List.of("467ec1c3-8ba7-32dc-9d72-71a2ccad161b:[\"1\",\"\"]"); + List result = parser.getParameterEntries(value); + assertThat(expected).isEqualTo(result); + } + +} diff --git a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.java b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.java index 06ae925fd5..bd2952eda1 100644 --- a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.java +++ b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.java @@ -29,13 +29,14 @@ import org.eclipse.sirius.components.core.api.IEditingContextRepresentationDescriptionProvider; import org.eclipse.sirius.components.core.api.IIdentityService; import org.eclipse.sirius.components.core.api.ILabelService; +import org.eclipse.sirius.components.papaya.AnnotableElement; import org.eclipse.sirius.components.papaya.PapayaFactory; import org.eclipse.sirius.components.papaya.PapayaPackage; import org.eclipse.sirius.components.papaya.Type; import org.eclipse.sirius.components.papaya.spec.PackageSpec; import org.eclipse.sirius.components.representations.IRepresentationDescription; import org.eclipse.sirius.components.representations.VariableManager; -import org.eclipse.sirius.components.tables.ColumnFilter; +import org.eclipse.sirius.components.tables.ColumnFilterMapped; import org.eclipse.sirius.components.tables.descriptions.ColumnDescription; import org.eclipse.sirius.components.tables.descriptions.ICellDescription; import org.eclipse.sirius.components.tables.descriptions.IconLabelCellDescription; @@ -124,7 +125,7 @@ private PaginatedData getSemanticElements(VariableManager variableManager) { var direction = variableManager.get(TableRenderer.PAGINATION_DIRECTION, String.class).orElse(null); var size = variableManager.get(TableRenderer.PAGINATION_SIZE, Integer.class).orElse(0); var globalFilter = variableManager.get(TableRenderer.GLOBAL_FILTER_DATA, String.class).orElse(null); - List columnFilters = variableManager.get(TableRenderer.COLUMN_FILTERS, List.class).orElse(List.of()); + List columnFilters = variableManager.get(TableRenderer.COLUMN_FILTERS, List.class).orElse(List.of()); Predicate predicate = eObject -> { boolean isValidCandidate = eObject instanceof Type && EcoreUtil.isAncestor(self, eObject); @@ -137,10 +138,28 @@ private PaginatedData getSemanticElements(VariableManager variableManager) { isValidCandidate = isValidCandidate || type.getAnnotations().stream().anyMatch(annotation -> annotation.getName().contains(globalFilter)); } isValidCandidate = isValidCandidate && columnFilters.stream().allMatch(columnFilter -> { - if (columnFilter.id().equals("papaya.NamedElement#name")) { - return type.getName() != null && type.getName().contains(columnFilter.value()); + boolean isValidColumFilterCandidat = true; + if (columnFilter.id().equals("papaya.NamedElement#name") && !columnFilter.values().isEmpty()) { + isValidColumFilterCandidat = type.getName() != null && type.getName().contains(columnFilter.values().get(0)); + } else if (columnFilter.id().equals("papaya.Type#nbAnnotation") && columnFilter.values().size() == 2) { + int nbAnnotation = type.getAnnotations().size(); + if (columnFilter.values().get(0) != null && !columnFilter.values().get(0).isBlank()) { + try { + int minValue = Integer.parseInt(columnFilter.values().get(0)); + isValidColumFilterCandidat = minValue <= nbAnnotation; + } catch (NumberFormatException ignored) { + } + } + if (columnFilter.values().get(1) != null && !columnFilter.values().get(1).isBlank()) { + try { + int maxValue = Integer.parseInt(columnFilter.values().get(1)); + isValidColumFilterCandidat = isValidColumFilterCandidat && maxValue >= nbAnnotation; + } catch (NumberFormatException e) { + isValidColumFilterCandidat = true; + } + } } - return true; + return isValidColumFilterCandidat; }); } @@ -166,6 +185,18 @@ private List getColumnDescriptions() { .filterVariantProvider(variableManager -> "text") .build(); + ColumnDescription nbAnnotationsColumn = ColumnDescription.newColumnDescription(UUID.nameUUIDFromBytes("nbAnnotation".getBytes()).toString()) + .semanticElementsProvider(variableManager -> List.of("NbAnnotationColumn")) + .headerLabelProvider(variableManager -> "Annotation number") + .headerIconURLsProvider(variableManager -> List.of("/icons/svg/Default.svg")) + .headerIndexLabelProvider(variableManager -> "") + .targetObjectIdProvider(variableManager -> "papaya.Type#nbAnnotation") + .targetObjectKindProvider(variableManager -> "") + .initialWidthProvider(variableManager -> 250) + .isResizablePredicate(variableManager -> false) + .filterVariantProvider(variableManager -> "range") + .build(); + Function headerLabelProvider = variableManager -> variableManager.get(VariableManager.SELF, EStructuralFeature.class) .map(featureToDisplayName::get) .orElse(""); @@ -189,7 +220,7 @@ private List getColumnDescriptions() { .isResizablePredicate(variableManager -> true) .filterVariantProvider(variableManager -> "text") .build(); - return List.of(iconColumnDescription, columnDescription); + return List.of(iconColumnDescription, columnDescription, nbAnnotationsColumn); } private List getCellDescriptions() { @@ -240,6 +271,25 @@ private List getCellDescriptions() { .cellValueProvider((variableManager, columnTargetObject) -> "") .cellIconURLsProvider(iconLabelCellIconURLsProvider) .build()); + + Predicate nbAnnotationCellPredicate = variableManager -> variableManager.get(ColumnDescription.COLUMN_TARGET_OBJECT, Object.class) + .filter(String.class::isInstance) + .map(String.class::cast) + .filter(value -> value.equals("NbAnnotationColumn")) + .isPresent(); + + cellDescriptions.add(IconLabelCellDescription.newIconLabelCellDescription("nbAnnotationCells") + .canCreatePredicate(nbAnnotationCellPredicate) + .targetObjectIdProvider(variableManager -> "") + .targetObjectKindProvider(variableManager -> "") + .cellValueProvider((variableManager, columnTargetObject) -> variableManager.get(VariableManager.SELF, Object.class) + .filter(AnnotableElement.class::isInstance) + .map(AnnotableElement.class::cast) + .map(annotableElement -> annotableElement.getAnnotations().size()) + .map(String::valueOf) + .orElse("NA")) + .cellIconURLsProvider((variableManager, o) -> List.of()) + .build()); return cellDescriptions; } } diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableColumnControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableColumnControllerIntegrationTests.java index 4a1d2244a1..eae53b4dbb 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableColumnControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableColumnControllerIntegrationTests.java @@ -106,7 +106,7 @@ public void givenTableWhenColumnResizeMutationTriggeredThenTheRepresentationIsRe .map(TableRefreshedEventPayload::table) .ifPresentOrElse(table -> { assertThat(table).isNotNull(); - assertThat(table.getColumns()).hasSize(5); + assertThat(table.getColumns()).hasSize(6); columnRef.set(table.getColumns().get(1)); assertThat(table.getColumns().get(1).getWidth()).isEqualTo(180); tableId.set(table.getId()); @@ -131,7 +131,7 @@ public void givenTableWhenColumnResizeMutationTriggeredThenTheRepresentationIsRe .map(TableRefreshedEventPayload::table) .ifPresentOrElse(table -> { assertThat(table).isNotNull(); - assertThat(table.getColumns()).hasSize(5); + assertThat(table.getColumns()).hasSize(6); assertThat(table.getColumns().get(1).getWidth()).isEqualTo(50); }, () -> fail(MISSING_TABLE)); @@ -162,7 +162,7 @@ public void givenTableWhenColumnVisibilityChangesMutationTriggeredThenTheReprese .map(TableRefreshedEventPayload::table) .ifPresentOrElse(table -> { assertThat(table).isNotNull(); - assertThat(table.getColumns()).hasSize(5); + assertThat(table.getColumns()).hasSize(6); columnNameRef.set(table.getColumns().get(0)); columnDescRef.set(table.getColumns().get(1)); columnAnnotationRef.set(table.getColumns().get(2)); @@ -195,7 +195,7 @@ public void givenTableWhenColumnVisibilityChangesMutationTriggeredThenTheReprese .map(TableRefreshedEventPayload::table) .ifPresentOrElse(table -> { assertThat(table).isNotNull(); - assertThat(table.getColumns()).hasSize(5); + assertThat(table.getColumns()).hasSize(6); assertThat(table.getColumns().get(0).isHidden()).isTrue(); assertThat(table.getColumns().get(1).isHidden()).isFalse(); assertThat(table.getColumns().get(2).isHidden()).isTrue(); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableControllerIntegrationTests.java index 018815ab8a..6b0cc6a1f5 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableControllerIntegrationTests.java @@ -113,7 +113,7 @@ public void givenTableRepresentationWhenWeSubscribeToItsEventThenTheRepresentati .map(TableRefreshedEventPayload::table) .ifPresentOrElse(table -> { assertThat(table).isNotNull(); - assertThat(table.getColumns()).hasSize(5); + assertThat(table.getColumns()).hasSize(6); assertThat(table.getLines()).hasSize(2); }, () -> fail(MISSING_TABLE)); @@ -138,7 +138,7 @@ public void givenTableWhenRefreshTriggeredThenTableIsRefreshed() { .map(TableRefreshedEventPayload::table) .ifPresentOrElse(table -> { assertThat(table).isNotNull(); - assertThat(table.getColumns()).hasSize(5); + assertThat(table.getColumns()).hasSize(6); assertThat(table.getLines()).hasSize(2); tableId.set(table.getId()); @@ -189,12 +189,13 @@ public void givenTableRepresentationWithColumnHeaderWhenWeSubscribeToItsEventThe .map(TableRefreshedEventPayload::table) .ifPresentOrElse(table -> { assertThat(table).isNotNull(); - assertThat(table.getColumns()).hasSize(5); + assertThat(table.getColumns()).hasSize(6); assertThat(table.getColumns().get(0).getHeaderIndexLabel()).isEqualTo(""); assertThat(table.getColumns().get(1).getHeaderIndexLabel()).isEqualTo("A"); assertThat(table.getColumns().get(2).getHeaderIndexLabel()).isEqualTo("B"); assertThat(table.getColumns().get(3).getHeaderIndexLabel()).isEqualTo("C"); assertThat(table.getColumns().get(4).getHeaderIndexLabel()).isEqualTo("D"); + assertThat(table.getColumns().get(5).getHeaderIndexLabel()).isEqualTo(""); }, () -> fail(MISSING_TABLE)); StepVerifier.create(flux) diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/TableIconURLControllerTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/TableIconURLControllerTests.java index df04191d34..a05874878a 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/TableIconURLControllerTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/TableIconURLControllerTests.java @@ -178,14 +178,12 @@ public void givenPapayaPackageWhenWeSubscribeToTableWithIconLabelCellThenURLOfIt assertThat(typename).isEqualTo(TableRefreshedEventPayload.class.getSimpleName()); List> iconLabelCellIconURLs = JsonPath.read(body, "$.data.tableEvent.table.lines[*].cells[*].iconURLs"); - assertThat(iconLabelCellIconURLs) + assertThat(iconLabelCellIconURLs.stream().filter(iconURL -> !iconURL.isEmpty()).toList()) .isNotEmpty() - .allSatisfy(iconURLs -> { - assertThat(iconURLs) - .isNotEmpty() - .hasSize(2) - .allSatisfy(iconURL -> assertThat(iconURL).startsWith(URLConstants.IMAGE_BASE_PATH)); - }); + .allSatisfy(iconURLs -> assertThat(iconURLs) + .isNotEmpty() + .hasSize(2) + .allSatisfy(iconURL -> assertThat(iconURL).startsWith(URLConstants.IMAGE_BASE_PATH))); }, () -> fail("Missing table")); StepVerifier.create(flux) diff --git a/packages/tables/backend/sirius-components-tables/pom.xml b/packages/tables/backend/sirius-components-tables/pom.xml index a30e78be42..fd99e53a79 100644 --- a/packages/tables/backend/sirius-components-tables/pom.xml +++ b/packages/tables/backend/sirius-components-tables/pom.xml @@ -56,6 +56,10 @@ 2025.1.0 test + + com.fasterxml.jackson.core + jackson-databind + @@ -113,4 +117,4 @@ - \ No newline at end of file + diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/ColumnFilterMapped.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/ColumnFilterMapped.java new file mode 100644 index 0000000000..6e8647acf5 --- /dev/null +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/ColumnFilterMapped.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2024 CEA LIST. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.tables; + +import java.util.List; +import java.util.Objects; + +/** + * Data representing the filter of a column with column mapped to the targetObjectId. + * + * @author frouene + */ +public record ColumnFilterMapped(String id, List values) { + + public ColumnFilterMapped { + Objects.requireNonNull(id); + Objects.requireNonNull(values); + } +} diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TableComponent.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TableComponent.java index 6705962346..153ee80b0a 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TableComponent.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TableComponent.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.sirius.components.tables.components; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -23,6 +27,7 @@ import org.eclipse.sirius.components.representations.IComponent; import org.eclipse.sirius.components.representations.VariableManager; import org.eclipse.sirius.components.tables.ColumnFilter; +import org.eclipse.sirius.components.tables.ColumnFilterMapped; import org.eclipse.sirius.components.tables.PaginationData; import org.eclipse.sirius.components.tables.Table; import org.eclipse.sirius.components.tables.descriptions.PaginatedData; @@ -78,12 +83,28 @@ public Element render() { return new Element(ColumnComponent.class, columnComponentProps); }) .toList(); - + ObjectMapper objectMapper = new ObjectMapper(); var columnFiltersMapped = optionalPreviousTable .map(previousTable -> columnsFilters.stream() .map(columnFilter -> tableElementRequestor.getColumn(previousTable, columnFilter.id()) - .map(column -> new ColumnFilter(column.getTargetObjectId(), columnFilter.value())) + .map(column -> { + List columnFilterValues = new ArrayList<>(); + if (List.of("range", "range-slider").contains(column.getFilterVariant())) { + try { + columnFilterValues.addAll(objectMapper.readValue(columnFilter.value(), new TypeReference<>() { + })); + } catch (JsonProcessingException ignored) { + } + } else { + try { + columnFilterValues.add(objectMapper.readValue(columnFilter.value(), new TypeReference<>() { + })); + } catch (JsonProcessingException ignored) { + } + } + return new ColumnFilterMapped(column.getTargetObjectId(), columnFilterValues); + }) ) .filter(Optional::isPresent) .map(Optional::get) diff --git a/packages/tables/frontend/sirius-components-tables/src/columns/useTableColumnFiltering.ts b/packages/tables/frontend/sirius-components-tables/src/columns/useTableColumnFiltering.ts index 9b89372016..cd75e96f2d 100644 --- a/packages/tables/frontend/sirius-components-tables/src/columns/useTableColumnFiltering.ts +++ b/packages/tables/frontend/sirius-components-tables/src/columns/useTableColumnFiltering.ts @@ -59,7 +59,12 @@ export const useTableColumnFiltering = ( }, [columnFilters]); useEffect(() => { - setColumnFilters(table.columnFilters); + setColumnFilters( + table.columnFilters.map((filter) => ({ + id: filter.id, + value: JSON.parse(filter.value as string), + })) + ); }, [table.columnFilters.map((columnFilter) => columnFilter.id + columnFilter.value).join('')]); const [mutationChangeColumnFilter, mutationChangeColumnFilterResult] = useMutation< @@ -74,14 +79,17 @@ export const useTableColumnFiltering = ( editingContextId, representationId, tableId: table.id, - columnFilters: columnFilters.map((columnFilter) => ({ id: columnFilter.id, value: columnFilter.value })), + columnFilters: columnFilters.map((columnFilter) => ({ + id: columnFilter.id, + value: JSON.stringify(columnFilter.value), + })), }; mutationChangeColumnFilter({ variables: { input } }); }; if (!enableColumnFilters) { return { - columnFilters: undefined, + columnFilters: [], setColumnFilters: undefined, }; } diff --git a/packages/tables/frontend/sirius-components-tables/src/representation/tableIdProvider.ts b/packages/tables/frontend/sirius-components-tables/src/representation/tableIdProvider.ts index 4dd10b2d74..ce7233086d 100644 --- a/packages/tables/frontend/sirius-components-tables/src/representation/tableIdProvider.ts +++ b/packages/tables/frontend/sirius-components-tables/src/representation/tableIdProvider.ts @@ -26,7 +26,7 @@ export const tableIdProvider = ( columnFilters !== null ? `&columnFilters=[${columnFilters .map((filter) => { - return filter.id + ':' + filter.value; + return filter.id + ':' + JSON.stringify(filter.value); }) .map(encodeURIComponent) .join(',')}]`