From 02c735223b98c9158a62b2daf33f9eb7153e6d4e Mon Sep 17 00:00:00 2001 From: havok2063 Date: Sun, 4 Aug 2024 11:44:05 -0400 Subject: [PATCH] switching table column title to display name --- src/store/app.ts | 8 ++++++-- src/views/Results.vue | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/store/app.ts b/src/store/app.ts index 26af33c..7033216 100644 --- a/src/store/app.ts +++ b/src/store/app.ts @@ -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; } }, diff --git a/src/views/Results.vue b/src/views/Results.vue index 2e51ce4..740d198 100644 --- a/src/views/Results.vue +++ b/src/views/Results.vue @@ -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)