Skip to content

Commit

Permalink
refactor: add rating totals (no ui)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohrstrom committed Jun 26, 2024
1 parent 88e786f commit 48a2770
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion obr_ui/components/rating/UserRating.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ export default defineComponent({
},
setup(props) {
const { iconSize } = useIconSize(props.iconScale);
const { ratingByKey, loadRating, setRatingWithSource } = useRating();
const { ratingByKey, totalsByKey, loadRating, setRatingWithSource } = useRating();
const rating = computed(() => ratingByKey(props.objKey));
const totals = computed(() => totalsByKey(props.objKey));
const totalsDisplay = computed(() => {
if (!totals.value) {
return "";
}
return `up: ${totals.value?.up ?? 0}, down: ${totals.value?.down ?? 0}`;
});
const isFlipped = ref(false);
const flipIcon = async () => {
isFlipped.value = true;
Expand Down Expand Up @@ -80,6 +87,7 @@ export default defineComponent({
});
return {
rating,
totalsDisplay,
rate,
style,
iconSize,
Expand All @@ -96,6 +104,7 @@ export default defineComponent({
'is-flipped': isFlipped,
}"
:style="style"
:title="totalsDisplay"
>
<IconHeart v-if="rating === 1" :scale="iconScale" :color-var="colorVar" @click="rate(null)" />
<IconFlash
Expand Down

0 comments on commit 48a2770

Please sign in to comment.