From 08d41c8d62afb87d65cce6f4a59f36f675b16082 Mon Sep 17 00:00:00 2001 From: Stanislav Popov Date: Thu, 3 Sep 2020 13:37:25 +0500 Subject: [PATCH] feat: show human columns --- pages/index.vue | 19 ++++++++++++++++++- plugins/localStorage.js | 10 ++++++++-- store/index.js | 4 ++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index db72944..3a3e444 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -42,6 +42,10 @@
+ + Human column names + + @@ -186,6 +190,15 @@ export default { return this.$store.state.filteredItems; }, + showHumanColumns: { + get() { + return this.$store.state.showHumanColumns; + }, + set(val) { + this.$store.commit('showHumanColumns', val); + } + }, + fieldsWithoutComments() { return this.$store.state.fields.map(f => { f = {...f}; @@ -351,7 +364,11 @@ export default { headings() { let h = {}; this.fields.forEach(field => { - h[field.name] = field.title.split("_").join(" ") || field.name; + if (this.showHumanColumns) { + h[field.name] = field.comment || field.title.split("_").join(" ") || field.name; + } else { + h[field.name] = field.title.split("_").join(" ") || field.name; + } }); return h; }, diff --git a/plugins/localStorage.js b/plugins/localStorage.js index 82ab41e..7ce15b7 100644 --- a/plugins/localStorage.js +++ b/plugins/localStorage.js @@ -1,7 +1,13 @@ import createPersistedState from 'vuex-persistedstate'; -export default ({ store }) => { +export default ({store}) => { createPersistedState({ - paths: ['itemsJsonUrl', 'jsonUrlHistory', 'visitCount', 'openGroups', 'currentJsonSort'] + paths: [ + 'itemsJsonUrl', + 'jsonUrlHistory', + 'visitCount', + 'openGroups', + 'showHumanColumns', + 'currentJsonSort'], })(store); }; diff --git a/store/index.js b/store/index.js index 8d3c9bc..11416db 100644 --- a/store/index.js +++ b/store/index.js @@ -89,6 +89,7 @@ export const state = () => ({ allFields: [], defaultField: '', openGroups: true, + showHumanColumns: true, currentJsonSort: 'added', q: '', columnPresets: {}, @@ -319,6 +320,9 @@ export const mutations = { openGroups(state, newValue) { state.openGroups = newValue; }, + showHumanColumns(state, newValue) { + state.showHumanColumns = newValue; + }, currentJsonSort(state, newValue) { state.currentJsonSort = newValue; },