|
237 | 237 | >{{ $t('Choisir quoi afficher') }}</label> |
238 | 238 | <SearchableSelect |
239 | 239 | id="x-axis-column" |
240 | | - v-model="form.x_axis.column_x" |
| 240 | + v-model="xAxisColumnProxy" |
241 | 241 | :label="$t('Choisir quoi afficher')" |
242 | 242 | :placeholder="$t('Rechercher une colonne...')" |
243 | 243 | :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" |
247 | 247 | :multiple="false" |
248 | 248 | class="w-full" |
249 | 249 | > |
|
312 | 312 | }}</label> |
313 | 313 | <SearchableSelect |
314 | 314 | :id="`column-y-${index}`" |
315 | | - v-model="serie.column_y" |
| 315 | + :model-value="getSerieColumnYProxy(serie).get()" |
316 | 316 | :label="$t('Colonne Y')" |
317 | 317 | :placeholder="$t('Rechercher une colonne...')" |
318 | 318 | :options="yAxisColumnOptions" |
|
321 | 321 | :group-by="(opt: {name: string, colType: ColumnType}) => typeConfig[opt.colType]?.label || opt.colType" |
322 | 322 | :multiple="false" |
323 | 323 | class="w-full" |
| 324 | + @update:model-value="getSerieColumnYProxy(serie).set($event)" |
324 | 325 | > |
325 | 326 | <template #option="{ option }"> |
326 | 327 | <component |
|
459 | 460 | </template> |
460 | 461 |
|
461 | 462 | <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' |
463 | 464 | import { resolveColumnType, buildTypeConfig, useDebouncedRef, useGetProfile, useHasTabularData, toast, BrandedButton, toChartApi, toChartForm, SearchableSelect, Listbox, useTranslation } from '@datagouv/components-next' |
464 | 465 | import type { Component } from 'vue' |
465 | 466 | import { computed, defineAsyncComponent, reactive, ref, watch } from 'vue' |
@@ -497,11 +498,36 @@ const chartTypeProxy = computed<{ value: string, label: string, icon: Component |
497 | 498 | get: () => chartTypeOptions.find(o => o.value === form.value.chart_type) ?? null, |
498 | 499 | set: (val: { value: string, label: string, icon: Component } | null) => { |
499 | 500 | if (val) { |
500 | | - form.value.chart_type = val.value |
| 501 | + form.value.chart_type = val.value as DataSeriesType |
501 | 502 | } |
502 | 503 | }, |
503 | 504 | }) |
504 | 505 |
|
| 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 | +
|
505 | 531 | const xAxisColumnOptions = computed<Array<{ name: string, colType: ColumnType, resourceId: string }>>(() => { |
506 | 532 | const result: Array<{ name: string, colType: ColumnType, resourceId: string }> = [] |
507 | 533 | for (const [resourceId, cols] of Object.entries(columns.value)) { |
@@ -551,7 +577,7 @@ const sourceText = computed<string>(() => { |
551 | 577 | return `${dataset.value.title}${orgName ? ` - ${orgName}` : ''} - datagouv.fr` |
552 | 578 | }) |
553 | 579 |
|
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> |
555 | 581 |
|
556 | 582 | const sortOptionLabels = computed<Record<string, string>>(() => { |
557 | 583 | const xAxisColumn = form.value.x_axis.column_x |
|
0 commit comments