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 @@ + + + \ 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 @@ @@ -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 @@ @@ -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">