Skip to content

Commit

Permalink
feat: filters in table stats enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Aug 24, 2020
1 parent e3a18e0 commit bacb32c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/ItemDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default {
groups[groupName].fields.push(field);
}
}
console.log('groups: ', groups);
// console.log('groups: ', groups);
return groups;
}
},
Expand Down
30 changes: 27 additions & 3 deletions components/Stats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@
<ul>
<li v-for="fStat in stats" :key="fStat.name" :class="['table-stats__field', fStat.class]">
<span class="table-stats__field-name item-details__label" v-html="fStat.title"></span>
<span class="table-stats__field-value item-details__value" v-html="fStat.value"></span>

<span v-if="fStat.subvalues.length === 0"
class="table-stats__field-value item-details__value"
v-html="fStat.value"></span>

<span v-else class="table-stats__field-value item-details__value">
<div v-for="subval of fStat.subvalues" :key="subval.value"
:class="{'item-details__subvalue': true, [subval.validateClass]: true}"
>
{{ subval.value }}: {{ subval.count }}

<FilterPresetButton class="field-preset" :preset="{ q: fStat.name + '=' + subval.value }" toggle>
<icon name="filter" scale="0.6"></icon>
</FilterPresetButton>
</div>
</span>
</li>
</ul>
</div>
Expand Down Expand Up @@ -61,9 +76,9 @@
</style>

<script>
import FilterPresetButton from "~/components/FilterPresetButton";
export default {
props: [""],
components: {},
components: {FilterPresetButton},
data() {
return {
fieldGroupsOpened: {},
Expand All @@ -80,6 +95,7 @@ export default {
if (!field) continue;
let val = "";
let subvalues = [];
let valueText = "";
let validateClass = "";
Expand Down Expand Up @@ -138,7 +154,14 @@ export default {
else if (valClass == 'warning' && validateClass != 'danger') validateClass = valClass;
else if (!validateClass) validateClass = valClass;
subvalues.push({
validateClass: valClass,
value: valName,
count: count,
});
// if (valClass === 'success') valClass = '';
// TODO: remove, not used, subvalues
msg.push(
`<span class="item-details__subvalue ${valClass}">${valName}: ${count}</span>`
);
Expand Down Expand Up @@ -183,6 +206,7 @@ export default {
title: field.comment || field.name,
class: validateClass,
value: valueText || val,
subvalues: subvalues,
});
}
}
Expand Down

0 comments on commit bacb32c

Please sign in to comment.