Skip to content

Commit

Permalink
csv templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mluena committed Aug 29, 2024
1 parent d7a32d3 commit 354757e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
6 changes: 2 additions & 4 deletions client/src/containers/datasets/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ export default function EditDatasetForm() {
datasetData?.data?.attributes?.value_type,
);

const colors =
datasetEditData?.data?.attributes?.colors ||
((datasetData?.data?.attributes?.layers?.data || [])[0]?.attributes
?.colors as Data["colors"]);
const colors = (datasetEditData?.data?.attributes?.colors ||
(datasetData?.data?.attributes?.layers?.data || [])[0]?.attributes?.colors) as Data["colors"];

setFormValues({ settings, data, colors });
}, [
Expand Down
4 changes: 4 additions & 0 deletions client/src/lib/utils/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const csvTypeMapping: Record<string, string[]> = {
"objective",
"highlight",
],
"other-tools": ["name", "description", "link", "category"],
collaborators: ["name", "type", "link"],
};

// Function to generate CSV content from data
Expand Down Expand Up @@ -69,6 +71,8 @@ export function downloadCSV(
filename: string = "data.csv",
): void {
// Generate CSV content
console.log(data, type);
debugger;
const csvContent = generateCSVContent(data, type);

// Create a Blob from the CSV content
Expand Down
12 changes: 12 additions & 0 deletions client/src/types/generated/strapi.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3680,6 +3680,7 @@ export type SdgProjectsDataItemAttributesCountriesDataItemAttributesDatasetValue
export type SdgProjectsDataItemAttributesCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributes =
{
category?: SdgProjectsDataItemAttributesCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: SdgProjectsDataItemAttributesCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: SdgProjectsDataItemAttributesCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -5773,6 +5774,7 @@ export const ProjectEditSuggestionCountriesDataItemAttributesDatasetValuesDataIt
export type ProjectEditSuggestionCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributes =
{
category?: ProjectEditSuggestionCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: ProjectEditSuggestionCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: ProjectEditSuggestionCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -7076,6 +7078,7 @@ export const ProjectCountriesDataItemAttributesDatasetValuesDataItemAttributesDa
export type ProjectCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributes =
{
category?: ProjectCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: ProjectCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: ProjectCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -8508,6 +8511,7 @@ export type PillarProjectsDataItemAttributesCountriesDataItemAttributesDatasetVa
export type PillarProjectsDataItemAttributesCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributes =
{
category?: PillarProjectsDataItemAttributesCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: PillarProjectsDataItemAttributesCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: PillarProjectsDataItemAttributesCountriesDataItemAttributesDatasetValuesDataItemAttributesDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -10460,6 +10464,7 @@ export const LayerDatasetDataAttributesValueType = {

export type LayerDatasetDataAttributes = {
category?: LayerDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: LayerDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: LayerDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -11716,6 +11721,7 @@ export type DatasetValueDatasetDataAttributesLayers = {

export type DatasetValueDatasetDataAttributes = {
category?: DatasetValueDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: DatasetValueDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: DatasetValueDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -12916,6 +12922,7 @@ export type DatasetEditSuggestionCategoryDataAttributesDatasetEditSuggestionsDat
export type DatasetEditSuggestionCategoryDataAttributesDatasetEditSuggestionsDataItemAttributesLayersDataItemAttributesDatasetDataAttributes =
{
category?: DatasetEditSuggestionCategoryDataAttributesDatasetEditSuggestionsDataItemAttributesLayersDataItemAttributesDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: DatasetEditSuggestionCategoryDataAttributesDatasetEditSuggestionsDataItemAttributesLayersDataItemAttributesDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: DatasetEditSuggestionCategoryDataAttributesDatasetEditSuggestionsDataItemAttributesLayersDataItemAttributesDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -13706,6 +13713,7 @@ export const DatasetValueType = {

export interface Dataset {
category?: DatasetCategory;
colors?: unknown;
createdAt?: string;
createdBy?: DatasetCreatedBy;
dataset_edit_suggestions?: DatasetDatasetEditSuggestions;
Expand Down Expand Up @@ -13820,6 +13828,7 @@ export const DatasetLayersDataItemAttributesDatasetDataAttributesValueType = {

export type DatasetLayersDataItemAttributesDatasetDataAttributes = {
category?: DatasetLayersDataItemAttributesDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: DatasetLayersDataItemAttributesDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: DatasetLayersDataItemAttributesDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -14725,6 +14734,7 @@ export type DatasetRequestDataCategory = number | string;

export type DatasetRequestData = {
category?: DatasetRequestDataCategory;
colors?: unknown;
dataset_edit_suggestions?: DatasetRequestDataDatasetEditSuggestionsItem[];
dataset_values?: DatasetRequestDataDatasetValuesItem[];
datum: unknown;
Expand Down Expand Up @@ -14893,6 +14903,7 @@ export type CountryDatasetValuesDataItemAttributesDatasetDataAttributesLayers =

export type CountryDatasetValuesDataItemAttributesDatasetDataAttributes = {
category?: CountryDatasetValuesDataItemAttributesDatasetDataAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: CountryDatasetValuesDataItemAttributesDatasetDataAttributesCreatedBy;
dataset_edit_suggestions?: CountryDatasetValuesDataItemAttributesDatasetDataAttributesDatasetEditSuggestions;
Expand Down Expand Up @@ -18003,6 +18014,7 @@ export type CategoryDatasetEditSuggestionsDataItemAttributesCategoryDataAttribut
export type CategoryDatasetEditSuggestionsDataItemAttributesCategoryDataAttributesDatasetDataItemAttributes =
{
category?: CategoryDatasetEditSuggestionsDataItemAttributesCategoryDataAttributesDatasetDataItemAttributesCategory;
colors?: unknown;
createdAt?: string;
createdBy?: CategoryDatasetEditSuggestionsDataItemAttributesCategoryDataAttributesDatasetDataItemAttributesCreatedBy;
dataset_edit_suggestions?: CategoryDatasetEditSuggestionsDataItemAttributesCategoryDataAttributesDatasetDataItemAttributesDatasetEditSuggestions;
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 @@ -61,6 +61,9 @@
"relation": "manyToOne",
"target": "api::category.category",
"inversedBy": "dataset"
},
"colors": {
"type": "json"
}
}
}
1 change: 1 addition & 0 deletions cms/types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ export interface ApiDatasetDataset extends Schema.CollectionType {
'manyToOne',
'api::category.category'
>;
colors: Attribute.JSON;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
publishedAt: Attribute.DateTime;
Expand Down

0 comments on commit 354757e

Please sign in to comment.