Skip to content

Commit

Permalink
Merge pull request #35
Browse files Browse the repository at this point in the history
Ability to order the sub-topics and datasets
  • Loading branch information
clementprdhomme authored Nov 22, 2024
2 parents 5060101 + 45785d2 commit 6fe21d1
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 46 deletions.
7 changes: 1 addition & 6 deletions client/src/components/panels/contextual-layers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
Expand Down
1 change: 0 additions & 1 deletion client/src/components/panels/drought/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
1 change: 0 additions & 1 deletion client/src/components/panels/flood/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
1 change: 0 additions & 1 deletion client/src/components/panels/hydrometeorological/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
7 changes: 3 additions & 4 deletions client/src/hooks/use-datasets-by-sub-topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type DatasetsBySubTopic = {

export default function useDatasetsBySubTopic(
topicSlug: string,
sort = "sub_topic.name,name",
layersFields = ["name"],
includeMetadata = false,
) {
Expand All @@ -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"],
Expand All @@ -46,7 +45,7 @@ export default function useDatasetsBySubTopic(
},
},
},
sort,
sort: "sub_topic.order,order",
},
{
query: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/use-topic-tab-layer-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
10 changes: 10 additions & 0 deletions client/src/types/generated/strapi.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ export interface SubTopic {
createdAt?: string;
createdBy?: SubTopicCreatedBy;
name: string;
order?: number;
updatedAt?: string;
updatedBy?: SubTopicUpdatedBy;
}
Expand Down Expand Up @@ -763,6 +764,7 @@ export interface SubTopicListResponse {

export type SubTopicRequestData = {
name: string;
order?: number;
};

export interface SubTopicRequest {
Expand Down Expand Up @@ -1173,6 +1175,7 @@ export type LayerDatasetDataAttributes = {
layers?: LayerDatasetDataAttributesLayers;
metadata?: LayerDatasetDataAttributesMetadata;
name?: string;
order?: number;
short_description?: string;
sub_topic?: LayerDatasetDataAttributesSubTopic;
topic?: LayerDatasetDataAttributesTopic;
Expand Down Expand Up @@ -1266,6 +1269,7 @@ export type LayerDatasetDataAttributesSubTopicDataAttributes = {
createdAt?: string;
createdBy?: LayerDatasetDataAttributesSubTopicDataAttributesCreatedBy;
name?: string;
order?: number;
updatedAt?: string;
updatedBy?: LayerDatasetDataAttributesSubTopicDataAttributesUpdatedBy;
};
Expand Down Expand Up @@ -1700,6 +1704,7 @@ export interface Dataset {
layers?: DatasetLayers;
metadata?: MetadataItemComponent;
name: string;
order?: number;
short_description?: string;
sub_topic?: DatasetSubTopic;
topic?: DatasetTopic;
Expand Down Expand Up @@ -1824,6 +1829,7 @@ export type DatasetLayersDataItemAttributesDatasetDataAttributes = {
layers?: DatasetLayersDataItemAttributesDatasetDataAttributesLayers;
metadata?: DatasetLayersDataItemAttributesDatasetDataAttributesMetadata;
name?: string;
order?: number;
short_description?: string;
sub_topic?: DatasetLayersDataItemAttributesDatasetDataAttributesSubTopic;
topic?: DatasetLayersDataItemAttributesDatasetDataAttributesTopic;
Expand Down Expand Up @@ -2041,6 +2047,7 @@ export type DatasetLayersDataItemAttributesDatasetDataAttributesSubTopicDataAttr
createdAt?: string;
createdBy?: DatasetLayersDataItemAttributesDatasetDataAttributesSubTopicDataAttributesCreatedBy;
name?: string;
order?: number;
updatedAt?: string;
updatedBy?: DatasetLayersDataItemAttributesDatasetDataAttributesSubTopicDataAttributesUpdatedBy;
};
Expand Down Expand Up @@ -2245,6 +2252,7 @@ export type DatasetRequestData = {
layers?: DatasetRequestDataLayersItem[];
metadata?: MetadataItemComponent;
name: string;
order?: number;
short_description?: string;
sub_topic?: DatasetRequestDataSubTopic;
topic?: DatasetRequestDataTopic;
Expand Down Expand Up @@ -2368,6 +2376,7 @@ export type ChartDataLayerDataAttributesDatasetDataAttributes = {
layers?: ChartDataLayerDataAttributesDatasetDataAttributesLayers;
metadata?: ChartDataLayerDataAttributesDatasetDataAttributesMetadata;
name?: string;
order?: number;
short_description?: string;
sub_topic?: ChartDataLayerDataAttributesDatasetDataAttributesSubTopic;
topic?: ChartDataLayerDataAttributesDatasetDataAttributesTopic;
Expand Down Expand Up @@ -2585,6 +2594,7 @@ export type ChartDataLayerDataAttributesDatasetDataAttributesSubTopicDataAttribu
createdAt?: string;
createdBy?: ChartDataLayerDataAttributesDatasetDataAttributesSubTopicDataAttributesCreatedBy;
name?: string;
order?: number;
updatedAt?: string;
updatedBy?: ChartDataLayerDataAttributesDatasetDataAttributesSubTopicDataAttributesUpdatedBy;
};
Expand Down
18 changes: 12 additions & 6 deletions cms/config/sync/admin-role.strapi-super-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"metadata.units",
"metadata.full_name",
"metadata.temporal_resolution",
"short_description"
"short_description",
"order"
]
},
"conditions": []
Expand Down Expand Up @@ -107,7 +108,8 @@
"metadata.units",
"metadata.full_name",
"metadata.temporal_resolution",
"short_description"
"short_description",
"order"
]
},
"conditions": []
Expand All @@ -132,7 +134,8 @@
"metadata.units",
"metadata.full_name",
"metadata.temporal_resolution",
"short_description"
"short_description",
"order"
]
},
"conditions": []
Expand Down Expand Up @@ -280,7 +283,8 @@
"subject": "api::sub-topic.sub-topic",
"properties": {
"fields": [
"name"
"name",
"order"
]
},
"conditions": []
Expand All @@ -298,7 +302,8 @@
"subject": "api::sub-topic.sub-topic",
"properties": {
"fields": [
"name"
"name",
"order"
]
},
"conditions": []
Expand All @@ -309,7 +314,8 @@
"subject": "api::sub-topic.sub-topic",
"properties": {
"fields": [
"name"
"name",
"order"
]
},
"conditions": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@
"sortable": true
}
},
"order": {
"edit": {
"label": "order",
"description": "Define the order of the dataset within a sub-topic. The value is relative to the other datasets.",
"placeholder": "",
"visible": true,
"editable": true
},
"list": {
"label": "order",
"searchable": true,
"sortable": true
}
},
"createdAt": {
"edit": {
"label": "createdAt",
Expand Down Expand Up @@ -186,6 +200,10 @@
{
"name": "name",
"size": 6
},
{
"name": "order",
"size": 6
}
],
[
Expand Down Expand Up @@ -225,7 +243,8 @@
"id",
"topic",
"sub_topic",
"name"
"name",
"order"
]
},
"uid": "api::dataset.dataset"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
"sortable": true
}
},
"order": {
"edit": {
"label": "order",
"description": "Define the order of the sub-topic within a topic. The value is relative to the other sub-topics.",
"placeholder": "",
"visible": true,
"editable": true
},
"list": {
"label": "order",
"searchable": true,
"sortable": true
}
},
"createdAt": {
"edit": {
"label": "createdAt",
Expand Down Expand Up @@ -93,17 +107,22 @@
}
},
"layouts": {
"list": [
"id",
"name"
],
"edit": [
[
{
"name": "name",
"size": 6
},
{
"name": "order",
"size": 4
}
]
],
"list": [
"id",
"name",
"order"
]
},
"uid": "api::sub-topic.sub-topic"
Expand Down
3 changes: 3 additions & 0 deletions cms/src/api/dataset/content-types/dataset/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"short_description": {
"type": "text",
"maxLength": 100
},
"order": {
"type": "integer"
}
}
}
3 changes: 3 additions & 0 deletions cms/src/api/sub-topic/content-types/sub-topic/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"name": {
"type": "string",
"required": true
},
"order": {
"type": "integer"
}
}
}
Loading

0 comments on commit 6fe21d1

Please sign in to comment.