11<script setup lang="ts">
2- import type { SearchCoverSchema , SearchRomSchema } from " @/__generated__" ;
2+ import type { SearchCoverSchema } from " @/__generated__" ;
33import RDialog from " @/components/common/RDialog.vue" ;
44import romApi from " @/services/api/rom" ;
55import storeRoms , { type SimpleRom } from " @/stores/roms" ;
66import type { Events } from " @/types/emitter" ;
77import type { Emitter } from " mitt" ;
88import { inject , onBeforeUnmount , ref } from " vue" ;
9- import { useDisplay , useTheme } from " vuetify" ;
9+ import { useDisplay } from " vuetify" ;
1010
1111// Props
12- const { xs, lgAndUp } = useDisplay ();
12+ const { lgAndUp } = useDisplay ();
1313const show = ref (false );
1414const romsStore = storeRoms ();
15- const theme = useTheme ();
1615const rom = ref <SimpleRom | null >(null );
1716const searching = ref (false );
1817const searchTerm = ref (" " );
1918const games = ref <SearchCoverSchema []>();
19+ const filteredGames = ref <SearchCoverSchema []>();
2020const panels = ref ([0 ]);
21- const panelIndex = ref (0 );
2221const emitter = inject <Emitter <Events >>(" emitter" );
22+ const type = ref (" all" );
2323emitter ?.on (" showSearchCoverDialog" , (romToSearch ) => {
2424 rom .value = romToSearch ;
2525 searchTerm .value = romToSearch .name || romToSearch .file_name_no_tags || " " ;
@@ -45,6 +45,19 @@ async function searchCovers() {
4545 })
4646 .then ((response ) => {
4747 games .value = response .data ;
48+ filteredGames .value = games .value
49+ .map ((game ) => {
50+ return {
51+ ... game ,
52+ resources:
53+ type .value === " all"
54+ ? game .resources
55+ : game .resources .filter (
56+ (resource ) => resource .type === type .value
57+ ),
58+ };
59+ })
60+ .filter ((item ) => item .resources .length > 0 );
4861 })
4962 .catch ((error ) => {
5063 emitter ?.emit (" snackbarShow" , {
@@ -62,9 +75,6 @@ async function searchCovers() {
6275async function updateCover(url_cover : string ) {
6376 if (! rom .value ) return ;
6477
65- console .log (url_cover );
66- console .log (url_cover .replace (" thumb" , " grid" ));
67-
6878 show .value = false ;
6979 emitter ?.emit (" showLoadingDialog" , { loading: true , scrim: true });
7080
@@ -92,6 +102,24 @@ async function updateCover(url_cover: string) {
92102 });
93103}
94104
105+ function filterCovers() {
106+ if (games .value ) {
107+ filteredGames .value = games .value
108+ .map ((game ) => {
109+ return {
110+ ... game ,
111+ resources:
112+ type .value === " all"
113+ ? game .resources
114+ : game .resources .filter (
115+ (resource ) => resource .type === type .value
116+ ),
117+ };
118+ })
119+ .filter ((item ) => item .resources .length > 0 );
120+ }
121+ }
122+
95123function closeDialog() {
96124 show .value = false ;
97125 games .value = undefined ;
@@ -116,7 +144,7 @@ onBeforeUnmount(() => {
116144 >
117145 <template #toolbar >
118146 <v-row class =" align-center" no-gutters >
119- <v-col cols =" 10 " sm =" 11 " >
147+ <v-col cols =" 8 " sm =" 9 " >
120148 <v-text-field
121149 id =" search-text-field"
122150 @keyup.enter =" searchCovers()"
@@ -128,6 +156,15 @@ onBeforeUnmount(() => {
128156 clearable
129157 />
130158 </v-col >
159+ <v-col cols =" 2" sm =" 2" >
160+ <v-select
161+ v-model =" type"
162+ hide-details
163+ label =" Type"
164+ @update:model-value =" filterCovers"
165+ :items =" ['all', 'static', 'animated']"
166+ />
167+ </v-col >
131168 <v-col >
132169 <v-btn
133170 type =" submit"
@@ -150,7 +187,7 @@ onBeforeUnmount(() => {
150187 rounded =" 0"
151188 variant =" accordion"
152189 >
153- <v-expansion-panel v-for =" game in games " :key =" game.name" >
190+ <v-expansion-panel v-for =" game in filteredGames " :key =" game.name" >
154191 <v-expansion-panel-title class =" bg-terciary" >
155192 <v-row no-gutters class =" justify-center" >
156193 <v-list-item class =" pa-0" >{{ game.name }}</v-list-item >
@@ -176,10 +213,7 @@ onBeforeUnmount(() => {
176213 cover
177214 >
178215 <template #error >
179- <v-img
180- :src =" `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`"
181- cover
182- ></v-img >
216+ <v-img :src =" resource.url" cover ></v-img >
183217 </template >
184218 <template #placeholder >
185219 <div
0 commit comments