diff --git a/src/components/InfoButton.vue b/src/components/InfoButton.vue new file mode 100644 index 00000000..22842953 --- /dev/null +++ b/src/components/InfoButton.vue @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/src/components/RecordCommonDetails.vue b/src/components/RecordCommonDetails.vue new file mode 100644 index 00000000..4b8786ee --- /dev/null +++ b/src/components/RecordCommonDetails.vue @@ -0,0 +1,104 @@ + + + + + {{ '' }} + + + + {{ $t('chr') }} + + + {{ $t('pos') }} + + + {{ $t('id') }} + + + {{ $t('ref') }} + + + {{ $t('alt') }} + + + {{ $t('qual') }} + + + {{ $t('filter') }} + + + + + {{ data.item.val }} + + + {{ data.item.val }} + + + + + + + + + + + , + + + + {{ data.item.val }} + + + {{ data.item.val }} + + + + + + + \ No newline at end of file diff --git a/src/components/RecordDetails.vue b/src/components/RecordDetails.vue index f95e13be..75a01be0 100644 --- a/src/components/RecordDetails.vue +++ b/src/components/RecordDetails.vue @@ -1,75 +1,10 @@ - - - {{ data.label ? $t(data.label) : '' }} - - - - {{ $t('chr') }} - - - {{ $t('pos') }} - - - {{ $t('id') }} - - - {{ $t('ref') }} - - - {{ $t('alt') }} - - - {{ $t('qual') }} - - - {{ $t('filter') }} - - - {{ $t('info') }} - - - {{ $t('sample') }} - - - - - {{ data.item.val }} - - - {{ data.item.val }} - - - - - - - - - - - , - - - - {{ data.item.val }} - - - {{ data.item.val }} - - - - - - {{ data.item.val[sample.index] }} - - - + + Info + + Sample + @@ -78,31 +13,16 @@ import Vue, {PropType} from 'vue' // eslint-disable-next-line no-unused-vars import {Record, RecordsMetadata, Sample} from '@molgenis/vip-report-api' - import Allele from '@/components/Allele.vue' - import Identifiers from '@/components/Identifiers.vue' + import RecordCommonDetails from '@/components/RecordCommonDetails.vue' import RecordInfoDetails from '@/components/RecordInfoDetails.vue' + import RecordSampleDetails from '@/components/RecordSampleDetails.vue' export default Vue.extend({ - components: {Allele, Identifiers, RecordInfoDetails}, + components: {RecordCommonDetails, RecordInfoDetails, RecordSampleDetails}, props: { metadata: Object as PropType, record: Object as PropType, sample: Object as PropType - }, - computed: { - fields: function () { - return [ - {key: 'key', label: 'prop'}, - {key: 'val', label: 'value'}] - }, - items() { - const items = [] - for (let key in this.record) { - const item = {key: key, val: this.record[key]} - items.push(item) - } - return items - } } }) \ No newline at end of file diff --git a/src/components/RecordInfoDetails.vue b/src/components/RecordInfoDetails.vue index 29138ecb..47f19e7f 100644 --- a/src/components/RecordInfoDetails.vue +++ b/src/components/RecordInfoDetails.vue @@ -1,21 +1,13 @@ - - - {{ $t(data.label) }} - - - - {{ data.item.key }} - - - - - + + + + {{ metadata.id }} + + + + @@ -24,40 +16,42 @@ import Vue, {PropType} from 'vue' // eslint-disable-next-line no-unused-vars import {InfoMetadata} from '@molgenis/vip-report-api' - import RecordInfoDetailsItem from '@/components/RecordInfoDetailsItem.vue' + import RecordInfoNestedDetails from '@/components/RecordInfoNestedDetails.vue' + import RecordInfoUnnestedDetails from '@/components/RecordInfoUnnestedDetails.vue' + import InfoButton from '@/components/InfoButton.vue' export default Vue.extend({ - components: {RecordInfoDetailsItem}, + components: {InfoButton, RecordInfoNestedDetails, RecordInfoUnnestedDetails}, props: { metadata: Array as PropType, info: Object as PropType }, computed: { - fields: function () { - return [ - {key: 'key', label: 'prop'}, - {key: 'val', label: 'value'}] + unnestedMetadata: function () { + const unnestedMetadata = this.metadata.filter(infoMetadata => infoMetadata.type !== 'NESTED') + unnestedMetadata.sort(this.sortMetadata) + return unnestedMetadata }, - items() { - const items = [] - for (let key in this.info) { - // fix for invalid VCF - if (key !== '') { - // @ts-ignore - const item = {key: key, val: this.info[key]} - items.push(item) - } - } - return items + nestedMetadata: function () { + const nestedMetadata = this.metadata.filter(infoMetadata => infoMetadata.type === 'NESTED') + nestedMetadata.sort(this.sortMetadata) + return nestedMetadata } }, methods: { - getInfoMetadata(key: string): InfoMetadata { - const infoMetadata = this.metadata.find(item => item.id === key) - if (infoMetadata === undefined) { - throw new Error('missing info metadata for \'' + key + '\'') + sortMetadata(thisItem: InfoMetadata, thatItem: InfoMetadata): number { + return thisItem.id.localeCompare(thatItem.id) + }, + getNestedInfo(metadata: InfoMetadata): object[] { + let nestedInfo: object[] + if(metadata.number && metadata.number.count === 1) { + // @ts-ignore + nestedInfo = [this.info[metadata.id]] + } else { + // @ts-ignore + nestedInfo = this.info[metadata.id] } - return infoMetadata + return nestedInfo } } }) diff --git a/src/components/RecordInfoDetailsItem.vue b/src/components/RecordInfoDetailsItem.vue index 426f8404..0be18c77 100644 --- a/src/components/RecordInfoDetailsItem.vue +++ b/src/components/RecordInfoDetailsItem.vue @@ -4,21 +4,11 @@ {{ value }} - - - - - {{ value }} - + {{ value }} - - - - - - {{ item }}, - + + {{ item }}, @@ -29,10 +19,8 @@ import Vue, {PropType} from 'vue' // eslint-disable-next-line no-unused-vars import {InfoMetadata} from '@molgenis/vip-report-api' - import RecordInfoNestedDetails from '@/components/RecordInfoNestedDetails.vue' export default Vue.extend({ - components: {RecordInfoNestedDetails}, props: { metadata: Object as PropType, value: [String, Number, Boolean, Array, Object] as PropType diff --git a/src/components/RecordInfoNestedDetails.vue b/src/components/RecordInfoNestedDetails.vue index 3a892476..20bb911b 100644 --- a/src/components/RecordInfoNestedDetails.vue +++ b/src/components/RecordInfoNestedDetails.vue @@ -5,7 +5,7 @@ :fields="fields" :items="items"> - {{ $t(data.label) }} + {{ data.label }} diff --git a/src/components/RecordInfoUnnestedDetails.vue b/src/components/RecordInfoUnnestedDetails.vue new file mode 100644 index 00000000..b5c3f453 --- /dev/null +++ b/src/components/RecordInfoUnnestedDetails.vue @@ -0,0 +1,70 @@ + + + + + {{ '' }} + + + + + + {{ data.item.key }} + + + + + + + + + \ No newline at end of file diff --git a/src/components/RecordSampleDetails.vue b/src/components/RecordSampleDetails.vue new file mode 100644 index 00000000..46297258 --- /dev/null +++ b/src/components/RecordSampleDetails.vue @@ -0,0 +1,18 @@ + + + + {{ data }} + + + + \ No newline at end of file diff --git a/src/components/RecordTable.vue b/src/components/RecordTable.vue index eb9fa1ac..cd1dd765 100644 --- a/src/components/RecordTable.vue +++ b/src/components/RecordTable.vue @@ -1,7 +1,8 @@ f - + + @@ -49,7 +50,7 @@ f - + @@ -58,19 +59,19 @@ f {{ data.item.c }}:{{ data.item.p | numberWithCommas }} - + - + - + , - + {{ data.item.s[sample.index].gt.p ? '|' : '/'}} @@ -88,10 +89,10 @@ f {{ data.item.s[sampleMaternal.index].gt.p ? '|' : '/'}} - + {{ data.item.q }} - + {{ filter }} , @@ -173,21 +174,23 @@ f return maternalId !== '0' ? this.getSampleById(maternalId) : null }, fields: function () { + // field keys must much report api field ids return [ {key: 'actions', label: '', class: ['compact', 'align-middle']}, - {key: 'pos', label: 'pos', sortable: true}, - {key: 'id', label: 'id'}, - {key: 'ref', label: 'ref'}, - this.sample ? {key: 'sample', label: 'sample'} : {key: 'alt', label: 'alt'}, + {key: 'p', label: 'pos', sortable: true}, + {key: 'i', label: 'id'}, + {key: 'r', label: 'ref'}, + this.sample ? {key: 's', label: 'sample'} : {key: 'a', label: 'alt'}, this.sample && this.samplePaternal ? {key: 'father', label: 'father'} : null, this.sample && this.sampleMaternal ? {key: 'mother', label: 'mother'} : null, - {key: 'qual', label: 'qual', sortable: true}, - {key: 'filter', label: 'filter'}] + {key: 'q', label: 'qual', sortable: true}, + {key: 'f', label: 'filter'}] } }, methods: { ...mapActions(['loadRecords']), provider(ctx: BvTableCtxObject) { + // todo: translate filter param to query const params: any = { page: ctx.currentPage - 1, size: ctx.perPage, diff --git a/src/locales/en.json b/src/locales/en.json index ce549df3..27391210 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -29,5 +29,6 @@ "recordDetails": "Record Details", "ok": "Ok", "prop": "Property", + "key": "Key", "value": "Value" } \ No newline at end of file diff --git a/src/plugins/bootstrap-vue.ts b/src/plugins/bootstrap-vue.ts index 693b8dfa..a7b1ccc3 100644 --- a/src/plugins/bootstrap-vue.ts +++ b/src/plugins/bootstrap-vue.ts @@ -1,9 +1,10 @@ import Vue from 'vue' -import { BootstrapVue, BIcon, BIconBoxArrowInUpRight, BIconSearch } from 'bootstrap-vue' +import { BootstrapVue, BIcon, BIconBoxArrowInUpRight, BIconQuestionCircle, BIconSearch } from 'bootstrap-vue' import 'bootstrap/dist/css/bootstrap.min.css' import 'bootstrap-vue/dist/bootstrap-vue.css' Vue.use(BootstrapVue) Vue.component('BIcon', BIcon) Vue.component('BIconBoxArrowInUpRight', BIconBoxArrowInUpRight) +Vue.component('BIconQuestionCircle', BIconQuestionCircle) Vue.component('BIconSearch', BIconSearch)