-
Notifications
You must be signed in to change notification settings - Fork 0
/
public_apis_filter.vue
71 lines (63 loc) · 1.49 KB
/
public_apis_filter.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<template>
<div class="flex items-center">
<label
for="filter"
class="text-sm font-medium text-gray-900 dark:text-gray-300"
>
{{ label }}:
</label>
<select
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full mx-4 my-2 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
id="filter"
v-bind="$attrs"
v-bind:value="value"
@change="changeHandler"
>
<option value="">All</option>
<option
v-for="category in categories"
v-bind:value="category"
:key="category"
>
{{ category }}
</option>
</select>
</div>
</template>
<script>
import getCategories from "@/api/getCategories";
export default {
name: 'FeldmPublicApisFilter',
inheritAttrs: false,
props: {
// This prop is needed to map the v-model correctly.
value: {
type: String,
required: false,
default: '',
},
label: {
type: String,
required: false,
default: "Category",
},
},
data() {
return {
categories: [],
};
},
created() {
this.fetchData();
},
methods: {
async fetchData() {
const response = await getCategories();
this.categories = response.data.categories;
},
changeHandler(event) {
this.$emit("input", event.target.value);
},
},
};
</script>