From 45785d2f3e7c7aa53320c650186f9a138eec0ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Fri, 22 Nov 2024 15:08:46 +0100 Subject: [PATCH] feat(client): Respect Sub-topic and Dataset order --- client/src/components/panels/contextual-layers/index.tsx | 7 +------ client/src/components/panels/drought/index.tsx | 1 - client/src/components/panels/flood/index.tsx | 1 - client/src/components/panels/hydrometeorological/index.tsx | 1 - client/src/hooks/use-datasets-by-sub-topic.ts | 7 +++---- client/src/hooks/use-topic-tab-layer-management.ts | 2 +- .../documentation/1.0.0/full_documentation.json | 2 +- 7 files changed, 6 insertions(+), 15 deletions(-) diff --git a/client/src/components/panels/contextual-layers/index.tsx b/client/src/components/panels/contextual-layers/index.tsx index ee6965a..5ebcd8e 100644 --- a/client/src/components/panels/contextual-layers/index.tsx +++ b/client/src/components/panels/contextual-layers/index.tsx @@ -9,12 +9,7 @@ import XMarkIcon from "@/svgs/xmark.svg"; import Item from "./item"; const ContextualLayersPanel = () => { - const { data, isLoading } = useDatasetsBySubTopic( - "contextual", - "sub_topic.name,name", - ["layer", "download_link"], - true, - ); + const { data, isLoading } = useDatasetsBySubTopic("contextual", ["layer", "download_link"], true); return ( <> diff --git a/client/src/components/panels/drought/index.tsx b/client/src/components/panels/drought/index.tsx index 2dc8c4b..c5341da 100644 --- a/client/src/components/panels/drought/index.tsx +++ b/client/src/components/panels/drought/index.tsx @@ -8,7 +8,6 @@ import useDatasetsBySubTopic from "@/hooks/use-datasets-by-sub-topic"; const DroughtPanel = () => { const { data, isLoading } = useDatasetsBySubTopic( "drought", - "sub_topic.name:desc,name", ["name", "params_config", "download_link"], true, ); diff --git a/client/src/components/panels/flood/index.tsx b/client/src/components/panels/flood/index.tsx index 597564d..0b8db01 100644 --- a/client/src/components/panels/flood/index.tsx +++ b/client/src/components/panels/flood/index.tsx @@ -8,7 +8,6 @@ import useDatasetsBySubTopic from "@/hooks/use-datasets-by-sub-topic"; const FloodPanel = () => { const { data, isLoading } = useDatasetsBySubTopic( "flood", - "sub_topic.name:desc,name", ["name", "params_config", "download_link"], true, ); diff --git a/client/src/components/panels/hydrometeorological/index.tsx b/client/src/components/panels/hydrometeorological/index.tsx index b57d1c1..6828639 100644 --- a/client/src/components/panels/hydrometeorological/index.tsx +++ b/client/src/components/panels/hydrometeorological/index.tsx @@ -9,7 +9,6 @@ import HydrometeorologicalImage from "../../../../public/assets/images/hydromete const HydrometeorologicalPanel = () => { const { data, isLoading } = useDatasetsBySubTopic( "hydrometeorological", - "sub_topic.name:desc,name", ["name", "params_config", "download_link"], true, ); diff --git a/client/src/hooks/use-datasets-by-sub-topic.ts b/client/src/hooks/use-datasets-by-sub-topic.ts index 1bd4c27..6409a4f 100644 --- a/client/src/hooks/use-datasets-by-sub-topic.ts +++ b/client/src/hooks/use-datasets-by-sub-topic.ts @@ -15,7 +15,6 @@ type DatasetsBySubTopic = { export default function useDatasetsBySubTopic( topicSlug: string, - sort = "sub_topic.name,name", layersFields = ["name"], includeMetadata = false, ) { @@ -25,10 +24,10 @@ export default function useDatasetsBySubTopic( { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore-error - fields: ["name", "short_description"], + fields: ["name", "short_description", "order"], populate: { sub_topic: { - fields: ["name"], + fields: ["name", "order"], }, default_layer: { fields: ["id"], @@ -46,7 +45,7 @@ export default function useDatasetsBySubTopic( }, }, }, - sort, + sort: "sub_topic.order,order", }, { query: { diff --git a/client/src/hooks/use-topic-tab-layer-management.ts b/client/src/hooks/use-topic-tab-layer-management.ts index b49431a..2fe3ef3 100644 --- a/client/src/hooks/use-topic-tab-layer-management.ts +++ b/client/src/hooks/use-topic-tab-layer-management.ts @@ -10,7 +10,7 @@ export default function useTopicTabLayerManagement() { const [layers, { addLayer, removeLayer }] = useMapLayers(); - const { data, isLoading } = useDatasetsBySubTopic(tab, "sub_topic.name:desc,name"); + const { data, isLoading } = useDatasetsBySubTopic(tab); // The ids of all the layers that belong to the topic const topicLayerIds = useMemo(() => { diff --git a/cms/src/extensions/documentation/documentation/1.0.0/full_documentation.json b/cms/src/extensions/documentation/documentation/1.0.0/full_documentation.json index 275220a..3785c14 100644 --- a/cms/src/extensions/documentation/documentation/1.0.0/full_documentation.json +++ b/cms/src/extensions/documentation/documentation/1.0.0/full_documentation.json @@ -14,7 +14,7 @@ "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }, - "x-generation-date": "2024-11-22T14:00:12.515Z" + "x-generation-date": "2024-11-22T14:01:53.948Z" }, "x-strapi-config": { "path": "/documentation",