This repository was archived by the owner on Jun 27, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 145
/
Copy pathTableAddSearchRow.vue
71 lines (63 loc) · 1.66 KB
/
TableAddSearchRow.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>
<ButtonWithDropdown
ref="dropdown"
dusk="add-search-row-dropdown"
:disabled="!hasSearchInputsWithoutValue"
class="w-auto"
>
<template #button>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 text-gray-400"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
clip-rule="evenodd"
/>
</svg>
</template>
<div
role="menu"
aria-orientation="horizontal"
aria-labelledby="add-search-input-menu"
class="min-w-max"
>
<button
v-for="(searchInput, key) in searchInputs"
:key="key"
:dusk="`add-search-row-${searchInput.key}`"
class="text-left w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-100 dark:hover:bg-gray-600 dark:hover:text-gray-100 rounded-md"
role="menuitem"
@click.prevent="enableSearch(searchInput.key)"
>
{{ searchInput.label }}
</button>
</div>
</ButtonWithDropdown>
</template>
<script setup>
import ButtonWithDropdown from "./ButtonWithDropdown.vue";
import { ref } from "vue";
const props = defineProps({
searchInputs: {
type: Object,
required: true,
},
hasSearchInputsWithoutValue: {
type: Boolean,
required: true,
},
onAdd: {
type: Function,
required: true,
},
});
const dropdown = ref(null);
function enableSearch(key) {
props.onAdd(key);
dropdown.value.hide();
}
</script>