|
2 | 2 | <div class="d-flex flex-column gap-2">
|
3 | 3 | <h1>Loots</h1>
|
4 | 4 |
|
| 5 | + <div class="btn-group flex-wrap gap-2"> |
| 6 | + <a class="btn btn-outline-dark" @click="clearFilter()"> |
| 7 | + <MaterialIcon name="backspace-outline" :size="24" /> |
| 8 | + </a> |
| 9 | + <a class="btn btn-outline-dark text-light" v-for="category in categories" @click="applyFilter(category)"> |
| 10 | + {{ category }} |
| 11 | + </a> |
| 12 | + </div> |
| 13 | + |
5 | 14 | <div class="input-group">
|
6 | 15 | <input type="text" class="form-control bg-transparent border-light border-opacity-25" placeholder="Search" name="Search"
|
7 | 16 | v-model="query"/>
|
|
29 | 38 | </template>
|
30 | 39 |
|
31 | 40 | <script setup lang="ts">
|
| 41 | +import MaterialIcon from '../../components/MaterialIcon.vue'; |
32 | 42 | import Pagination from "../../components/Pagination.vue";
|
33 | 43 | import useClient from '../../composables/useClient';
|
34 | 44 | import useIsNumeric from "../../composables/useIsNumeric";
|
35 | 45 | import usePagination from '../../composables/usePagination';
|
36 |
| -import Badge from "~/components/Badge.vue"; |
37 | 46 |
|
38 | 47 | const { client } = useClient();
|
39 | 48 |
|
40 | 49 | const query = ref("");
|
| 50 | +const filter = ref(""); |
| 51 | +
|
| 52 | +const clearFilter = () => filter.value = ""; |
| 53 | +const applyFilter = (category: string) => filter.value = category; |
41 | 54 |
|
42 | 55 | // Alphanumerically sort by id, remove null entries
|
43 | 56 | const loots = (await client.loots.listAsync({locale: "default", version: "latest"}))
|
44 | 57 | .sort((a, b) => a.id.localeCompare(b.id))
|
45 | 58 | .filter((x) => x.id != "");
|
46 | 59 |
|
| 60 | +const categories = new Set(loots.map((x) => x.type)); |
| 61 | +
|
47 | 62 | const { isNumeric } = useIsNumeric();
|
48 | 63 | const p = computed(() => {
|
49 | 64 | let filtered = [];
|
50 | 65 |
|
51 | 66 | filtered = loots.filter((x) => x.name.toLowerCase().includes(query.value.toLowerCase()));
|
| 67 | + if (filter.value != "") |
| 68 | + filtered = loots.filter((x) => x.type == filter.value); |
52 | 69 |
|
53 | 70 | return usePagination(filtered, 100);
|
54 | 71 | });
|
|
0 commit comments