Skip to content

Commit 2e55372

Browse files
fix: local wip
1 parent 0b5f767 commit 2e55372

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

components/Charts/ChartConfigurator.vue

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@
237237
>{{ $t('Choisir quoi afficher') }}</label>
238238
<SearchableSelect
239239
id="x-axis-column"
240-
v-model="form.x_axis.column_x"
240+
v-model="xAxisColumnProxy"
241241
:label="$t('Choisir quoi afficher')"
242242
:placeholder="$t('Rechercher une colonne...')"
243243
:options="xAxisColumnOptions"
244-
:display-value="(opt: {name: string, colType: ColumnType}) => opt.name"
245-
:get-option-id="(opt: {name: string, colType: ColumnType}) => opt.name"
246-
:group-by="(opt: {name: string, colType: ColumnType}) => typeConfig[opt.colType]?.label || opt.colType"
244+
:display-value="(opt: {name: string, colType: ColumnType, resourceId: string}) => opt.name"
245+
:get-option-id="(opt: {name: string, colType: ColumnType, resourceId: string}) => opt.name"
246+
:group-by="(opt: {name: string, colType: ColumnType, resourceId: string}) => typeConfig[opt.colType]?.label || opt.colType"
247247
:multiple="false"
248248
class="w-full"
249249
>
@@ -312,7 +312,7 @@
312312
}}</label>
313313
<SearchableSelect
314314
:id="`column-y-${index}`"
315-
v-model="serie.column_y"
315+
:model-value="getSerieColumnYProxy(serie).get()"
316316
:label="$t('Colonne Y')"
317317
:placeholder="$t('Rechercher une colonne...')"
318318
:options="yAxisColumnOptions"
@@ -321,6 +321,7 @@
321321
:group-by="(opt: {name: string, colType: ColumnType}) => typeConfig[opt.colType]?.label || opt.colType"
322322
:multiple="false"
323323
class="w-full"
324+
@update:model-value="getSerieColumnYProxy(serie).set($event)"
324325
>
325326
<template #option="{ option }">
326327
<component
@@ -459,7 +460,7 @@
459460
</template>
460461

461462
<script setup lang="ts">
462-
import type { Resource, PaginatedArray, ChartForm, Chart, Filter, AndFilters, GenericFilter, Owned, ColumnType } from '@datagouv/components-next'
463+
import type { Resource, PaginatedArray, ChartForm, Chart, Filter, AndFilters, GenericFilter, Owned, ColumnType, DataSeriesType, DataSeriesForm, FilterCondition } from '@datagouv/components-next'
463464
import { resolveColumnType, buildTypeConfig, useDebouncedRef, useGetProfile, useHasTabularData, toast, BrandedButton, toChartApi, toChartForm, SearchableSelect, Listbox, useTranslation } from '@datagouv/components-next'
464465
import type { Component } from 'vue'
465466
import { computed, defineAsyncComponent, reactive, ref, watch } from 'vue'
@@ -497,11 +498,36 @@ const chartTypeProxy = computed<{ value: string, label: string, icon: Component
497498
get: () => chartTypeOptions.find(o => o.value === form.value.chart_type) ?? null,
498499
set: (val: { value: string, label: string, icon: Component } | null) => {
499500
if (val) {
500-
form.value.chart_type = val.value
501+
form.value.chart_type = val.value as DataSeriesType
501502
}
502503
},
503504
})
504505
506+
// Proxy for x_axis.column_x to handle SearchableSelect object selection
507+
const xAxisColumnProxy = computed<{ name: string, colType: ColumnType, resourceId: string } | null>({
508+
get: () => {
509+
const colName = form.value.x_axis.column_x
510+
if (!colName) return null
511+
return xAxisColumnOptions.value.find(opt => opt.name === colName) ?? null
512+
},
513+
set: (val: { name: string, colType: ColumnType, resourceId: string } | null) => {
514+
form.value.x_axis.column_x = val?.name ?? ''
515+
},
516+
})
517+
518+
// Helper to get/set column_y as object for SearchableSelect
519+
function getSerieColumnYProxy(serie: DataSeriesForm) {
520+
const get = (): { name: string, colType: ColumnType } | null => {
521+
const colName = serie.column_y
522+
if (!colName) return null
523+
return yAxisColumnOptions.value.find(opt => opt.name === colName) ?? null
524+
}
525+
const set = (val: { name: string, colType: ColumnType } | null | undefined) => {
526+
serie.column_y = val?.name ?? ''
527+
}
528+
return { get, set }
529+
}
530+
505531
const xAxisColumnOptions = computed<Array<{ name: string, colType: ColumnType, resourceId: string }>>(() => {
506532
const result: Array<{ name: string, colType: ColumnType, resourceId: string }> = []
507533
for (const [resourceId, cols] of Object.entries(columns.value)) {
@@ -551,7 +577,7 @@ const sourceText = computed<string>(() => {
551577
return `${dataset.value.title}${orgName ? ` - ${orgName}` : ''} - datagouv.fr`
552578
})
553579
554-
const conditionOptions = ['exact', 'differs', 'is_null', 'is_not_null', 'greater', 'less', 'strictly_greater', 'strictly_less'] as const
580+
const conditionOptions = ['exact', 'differs', 'is_null', 'is_not_null', 'greater', 'less', 'strictly_greater', 'strictly_less'] satisfies Array<FilterCondition>
555581
556582
const sortOptionLabels = computed<Record<string, string>>(() => {
557583
const xAxisColumn = form.value.x_axis.column_x

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"lint:fix": "eslint . --fix",
3535
"lint-staged": "lint-staged",
3636
"build": "NODE_OPTIONS=--max-old-space-size=8192 nuxt build",
37-
"typecheck": "nuxt typecheck",
37+
"typecheck": "NODE_OPTIONS=--max-old-space-size=8192 nuxt typecheck",
3838
"dev": "nuxt dev",
3939
"generate": "nuxt generate",
4040
"preview": "nuxt preview",

0 commit comments

Comments
 (0)