From 634ab937de970fe0f4c7f7cbc52979cbb11c6ace Mon Sep 17 00:00:00 2001 From: Nicolas Kempf Le Stanc Date: Tue, 24 Feb 2026 12:39:15 +0100 Subject: [PATCH 01/23] fix(resources): fix wrong checks and refactor to provide a single function as source of truth --- components/Datasets/FileEditModal.vue | 8 ++++--- .../ResourceAccordion/ResourceAccordion.vue | 10 +++------ .../src/composables/useHasTabularData.ts | 22 +++++++++++++++++++ .../composables/useResourceCapabilities.ts | 7 +++--- datagouv-components/src/main.ts | 1 + 5 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 datagouv-components/src/composables/useHasTabularData.ts diff --git a/components/Datasets/FileEditModal.vue b/components/Datasets/FileEditModal.vue index 7532bfd2b..2dd8b0129 100644 --- a/components/Datasets/FileEditModal.vue +++ b/components/Datasets/FileEditModal.vue @@ -192,7 +192,7 @@ + + diff --git a/datagouv-components/src/main.ts b/datagouv-components/src/main.ts index 727d510f4..479204a35 100644 --- a/datagouv-components/src/main.ts +++ b/datagouv-components/src/main.ts @@ -23,6 +23,7 @@ import type { Site } from './types/site' import type { Weight, WellType } from './types/ui' import type { User, UserReference } from './types/users' import type { Report, ReportSubject, ReportReason } from './types/reports' +import type { Chart, ChartForm, FilterCondition, Filter, AndFilters, GenericFilter, XAxisType, XAxisSortBy, SortDirection, XAxis, UnitPosition, YAxis, DataSeriesType, AggregateType, DataSeries } from './types/visualizations' import type { GlobalSearchConfig, SearchType, SortOption } from './types/search' import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions } from './types/search' @@ -216,6 +217,21 @@ export type { ValidataError, Weight, WellType, + Chart, + ChartForm, + FilterCondition, + Filter, + AndFilters, + GenericFilter, + XAxisType, + XAxisSortBy, + SortDirection, + XAxis, + UnitPosition, + YAxis, + DataSeriesType, + AggregateType, + DataSeries, } export { diff --git a/datagouv-components/src/types/visualizations.ts b/datagouv-components/src/types/visualizations.ts new file mode 100644 index 000000000..b24ef4d4c --- /dev/null +++ b/datagouv-components/src/types/visualizations.ts @@ -0,0 +1,87 @@ +import type { Owned, OwnedWithId } from './owned' + +// Filter types +export type FilterCondition = 'equal' | 'greater' + +export type Filter = { + column: string + condition: FilterCondition + value?: string +} + +export type AndFilters = { + filters: Array +} + +export type GenericFilter = Filter | AndFilters + +// Axis types +export type XAxisType = 'discrete' | 'continuous' + +export type XAxisSortBy = 'axis_x' | 'axis_y' + +export type SortDirection = 'asc' | 'desc' + +export type XAxis = { + column_x: string + sort_x_by?: XAxisSortBy + sort_x_direction?: SortDirection + type: XAxisType +} + +export type UnitPosition = 'prefix' | 'suffix' + +export type YAxis = { + min?: number + max?: number + label?: string + unit?: string + unit_position?: UnitPosition +} + +// Data series types +export type DataSeriesType = 'line' | 'histogram' + +export type AggregateType = 'sum' | 'median' + +export type DataSeries = { + type: DataSeriesType + column_y?: string + aggregate_y?: AggregateType + resource_id?: string + column_x_name_override?: string + filters?: GenericFilter +} + +// Chart form fields (for POST/PATCH requests) +export type ChartForm = OwnedWithId & { + title: string + description: string + private?: boolean + x_axis?: XAxis + y_axis?: YAxis + series?: Array + extras?: Record +} + +// Chart read fields (API responses) +export type Chart = Owned & { + id: string + title: string + slug: string + description: string + private: boolean + created_at: string + last_modified: string + deleted_at: string | null + uri: string + page: string + x_axis?: XAxis + y_axis?: YAxis + series?: Array + extras: Record + permissions: { delete: boolean, edit: boolean, read: boolean } + metrics: { + views: number + } +} diff --git a/design-system/ChartConfigurator.vue b/design-system/ChartConfigurator.vue new file mode 100644 index 000000000..27ca2df5a --- /dev/null +++ b/design-system/ChartConfigurator.vue @@ -0,0 +1,293 @@ +