Skip to content

Commit

Permalink
feat(cms/client): Add dataset short description
Browse files Browse the repository at this point in the history
SS-143
  • Loading branch information
clementprdhomme committed Nov 22, 2024
1 parent ca498fe commit 5060101
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 12 deletions.
11 changes: 10 additions & 1 deletion client/src/components/dataset-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@ import {
interface DatasetCardProps {
id: number;
name: string;
shortDescription?: string;
defaultLayerId: number | undefined;
layers: DatasetLayersDataItem[];
metadata?: MetadataItemComponent;
}

const DatasetCard = ({ id, name, defaultLayerId, layers, metadata }: DatasetCardProps) => {
const DatasetCard = ({
id,
name,
shortDescription,
defaultLayerId,
layers,
metadata,
}: DatasetCardProps) => {
const [layersConfiguration, { addLayer, updateLayer, removeLayer }] = useMapLayers();
const [location] = useLocation();

Expand Down Expand Up @@ -360,6 +368,7 @@ const DatasetCard = ({ id, name, defaultLayerId, layers, metadata }: DatasetCard
/>
</div>
</div>
{!!shortDescription && <div className="mt-1 text-sm">{shortDescription}</div>}
<div className="mt-1 flex flex-col gap-1.5">
{layers.length > 1 && (
<Select
Expand Down
5 changes: 4 additions & 1 deletion client/src/hooks/use-datasets-by-sub-topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type DatasetsBySubTopic = {
datasets: {
id: number;
name: string;
shortDescription?: string;
defaultLayerId: number | undefined;
layers: DatasetLayersDataItem[];
metadata?: MetadataItemComponent;
Expand All @@ -24,7 +25,7 @@ export default function useDatasetsBySubTopic(
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore-error
fields: ["name"],
fields: ["name", "short_description"],
populate: {
sub_topic: {
fields: ["name"],
Expand Down Expand Up @@ -63,6 +64,7 @@ export default function useDatasetsBySubTopic(
for (const item of data.data) {
const subTopic = item.attributes!.sub_topic!.data!.attributes!.name! as string;
const dataset = item.attributes!.name;
const shortDescription = item.attributes!.short_description;
const defaultLayerId = item.attributes!.default_layer!.data?.id;
const layers = item.attributes!.layers!.data!;
const metadata = item.attributes!.metadata;
Expand All @@ -76,6 +78,7 @@ export default function useDatasetsBySubTopic(
res[currentIndex].datasets.push({
id: item.id!,
name: dataset,
shortDescription,
defaultLayerId,
layers,
...(includeMetadata ? { metadata: metadata ?? undefined } : {}),
Expand Down
5 changes: 5 additions & 0 deletions client/src/types/generated/strapi.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@ export type LayerDatasetDataAttributes = {
layers?: LayerDatasetDataAttributesLayers;
metadata?: LayerDatasetDataAttributesMetadata;
name?: string;
short_description?: string;
sub_topic?: LayerDatasetDataAttributesSubTopic;
topic?: LayerDatasetDataAttributesTopic;
updatedAt?: string;
Expand Down Expand Up @@ -1699,6 +1700,7 @@ export interface Dataset {
layers?: DatasetLayers;
metadata?: MetadataItemComponent;
name: string;
short_description?: string;
sub_topic?: DatasetSubTopic;
topic?: DatasetTopic;
updatedAt?: string;
Expand Down Expand Up @@ -1822,6 +1824,7 @@ export type DatasetLayersDataItemAttributesDatasetDataAttributes = {
layers?: DatasetLayersDataItemAttributesDatasetDataAttributesLayers;
metadata?: DatasetLayersDataItemAttributesDatasetDataAttributesMetadata;
name?: string;
short_description?: string;
sub_topic?: DatasetLayersDataItemAttributesDatasetDataAttributesSubTopic;
topic?: DatasetLayersDataItemAttributesDatasetDataAttributesTopic;
updatedAt?: string;
Expand Down Expand Up @@ -2242,6 +2245,7 @@ export type DatasetRequestData = {
layers?: DatasetRequestDataLayersItem[];
metadata?: MetadataItemComponent;
name: string;
short_description?: string;
sub_topic?: DatasetRequestDataSubTopic;
topic?: DatasetRequestDataTopic;
};
Expand Down Expand Up @@ -2364,6 +2368,7 @@ export type ChartDataLayerDataAttributesDatasetDataAttributes = {
layers?: ChartDataLayerDataAttributesDatasetDataAttributesLayers;
metadata?: ChartDataLayerDataAttributesDatasetDataAttributesMetadata;
name?: string;
short_description?: string;
sub_topic?: ChartDataLayerDataAttributesDatasetDataAttributesSubTopic;
topic?: ChartDataLayerDataAttributesDatasetDataAttributesTopic;
updatedAt?: string;
Expand Down
9 changes: 6 additions & 3 deletions cms/config/sync/admin-role.strapi-super-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"metadata.spatial_resolution",
"metadata.units",
"metadata.full_name",
"metadata.temporal_resolution"
"metadata.temporal_resolution",
"short_description"
]
},
"conditions": []
Expand Down Expand Up @@ -105,7 +106,8 @@
"metadata.spatial_resolution",
"metadata.units",
"metadata.full_name",
"metadata.temporal_resolution"
"metadata.temporal_resolution",
"short_description"
]
},
"conditions": []
Expand All @@ -129,7 +131,8 @@
"metadata.spatial_resolution",
"metadata.units",
"metadata.full_name",
"metadata.temporal_resolution"
"metadata.temporal_resolution",
"short_description"
]
},
"conditions": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@
"sortable": false
}
},
"short_description": {
"edit": {
"label": "short_description",
"description": "Displayed in the dataset cards",
"placeholder": "",
"visible": true,
"editable": true
},
"list": {
"label": "short_description",
"searchable": true,
"sortable": true
}
},
"createdAt": {
"edit": {
"label": "createdAt",
Expand Down Expand Up @@ -167,12 +181,6 @@
}
},
"layouts": {
"list": [
"id",
"topic",
"sub_topic",
"name"
],
"edit": [
[
{
Expand Down Expand Up @@ -200,12 +208,24 @@
"size": 6
}
],
[
{
"name": "short_description",
"size": 12
}
],
[
{
"name": "metadata",
"size": 12
}
]
],
"list": [
"id",
"topic",
"sub_topic",
"name"
]
},
"uid": "api::dataset.dataset"
Expand Down
4 changes: 4 additions & 0 deletions cms/src/api/dataset/content-types/dataset/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
"type": "component",
"repeatable": false,
"component": "metadata.item"
},
"short_description": {
"type": "text",
"maxLength": 100
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2024-11-18T15:05:56.007Z"
"x-generation-date": "2024-11-22T10:48:59.215Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down Expand Up @@ -725,6 +725,9 @@
}
}
},
"short_description": {
"type": "string"
},
"createdAt": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -1045,6 +1048,9 @@
},
"metadata": {
"$ref": "#/components/schemas/MetadataItemComponent"
},
"short_description": {
"type": "string"
}
}
}
Expand Down Expand Up @@ -1645,6 +1651,9 @@
}
}
},
"short_description": {
"type": "string"
},
"createdAt": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -1890,6 +1899,9 @@
"metadata": {
"$ref": "#/components/schemas/MetadataItemComponent"
},
"short_description": {
"type": "string"
},
"createdAt": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -2808,6 +2820,9 @@
}
}
},
"short_description": {
"type": "string"
},
"createdAt": {
"type": "string",
"format": "date-time"
Expand Down
4 changes: 4 additions & 0 deletions cms/types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,10 @@ export interface ApiDatasetDataset extends Schema.CollectionType {
'api::sub-topic.sub-topic'
>;
metadata: Attribute.Component<'metadata.item'>;
short_description: Attribute.Text &
Attribute.SetMinMaxLength<{
maxLength: 100;
}>;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
createdBy: Attribute.Relation<
Expand Down

0 comments on commit 5060101

Please sign in to comment.