From 1b69c91215d143ccf5d631bd1226fb02a426d4c0 Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Thu, 24 Oct 2024 12:53:45 +0200 Subject: [PATCH] wip --- .../varfish_api_schema.yaml | 127 +++++++++---- .../ext/varfish-api/src/lib/schemas.gen.ts | 175 +++++++++++++----- frontend/ext/varfish-api/src/lib/types.gen.ts | 62 +++++-- ...ColumnControls.vue => ColumnsControls.vue} | 27 +-- .../components/QueryEditor/QueryEditor.vue | 165 +---------------- .../seqvars/components/QueryEditor/groups.ts | 8 + .../QueryResults/QueryResultsTable.vue | 2 +- frontend/src/seqvars/queries/seqvarQuery.ts | 6 +- 8 files changed, 289 insertions(+), 283 deletions(-) rename frontend/src/seqvars/components/QueryEditor/{ColumnControls.vue => ColumnsControls.vue} (81%) diff --git a/backend/varfish/tests/drf_openapi_schema/varfish_api_schema.yaml b/backend/varfish/tests/drf_openapi_schema/varfish_api_schema.yaml index 3cdb665a2..109c911ae 100644 --- a/backend/varfish/tests/drf_openapi_schema/varfish_api_schema.yaml +++ b/backend/varfish/tests/drf_openapi_schema/varfish_api_schema.yaml @@ -8317,8 +8317,6 @@ components: maxLength: 128 settings: $ref: '#/components/schemas/SeqvarsQuerySettingsDetailsRequest' - columnsconfig: - $ref: '#/components/schemas/SeqvarsQueryColumnsConfigRequest' PatchedSeqvarsQueryPresetsClinvarRequest: type: object description: |- @@ -8791,6 +8789,8 @@ components: $ref: '#/components/schemas/SeqvarsQuerySettingsVariantPrioRequest' clinvar: $ref: '#/components/schemas/SeqvarsQuerySettingsClinvarRequest' + columns: + $ref: '#/components/schemas/SeqvarsQuerySettingsColumnsRequest' PatchedTargetBedFileRequest: type: object description: Serializer for ``TargetBedFile``. @@ -9943,8 +9943,41 @@ components: - $ref: '#/components/schemas/SeqvarsQuerySettingsClinvarPydantic' - type: 'null' default: null + columns: + anyOf: + - $ref: '#/components/schemas/SeqvarsQuerySettingsColumnsPydantic' + - type: 'null' + default: null title: SeqvarsCaseQueryPydantic type: object + SeqvarsColumnConfigPydantic: + description: Configuration for a single column in the result table. + properties: + name: + title: Name + type: string + label: + title: Label + type: string + description: + anyOf: + - type: string + - type: 'null' + default: null + title: Description + width: + default: 100 + title: Width + type: integer + visible: + default: false + title: Visible + type: boolean + required: + - name + - label + title: SeqvarsColumnConfigPydantic + type: object SeqvarsColumnConfigPydanticList: type: array items: @@ -10424,7 +10457,6 @@ components: readOnly: true columnsconfig: type: string - format: uuid readOnly: true required: - columnsconfig @@ -10434,34 +10466,6 @@ components: - session - settings - sodar_uuid - SeqvarsQueryColumnsConfig: - type: object - description: Serializer for ``QueryColumnsConfig``. - properties: - sodar_uuid: - type: string - format: uuid - readOnly: true - date_created: - type: string - format: date-time - readOnly: true - date_modified: - type: string - format: date-time - readOnly: true - column_settings: - $ref: '#/components/schemas/SeqvarsColumnConfigPydanticList' - required: - - date_created - - date_modified - - sodar_uuid - SeqvarsQueryColumnsConfigRequest: - type: object - description: Serializer for ``QueryColumnsConfig``. - properties: - column_settings: - $ref: '#/components/schemas/SeqvarsColumnConfigPydanticList' SeqvarsQueryCreateFromRequest: type: object description: Serializer used for drf-spectacular arguments for ``SeqvarsQuerySettingsViewSet.create_from``. @@ -10509,7 +10513,8 @@ components: settings: $ref: '#/components/schemas/SeqvarsQuerySettingsDetails' columnsconfig: - $ref: '#/components/schemas/SeqvarsQueryColumnsConfig' + type: string + readOnly: true required: - columnsconfig - date_created @@ -10535,10 +10540,7 @@ components: maxLength: 128 settings: $ref: '#/components/schemas/SeqvarsQuerySettingsDetailsRequest' - columnsconfig: - $ref: '#/components/schemas/SeqvarsQueryColumnsConfigRequest' required: - - columnsconfig - label - settings SeqvarsQueryExecution: @@ -11980,9 +11982,14 @@ components: type: string format: uuid readOnly: true + columns: + type: string + format: uuid + readOnly: true required: - clinvar - clinvarpresets + - columns - columnspresets - consequence - consequencepresets @@ -12068,6 +12075,50 @@ components: allow_conflicting_interpretations: type: boolean default: false + SeqvarsQuerySettingsColumns: + type: object + description: Serializer for ``QuerySettingsColumns``. + properties: + column_settings: + $ref: '#/components/schemas/SeqvarsColumnConfigPydanticList' + sodar_uuid: + type: string + format: uuid + readOnly: true + date_created: + type: string + format: date-time + readOnly: true + date_modified: + type: string + format: date-time + readOnly: true + querysettings: + type: string + format: uuid + readOnly: true + required: + - date_created + - date_modified + - querysettings + - sodar_uuid + SeqvarsQuerySettingsColumnsPydantic: + description: Pydantic representation of ``SeqvarsQuerySettingsColumns``. + properties: + column_settings: + default: [] + items: + $ref: '#/components/schemas/SeqvarsColumnConfigPydantic' + title: Column Settings + type: array + title: SeqvarsQuerySettingsColumnsPydantic + type: object + SeqvarsQuerySettingsColumnsRequest: + type: object + description: Serializer for ``QuerySettingsColumns``. + properties: + column_settings: + $ref: '#/components/schemas/SeqvarsColumnConfigPydanticList' SeqvarsQuerySettingsConsequence: type: object description: Serializer for ``QuerySettingsConsequence``. @@ -12237,8 +12288,11 @@ components: $ref: '#/components/schemas/SeqvarsQuerySettingsVariantPrio' clinvar: $ref: '#/components/schemas/SeqvarsQuerySettingsClinvar' + columns: + $ref: '#/components/schemas/SeqvarsQuerySettingsColumns' required: - clinvar + - columns - consequence - date_created - date_modified @@ -12321,8 +12375,11 @@ components: $ref: '#/components/schemas/SeqvarsQuerySettingsVariantPrioRequest' clinvar: $ref: '#/components/schemas/SeqvarsQuerySettingsClinvarRequest' + columns: + $ref: '#/components/schemas/SeqvarsQuerySettingsColumnsRequest' required: - clinvar + - columns - consequence - frequency - genotype diff --git a/frontend/ext/varfish-api/src/lib/schemas.gen.ts b/frontend/ext/varfish-api/src/lib/schemas.gen.ts index b618ba117..14254b2f8 100644 --- a/frontend/ext/varfish-api/src/lib/schemas.gen.ts +++ b/frontend/ext/varfish-api/src/lib/schemas.gen.ts @@ -3730,9 +3730,6 @@ in detail.`, }, settings: { '$ref': '#/components/schemas/SeqvarsQuerySettingsDetailsRequest' - }, - columnsconfig: { - '$ref': '#/components/schemas/SeqvarsQueryColumnsConfigRequest' } } } as const; @@ -4459,6 +4456,9 @@ owned category settings.`, }, clinvar: { '$ref': '#/components/schemas/SeqvarsQuerySettingsClinvarRequest' + }, + columns: { + '$ref': '#/components/schemas/SeqvarsQuerySettingsColumnsRequest' } } } as const; @@ -5880,12 +5880,62 @@ export const $SeqvarsCaseQueryPydantic = { } ], default: null + }, + columns: { + anyOf: [ + { + '$ref': '#/components/schemas/SeqvarsQuerySettingsColumnsPydantic' + }, + { + type: 'null' + } + ], + default: null } }, title: 'SeqvarsCaseQueryPydantic', type: 'object' } as const; +export const $SeqvarsColumnConfigPydantic = { + description: 'Configuration for a single column in the result table.', + properties: { + name: { + title: 'Name', + type: 'string' + }, + label: { + title: 'Label', + type: 'string' + }, + description: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + default: null, + title: 'Description' + }, + width: { + default: 100, + title: 'Width', + type: 'integer' + }, + visible: { + default: false, + title: 'Visible', + type: 'boolean' + } + }, + required: ['name', 'label'], + title: 'SeqvarsColumnConfigPydantic', + type: 'object' +} as const; + export const $SeqvarsColumnConfigPydanticList = { type: 'array', items: { @@ -6567,49 +6617,12 @@ export const $SeqvarsQuery = { }, columnsconfig: { type: 'string', - format: 'uuid', readOnly: true } }, required: ['columnsconfig', 'date_created', 'date_modified', 'label', 'session', 'settings', 'sodar_uuid'] } as const; -export const $SeqvarsQueryColumnsConfig = { - type: 'object', - description: 'Serializer for ``QueryColumnsConfig``.', - properties: { - sodar_uuid: { - type: 'string', - format: 'uuid', - readOnly: true - }, - date_created: { - type: 'string', - format: 'date-time', - readOnly: true - }, - date_modified: { - type: 'string', - format: 'date-time', - readOnly: true - }, - column_settings: { - '$ref': '#/components/schemas/SeqvarsColumnConfigPydanticList' - } - }, - required: ['date_created', 'date_modified', 'sodar_uuid'] -} as const; - -export const $SeqvarsQueryColumnsConfigRequest = { - type: 'object', - description: 'Serializer for ``QueryColumnsConfig``.', - properties: { - column_settings: { - '$ref': '#/components/schemas/SeqvarsColumnConfigPydanticList' - } - } -} as const; - export const $SeqvarsQueryCreateFromRequest = { type: 'object', description: 'Serializer used for drf-spectacular arguments for ``SeqvarsQuerySettingsViewSet.create_from``.', @@ -6666,7 +6679,8 @@ in detail.`, '$ref': '#/components/schemas/SeqvarsQuerySettingsDetails' }, columnsconfig: { - '$ref': '#/components/schemas/SeqvarsQueryColumnsConfig' + type: 'string', + readOnly: true } }, required: ['columnsconfig', 'date_created', 'date_modified', 'label', 'session', 'settings', 'sodar_uuid'] @@ -6690,12 +6704,9 @@ in detail.`, }, settings: { '$ref': '#/components/schemas/SeqvarsQuerySettingsDetailsRequest' - }, - columnsconfig: { - '$ref': '#/components/schemas/SeqvarsQueryColumnsConfigRequest' } }, - required: ['columnsconfig', 'label', 'settings'] + required: ['label', 'settings'] } as const; export const $SeqvarsQueryExecution = { @@ -8643,9 +8654,14 @@ export const $SeqvarsQuerySettings = { type: 'string', format: 'uuid', readOnly: true + }, + columns: { + type: 'string', + format: 'uuid', + readOnly: true } }, - required: ['clinvar', 'clinvarpresets', 'columnspresets', 'consequence', 'consequencepresets', 'date_created', 'date_modified', 'frequency', 'frequencypresets', 'genotype', 'locus', 'locuspresets', 'phenotypeprio', 'phenotypepriopresets', 'predefinedquery', 'presetssetversion', 'quality', 'qualitypresets', 'session', 'sodar_uuid', 'variantprio', 'variantpriopresets'] + required: ['clinvar', 'clinvarpresets', 'columns', 'columnspresets', 'consequence', 'consequencepresets', 'date_created', 'date_modified', 'frequency', 'frequencypresets', 'genotype', 'locus', 'locuspresets', 'phenotypeprio', 'phenotypepriopresets', 'predefinedquery', 'presetssetversion', 'quality', 'qualitypresets', 'session', 'sodar_uuid', 'variantprio', 'variantpriopresets'] } as const; export const $SeqvarsQuerySettingsClinvar = { @@ -8731,6 +8747,63 @@ export const $SeqvarsQuerySettingsClinvarRequest = { } } as const; +export const $SeqvarsQuerySettingsColumns = { + type: 'object', + description: 'Serializer for ``QuerySettingsColumns``.', + properties: { + column_settings: { + '$ref': '#/components/schemas/SeqvarsColumnConfigPydanticList' + }, + sodar_uuid: { + type: 'string', + format: 'uuid', + readOnly: true + }, + date_created: { + type: 'string', + format: 'date-time', + readOnly: true + }, + date_modified: { + type: 'string', + format: 'date-time', + readOnly: true + }, + querysettings: { + type: 'string', + format: 'uuid', + readOnly: true + } + }, + required: ['date_created', 'date_modified', 'querysettings', 'sodar_uuid'] +} as const; + +export const $SeqvarsQuerySettingsColumnsPydantic = { + description: 'Pydantic representation of ``SeqvarsQuerySettingsColumns``.', + properties: { + column_settings: { + default: [], + items: { + '$ref': '#/components/schemas/SeqvarsColumnConfigPydantic' + }, + title: 'Column Settings', + type: 'array' + } + }, + title: 'SeqvarsQuerySettingsColumnsPydantic', + type: 'object' +} as const; + +export const $SeqvarsQuerySettingsColumnsRequest = { + type: 'object', + description: 'Serializer for ``QuerySettingsColumns``.', + properties: { + column_settings: { + '$ref': '#/components/schemas/SeqvarsColumnConfigPydanticList' + } + } +} as const; + export const $SeqvarsQuerySettingsConsequence = { type: 'object', description: 'Serializer for ``QuerySettingsConsequence``.', @@ -8962,9 +9035,12 @@ owned category settings.`, }, clinvar: { '$ref': '#/components/schemas/SeqvarsQuerySettingsClinvar' + }, + columns: { + '$ref': '#/components/schemas/SeqvarsQuerySettingsColumns' } }, - required: ['clinvar', 'consequence', 'date_created', 'date_modified', 'frequency', 'genotype', 'locus', 'phenotypeprio', 'predefinedquery', 'presetssetversion', 'quality', 'session', 'sodar_uuid', 'variantprio'] + required: ['clinvar', 'columns', 'consequence', 'date_created', 'date_modified', 'frequency', 'genotype', 'locus', 'phenotypeprio', 'predefinedquery', 'presetssetversion', 'quality', 'session', 'sodar_uuid', 'variantprio'] } as const; export const $SeqvarsQuerySettingsDetailsRequest = { @@ -9063,9 +9139,12 @@ owned category settings.`, }, clinvar: { '$ref': '#/components/schemas/SeqvarsQuerySettingsClinvarRequest' + }, + columns: { + '$ref': '#/components/schemas/SeqvarsQuerySettingsColumnsRequest' } }, - required: ['clinvar', 'consequence', 'frequency', 'genotype', 'locus', 'phenotypeprio', 'quality', 'variantprio'] + required: ['clinvar', 'columns', 'consequence', 'frequency', 'genotype', 'locus', 'phenotypeprio', 'quality', 'variantprio'] } as const; export const $SeqvarsQuerySettingsFrequency = { diff --git a/frontend/ext/varfish-api/src/lib/types.gen.ts b/frontend/ext/varfish-api/src/lib/types.gen.ts index 15a39471b..afc577039 100644 --- a/frontend/ext/varfish-api/src/lib/types.gen.ts +++ b/frontend/ext/varfish-api/src/lib/types.gen.ts @@ -1266,7 +1266,6 @@ export type PatchedSeqvarsQueryDetailsRequest = { rank?: number; label?: string; settings?: SeqvarsQuerySettingsDetailsRequest; - columnsconfig?: SeqvarsQueryColumnsConfigRequest; }; /** @@ -1457,6 +1456,7 @@ export type PatchedSeqvarsQuerySettingsDetailsRequest = { phenotypeprio?: SeqvarsQuerySettingsPhenotypePrioRequest; variantprio?: SeqvarsQuerySettingsVariantPrioRequest; clinvar?: SeqvarsQuerySettingsClinvarRequest; + columns?: SeqvarsQuerySettingsColumnsRequest; }; /** @@ -1960,6 +1960,18 @@ export type SeqvarsCaseQueryPydantic = { consequence?: (SeqvarsQuerySettingsConsequencePydantic | null); locus?: (SeqvarsQuerySettingsLocusPydantic | null); clinvar?: (SeqvarsQuerySettingsClinvarPydantic | null); + columns?: (SeqvarsQuerySettingsColumnsPydantic | null); +}; + +/** + * Configuration for a single column in the result table. + */ +export type SeqvarsColumnConfigPydantic = { + name: string; + label: string; + description?: (string | null); + width?: number; + visible?: boolean; }; export type SeqvarsColumnConfigPydanticList = Array<{ @@ -2141,23 +2153,6 @@ export type SeqvarsQuery = { readonly columnsconfig: string; }; -/** - * Serializer for ``QueryColumnsConfig``. - */ -export type SeqvarsQueryColumnsConfig = { - readonly sodar_uuid: string; - readonly date_created: string; - readonly date_modified: string; - column_settings?: SeqvarsColumnConfigPydanticList; -}; - -/** - * Serializer for ``QueryColumnsConfig``. - */ -export type SeqvarsQueryColumnsConfigRequest = { - column_settings?: SeqvarsColumnConfigPydanticList; -}; - /** * Serializer used for drf-spectacular arguments for ``SeqvarsQuerySettingsViewSet.create_from``. */ @@ -2180,7 +2175,7 @@ export type SeqvarsQueryDetails = { label: string; readonly session: string; settings: SeqvarsQuerySettingsDetails; - columnsconfig: SeqvarsQueryColumnsConfig; + readonly columnsconfig: string; }; /** @@ -2193,7 +2188,6 @@ export type SeqvarsQueryDetailsRequest = { rank?: number; label: string; settings: SeqvarsQuerySettingsDetailsRequest; - columnsconfig: SeqvarsQueryColumnsConfigRequest; }; /** @@ -2697,6 +2691,7 @@ export type SeqvarsQuerySettings = { readonly phenotypeprio: string; readonly variantprio: string; readonly clinvar: string; + readonly columns: string; }; /** @@ -2730,6 +2725,31 @@ export type SeqvarsQuerySettingsClinvarRequest = { allow_conflicting_interpretations?: boolean; }; +/** + * Serializer for ``QuerySettingsColumns``. + */ +export type SeqvarsQuerySettingsColumns = { + column_settings?: SeqvarsColumnConfigPydanticList; + readonly sodar_uuid: string; + readonly date_created: string; + readonly date_modified: string; + readonly querysettings: string; +}; + +/** + * Pydantic representation of ``SeqvarsQuerySettingsColumns``. + */ +export type SeqvarsQuerySettingsColumnsPydantic = { + column_settings?: Array; +}; + +/** + * Serializer for ``QuerySettingsColumns``. + */ +export type SeqvarsQuerySettingsColumnsRequest = { + column_settings?: SeqvarsColumnConfigPydanticList; +}; + /** * Serializer for ``QuerySettingsConsequence``. */ @@ -2796,6 +2816,7 @@ export type SeqvarsQuerySettingsDetails = { phenotypeprio: SeqvarsQuerySettingsPhenotypePrio; variantprio: SeqvarsQuerySettingsVariantPrio; clinvar: SeqvarsQuerySettingsClinvar; + columns: SeqvarsQuerySettingsColumns; }; /** @@ -2824,6 +2845,7 @@ export type SeqvarsQuerySettingsDetailsRequest = { phenotypeprio: SeqvarsQuerySettingsPhenotypePrioRequest; variantprio: SeqvarsQuerySettingsVariantPrioRequest; clinvar: SeqvarsQuerySettingsClinvarRequest; + columns: SeqvarsQuerySettingsColumnsRequest; }; /** diff --git a/frontend/src/seqvars/components/QueryEditor/ColumnControls.vue b/frontend/src/seqvars/components/QueryEditor/ColumnsControls.vue similarity index 81% rename from frontend/src/seqvars/components/QueryEditor/ColumnControls.vue rename to frontend/src/seqvars/components/QueryEditor/ColumnsControls.vue index 42f31c3e4..2172ca491 100644 --- a/frontend/src/seqvars/components/QueryEditor/ColumnControls.vue +++ b/frontend/src/seqvars/components/QueryEditor/ColumnsControls.vue @@ -33,17 +33,20 @@ const seqvarQueryUpdate = useSeqvarQueryUpdateMutation() const applyMutation = async (data: { name: string; visible: boolean }) => { const newData = { ...props.modelValue, - columnsconfig: { - ...props.modelValue.columnsconfig, - column_settings: ( - props.modelValue.columnsconfig.column_settings || [] - ).map((column) => { - const res = { - ...column, - visible: data.name === column.name ? data.visible : column.visible, - } - return res - }), + settings: { + ...props.modelValue.settings, + columns: { + ...props.modelValue.settings.columns, + column_settings: ( + props.modelValue.settings.columns.column_settings || [] + ).map((column) => { + const res = { + ...column, + visible: data.name === column.name ? data.visible : column.visible, + } + return res + }), + }, }, } @@ -62,7 +65,7 @@ const applyMutation = async (data: { name: string; visible: boolean }) => { - - - - - diff --git a/frontend/src/seqvars/components/QueryEditor/groups.ts b/frontend/src/seqvars/components/QueryEditor/groups.ts index 416f0d4f4..e6e690990 100644 --- a/frontend/src/seqvars/components/QueryEditor/groups.ts +++ b/frontend/src/seqvars/components/QueryEditor/groups.ts @@ -18,6 +18,7 @@ import ClinvarControls from './ClinvarControls.vue' import EffectsControls from './EffectsControls.vue' import FrequencyControls from './FrequencyControls.vue' import LocusControls from './LocusControls.vue' +import ColumnsControls from './ColumnsControls.vue' import PathogenicityPrioControls from './PathogenicityPrioControls.vue' import PhenotypePrioControls from './PhenotypePrioControls.vue' import QualityControls from './QualityControls.vue' @@ -175,6 +176,13 @@ export const GROUPS = [ getCompareFields: (v) => [v.gene_panels, v.genes, v.genome_regions], Component: LocusControls, }), + + new FilterGroup({ + id: 'columns', + title: 'Columns', + getCompareFields: (v) => [v.column_settings], + Component: ColumnsControls, + }), ] export const createGenotypeFromPreset = ( diff --git a/frontend/src/seqvars/components/QueryResults/QueryResultsTable.vue b/frontend/src/seqvars/components/QueryResults/QueryResultsTable.vue index 935c1e7ae..efbbf43d9 100644 --- a/frontend/src/seqvars/components/QueryResults/QueryResultsTable.vue +++ b/frontend/src/seqvars/components/QueryResults/QueryResultsTable.vue @@ -154,7 +154,7 @@ const headers = computed(() => { const formatColumns = [] // Collect `INFO` headers. - for (const column of seqvarQueryRes.data.value?.columnsconfig + for (const column of seqvarQueryRes.data.value?.settings.columns .column_settings ?? []) { if (column.visible) { if (column.name.includes('__SAMPLE__')) { diff --git a/frontend/src/seqvars/queries/seqvarQuery.ts b/frontend/src/seqvars/queries/seqvarQuery.ts index 95dc70684..5358aa71e 100644 --- a/frontend/src/seqvars/queries/seqvarQuery.ts +++ b/frontend/src/seqvars/queries/seqvarQuery.ts @@ -230,12 +230,12 @@ export const useSeqvarQueryUpdateMutation = () => { : deepmergeCustom({ mergeArrays: false })(previousValue, data.body) if ( newValue !== undefined && - data.body.columnsconfig.column_settings !== undefined + data.body.settings.columns.column_settings !== undefined ) { // Need to manually clone the column settings as we disable merging of // arrays in `deepmergeCustom()` call. - newValue.columnsconfig.column_settings = structuredClone( - toRaw(data.body.columnsconfig.column_settings), + newValue.settings.columns.column_settings = structuredClone( + toRaw(data.body.settings.columns.column_settings), ) } queryClient.setQueryData(queryKey, newValue)