Skip to content

Commit

Permalink
feat(reports): show item details when 1 item in table
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Dec 29, 2020
1 parent a3df690 commit f257109
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/ItemDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<span class="item-details__value" v-html="field.valueText || field.value"></span>

<FilterPresetButton
v-if="field.type == 'boolean' || true"
v-if="itemsLength > 1"
class="field-preset"
:preset="{ q: field.name + '=' + field.value }"
append
Expand Down Expand Up @@ -59,6 +59,9 @@ export default {
tests() {
return this.$store.state.tests;
},
itemsLength() {
return this.$store.state.items.length;
},
groups() {
let groups = { unnamed: { name: "", fields: [] } };
Expand Down Expand Up @@ -102,7 +105,7 @@ export default {
// add to groups
for (let g in groupsList) {
console.log('g: ', g);
// console.log('g: ', g);
let groupName = groupsList[g];
if (!(groupName in groups)) {
groups[groupName] = { name: groupName, fields: [] };
Expand Down
13 changes: 13 additions & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ export default {
return this.$store.state.availableFields;
},
itemsLength() {
return this.$store.state.items.length;
},
filteredItems() {
return this.$store.state.filteredItems;
},
Expand Down Expand Up @@ -760,6 +764,15 @@ export default {
this.$store.commit("tests", itemsJson.fields);
this.$store.dispatch("items", itemsJson.items);
// open details when single row
if (this.itemsLength === 1) {
const row = this.filteredItems[0];
// console.log('row: ', row);
setTimeout(() => {
this.rowClick({row});
}, 1000);
}
// filter
if (this.defaultFilter && !this.$route.query["q"]) {
this.$route.query["q"] = this.defaultFilter.q;
Expand Down

0 comments on commit f257109

Please sign in to comment.