Skip to content

Commit

Permalink
switching table column title to display name
Browse files Browse the repository at this point in the history
  • Loading branch information
havok2063 committed Aug 4, 2024
1 parent b7ee627 commit 02c7352
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/store/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ export const useAppStore = defineStore('app', {
return this.logged_in || (!this.logged_in && this.release.startsWith("DR"))
},

get_description_from_db(column: string) {
get_field_from_db(column: string, field: string) {
// looks up a db column description from the flattened db metadata
return this.flat_db[column] ? this.flat_db[column].description : null;

// set default value to the column name if the field is display_name, otherwise null
let default_val = (this.flat_db[column] === undefined && field === 'display_name') ? column : null

return this.flat_db[column] ? this.flat_db[column][field] : default_val;
}

},
Expand Down
2 changes: 1 addition & 1 deletion src/views/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ onMounted(() => {
msg.value = 'No search results returned'
} else {
data.value = results
headers.value = Object.entries(data.value[0]).map((item)=> ({title: item[0], key: item[0], type: typeof item[1], description: store.get_description_from_db(item[0])}))
headers.value = Object.entries(data.value[0]).map((item)=> ({title: store.get_field_from_db(item[0], 'display_name'), key: item[0], type: typeof item[1], description: store.get_field_from_db(item[0], 'description')}))
console.log('data', data.value)
console.log('headers', headers.value)
Expand Down

0 comments on commit 02c7352

Please sign in to comment.