Skip to content

Commit

Permalink
Merge pull request #14 from molgenis/fix/small-issues
Browse files Browse the repository at this point in the history
feature: do not display empty rows and columns
  • Loading branch information
dennishendriksen authored Jun 23, 2020
2 parents 801b0a5 + 1bdd53f commit a43e3af
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/RecordInfoDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<div>
<RecordInfoUnnestedDetails :metadata="unnestedMetadata" :info="info" />
<div v-for="metadata in nestedMetadata" :key="metadata.key">
<h5>
<h4>
{{ metadata.id }}
<InfoButton :info="metadata.description" />
</h5>
</h4>
<RecordInfoNestedDetails :metadata="metadata.nested" :info="getNestedInfo(metadata)" />
</div>
</div>
Expand Down
18 changes: 12 additions & 6 deletions src/components/RecordInfoNestedDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
const fields = []
let index = 0
for (const info of this.metadata) {
fields.push({key: info.id, label: info.description, index: index, metadata: info})
// @ts-ignore
if(this.hasData(index)) {
fields.push({key: info.id, label: info.description, index: index, metadata: info})
}
++index
}
return fields
Expand All @@ -50,12 +53,15 @@
}
},
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 + '\'')
hasData(index: number): boolean {
for (let item of this.info) {
// @ts-ignore
if(!(item[index] === null || (Array.isArray(item[index]) && item[index].length === 0))) {
return true
}
}
return infoMetadata
return false
}
}
})
Expand Down
7 changes: 5 additions & 2 deletions src/components/RecordInfoUnnestedDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@
const items: object[] = []
for (let metadata of this.metadata) {
// @ts-ignore
const item = {key: metadata.id, val: this.info[metadata.id], metadata: metadata}
items.push(item)
if(this.info[metadata.id] !== undefined) {
// @ts-ignore
const item = {key: metadata.id, val: this.info[metadata.id], metadata: metadata}
items.push(item)
}
}
items.sort(function (thisItem, thatItem) {
// @ts-ignore
Expand Down

0 comments on commit a43e3af

Please sign in to comment.