-
Notifications
You must be signed in to change notification settings - Fork 2
/
VgtGlobalSearch.vue
67 lines (63 loc) · 1.56 KB
/
VgtGlobalSearch.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
<template>
<div v-if="showControlBar" class="vgt-global-search vgt-clearfix">
<div class="vgt-global-search__input vgt-pull-left">
<form @submit.prevent v-if="searchEnabled" role="search">
<label :for="id">
<span aria-hidden="true" class="input__icon">
<div class="magnifying-glass"></div>
</span>
<span class="sr-only">Search</span>
</label>
<input
:id="id"
type="text"
class="vgt-input vgt-pull-left"
:placeholder="globalSearchPlaceholder"
:value="value"
@input="updateValue($event.target.value)"
@keyup.enter="entered($event.target.value)"/>
</form>
</div>
<div class="vgt-global-search__actions vgt-pull-right">
<slot name="internal-table-actions">
</slot>
</div>
</div>
</template>
<script>
export default {
name: 'VgtGlobalSearch',
props: [
'value',
'searchEnabled',
'globalSearchPlaceholder',
],
data () {
return {
globalSearchTerm: null,
id: this.getId(),
}
},
computed: {
showControlBar () {
if (this.searchEnabled) return true
if (this.$slots && this.$slots['internal-table-actions']) return true
return false
},
},
methods: {
updateValue (value) {
this.$emit('input', value)
this.$emit('on-keyup', value)
},
entered (value) {
this.$emit('on-enter', value)
},
getId () {
return `vgt-search-${Math.floor(Math.random() * Date.now())}`
},
},
}
</script>
<style>
</style>