Skip to content

Commit 06f7043

Browse files
Add filter options for loot
1 parent 674a503 commit 06f7043

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pages/loots/index.vue

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
<div class="d-flex flex-column gap-2">
33
<h1>Loots</h1>
44

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+
514
<div class="input-group">
615
<input type="text" class="form-control bg-transparent border-light border-opacity-25" placeholder="Search" name="Search"
716
v-model="query"/>
@@ -29,26 +38,34 @@
2938
</template>
3039

3140
<script setup lang="ts">
41+
import MaterialIcon from '../../components/MaterialIcon.vue';
3242
import Pagination from "../../components/Pagination.vue";
3343
import useClient from '../../composables/useClient';
3444
import useIsNumeric from "../../composables/useIsNumeric";
3545
import usePagination from '../../composables/usePagination';
36-
import Badge from "~/components/Badge.vue";
3746
3847
const { client } = useClient();
3948
4049
const query = ref("");
50+
const filter = ref("");
51+
52+
const clearFilter = () => filter.value = "";
53+
const applyFilter = (category: string) => filter.value = category;
4154
4255
// Alphanumerically sort by id, remove null entries
4356
const loots = (await client.loots.listAsync({locale: "default", version: "latest"}))
4457
.sort((a, b) => a.id.localeCompare(b.id))
4558
.filter((x) => x.id != "");
4659
60+
const categories = new Set(loots.map((x) => x.type));
61+
4762
const { isNumeric } = useIsNumeric();
4863
const p = computed(() => {
4964
let filtered = [];
5065
5166
filtered = loots.filter((x) => x.name.toLowerCase().includes(query.value.toLowerCase()));
67+
if (filter.value != "")
68+
filtered = loots.filter((x) => x.type == filter.value);
5269
5370
return usePagination(filtered, 100);
5471
});

0 commit comments

Comments
 (0)