Added Filtering, Looks Ugly, Mostly Works

This commit is contained in:
Annika Merris 2024-01-22 22:30:53 -05:00
parent 744e6608af
commit e2a6270c12
5 changed files with 118 additions and 15 deletions

View file

@ -115,6 +115,7 @@
"minItemPower": 10, "minItemPower": 10,
"maxItemPower": 30, "maxItemPower": 30,
"rarity": 4, "rarity": 4,
"origin": "Unknown",
"isEventItem": true "isEventItem": true
}, },
"6459b278-9e0d-48ab-b6bb-aa4bfc88011b": { "6459b278-9e0d-48ab-b6bb-aa4bfc88011b": {

View file

@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { usePowerItems } from '@/stores/powerItems' import { usePowerItems } from '@/stores/powerItems'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import type { Ref } from 'vue';
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
const { const {
@ -66,11 +67,28 @@ const sortBy = ref([
order: 'asc' order: 'asc'
} }
]) ])
const selectedEvents: Ref<string[]> = ref(['All'])
const getEventImageUrl = function(eventName: string): string { const getEventImageUrl = function(eventName: string): string {
return eventName !== undefined ? "/images/" + eventName.replace(/\s/g, '_').toLocaleLowerCase() + ".png" : '' return eventName !== undefined ? "/images/" + eventName.replace(/\s/g, '_').toLocaleLowerCase() + ".png" : ''
} }
const events = computed(() =>
[...specialBlessingItems.value.values()]
.map((cur) => cur.origin)
.filter((value: string, idx: number, arr: string[]) => arr.indexOf(value) === idx)
.concat('All')
)
const filteredItems = computed(() =>
[...specialBlessingItems.value.entries()]
.map((value) =>
selectedEvents.value.indexOf('All') !== -1 ||
selectedEvents.value.indexOf(value[1].origin) !== -1
? value
: undefined
)
.filter((value) => value !== undefined)
)
const getColor = computed(() => (rarity: number): string => { const getColor = computed(() => (rarity: number): string => {
if (rarity === 5) { if (rarity === 5) {
return 'red' return 'red'
@ -91,10 +109,19 @@ const getColor = computed(() => (rarity: number): string => {
<v-card-title>Special Items</v-card-title> <v-card-title>Special Items</v-card-title>
<v-card-subtitle>Items from events</v-card-subtitle> <v-card-subtitle>Items from events</v-card-subtitle>
<v-card-item> <v-card-item>
<v-select
clearable
chips
label="Event"
:items="events"
multiple
density="compact"
v-model="selectedEvents"
></v-select>
<v-data-table <v-data-table
density="compact" density="compact"
v-model:sort-by="sortBy" v-model:sort-by="sortBy"
:items="[...specialBlessingItems.entries()]" :items="filteredItems"
:headers="headers" :headers="headers"
> >
<template v-slot:item.1.origin="{ item }"> <template v-slot:item.1.origin="{ item }">

View file

@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { usePowerItems } from '@/stores/powerItems' import { usePowerItems } from '@/stores/powerItems'
import type { PowerItem } from '@/types/PowerItem'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import type { Ref } from 'vue'
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
const { const {
@ -12,7 +14,7 @@ const {
const headers = ref([ const headers = ref([
{ {
title: "Event", title: 'Event',
align: ' d-none d-lg-table-cell start', align: ' d-none d-lg-table-cell start',
sortable: true, sortable: true,
value: '1.origin' value: '1.origin'
@ -66,10 +68,30 @@ const sortBy = ref([
order: 'asc' order: 'asc'
} }
]) ])
const selectedEvents: Ref<string[]> = ref(['All'])
const getEventImageUrl = function(eventName: string): string { const getEventImageUrl = function (eventName: string): string {
return eventName !== undefined ? "/images/" + eventName.replace(/\s/g, '_').toLocaleLowerCase() + ".png" : '' return eventName !== undefined
? '/images/' + eventName.replace(/\s/g, '_').toLocaleLowerCase() + '.png'
: ''
} }
const events = computed(() =>
[...specialFellowItems.value.values()]
.map((cur) => cur.origin)
.filter((value: string, idx: number, arr: string[]) => arr.indexOf(value) === idx)
.concat('All')
)
const filteredItems = computed(() =>
[...specialFellowItems.value.entries()]
.map((value) =>
selectedEvents.value.indexOf('All') !== -1 ||
selectedEvents.value.indexOf(value[1].origin) !== -1
? value
: undefined
)
.filter((value) => value !== undefined)
)
const getColor = computed(() => (rarity: number): string => { const getColor = computed(() => (rarity: number): string => {
if (rarity === 5) { if (rarity === 5) {
return 'red' return 'red'
@ -90,22 +112,44 @@ const getColor = computed(() => (rarity: number): string => {
<v-card-title>Special Items</v-card-title> <v-card-title>Special Items</v-card-title>
<v-card-subtitle>Items from events</v-card-subtitle> <v-card-subtitle>Items from events</v-card-subtitle>
<v-card-item> <v-card-item>
<v-select
clearable
chips
label="Event"
:items="events"
multiple
density="compact"
v-model="selectedEvents"
></v-select>
<v-data-table <v-data-table
density="compact" density="compact"
v-model:sort-by="sortBy" v-model:sort-by="sortBy"
:items="[...specialFellowItems.entries()]" :items="filteredItems"
:headers="headers" :headers="headers"
> >
<template v-slot:item.1.origin="{ item }"> <template v-slot:item.1.origin="{ item }">
<v-card class="my-2" elevation="2" rounded width="39" v-if="getEventImageUrl(item[1].origin) !== ''" color="transparent"> <v-card
<v-img :src="getEventImageUrl(item[1].origin)"></v-img> class="my-2"
</v-card> elevation="2"
</template> rounded
width="39"
v-if="getEventImageUrl(item[1].origin) !== ''"
color="transparent"
>
<v-img :src="getEventImageUrl(item[1].origin)"></v-img>
</v-card>
</template>
<template v-slot:item.1.itemName="{ item }"> <template v-slot:item.1.itemName="{ item }">
<v-tooltip activator="parent" v-if="item[1].tooltip != undefined" content-class="custom-tooltip"> <v-tooltip
activator="parent"
v-if="item[1].tooltip != undefined"
content-class="custom-tooltip"
>
<v-card variant="text" density="compact" max-width="25vw"> <v-card variant="text" density="compact" max-width="25vw">
<v-card-title class="px-2">Origin: {{ item[1].origin }}</v-card-title> <v-card-title class="px-2">Origin: {{ item[1].origin }}</v-card-title>
<v-card-text class="px-2" v-if="item[1].tooltip !== ''">{{ item[1].tooltip }}</v-card-text> <v-card-text class="px-2" v-if="item[1].tooltip !== ''">{{
item[1].tooltip
}}</v-card-text>
</v-card> </v-card>
</v-tooltip> </v-tooltip>
<v-chip :color="`${getColor(item[1].rarity)}`"> <v-chip :color="`${getColor(item[1].rarity)}`">

View file

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { usePowerItems } from '@/stores/powerItems' import { usePowerItems } from '@/stores/powerItems'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { computed, ref } from 'vue' import { computed, ref, type Ref } from 'vue'
const { const {
specialIntimacyItems, specialIntimacyItems,
@ -66,11 +66,28 @@ const sortBy = ref([
order: 'asc' order: 'asc'
} }
]) ])
const selectedEvents: Ref<string[]> = ref(['All'])
const getEventImageUrl = function(eventName: string): string { const getEventImageUrl = function(eventName: string): string {
return eventName !== undefined ? "/images/" + eventName.replace(/\s/g, '_').toLocaleLowerCase() + ".png" : '' return eventName !== undefined ? "/images/" + eventName.replace(/\s/g, '_').toLocaleLowerCase() + ".png" : ''
} }
const events = computed(() =>
[...specialIntimacyItems.value.values()]
.map((cur) => cur.origin)
.filter((value: string, idx: number, arr: string[]) => arr.indexOf(value) === idx)
.concat('All')
)
const filteredItems = computed(() =>
[...specialIntimacyItems.value.entries()]
.map((value) =>
selectedEvents.value.indexOf('All') !== -1 ||
selectedEvents.value.indexOf(value[1].origin) !== -1
? value
: undefined
)
.filter((value) => value !== undefined)
)
const getColor = computed(() => (rarity: number): string => { const getColor = computed(() => (rarity: number): string => {
if (rarity === 5) { if (rarity === 5) {
return 'red' return 'red'
@ -91,10 +108,19 @@ const getColor = computed(() => (rarity: number): string => {
<v-card-title>Special Items</v-card-title> <v-card-title>Special Items</v-card-title>
<v-card-subtitle>Items from events</v-card-subtitle> <v-card-subtitle>Items from events</v-card-subtitle>
<v-card-item> <v-card-item>
<v-select
clearable
chips
label="Event"
:items="events"
multiple
density="compact"
v-model="selectedEvents"
></v-select>
<v-data-table <v-data-table
density="compact" density="compact"
v-model:sort-by="sortBy" v-model:sort-by="sortBy"
:items="[...specialIntimacyItems.entries()]" :items="filteredItems"
:headers="headers" :headers="headers"
> >
<template v-slot:item.1.origin="{ item }"> <template v-slot:item.1.origin="{ item }">

View file

@ -8,6 +8,10 @@ const entries20240120 = ref([
'Added a default sort to all of the tables', 'Added a default sort to all of the tables',
'Added a couple of icons, and started working on adding tooltips' 'Added a couple of icons, and started working on adding tooltips'
]) ])
const entries20240121 = ref([
'Added Touno Island items',
'Added event icon display'
])
</script> </script>
<template> <template>
@ -77,7 +81,8 @@ const entries20240120 = ref([
<p>First pass that I'm comfortable letting other people see</p> <p>First pass that I'm comfortable letting other people see</p>
</v-list-item-subtitle> </v-list-item-subtitle>
</v-list-item> </v-list-item>
<ChangeLogEntry date="2024-01-20" :entries="entries20240120"> </ChangeLogEntry> <ChangeLogEntry date="2024-01-20" :entries="entries20240120"></ChangeLogEntry>
<ChangeLogEntry date="2024-01-21" :entries="entries20240121"></ChangeLogEntry>
</v-list> </v-list>
</v-sheet> </v-sheet>
<v-sheet :elevation="1" class="ma-2 my-4"> <v-sheet :elevation="1" class="ma-2 my-4">