Skip to content

Commit

Permalink
feat: show human columns
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Sep 3, 2020
1 parent 6005cbd commit 08d41c8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
19 changes: 18 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
</div>

<div class="table-actions">
<el-checkbox class="human-columns-switch" v-model="showHumanColumns">
Human column names
</el-checkbox>

<button class="btn btn-excel" @click="getXlsx">
<icon name="file-excel"></icon> xlsx
</button>
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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;
},
Expand Down
10 changes: 8 additions & 2 deletions plugins/localStorage.js
Original file line number Diff line number Diff line change
@@ -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);
};
4 changes: 4 additions & 0 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const state = () => ({
allFields: [],
defaultField: '',
openGroups: true,
showHumanColumns: true,
currentJsonSort: 'added',
q: '',
columnPresets: {},
Expand Down Expand Up @@ -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;
},
Expand Down

0 comments on commit 08d41c8

Please sign in to comment.