2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00
books/ui/components/Navbar.vue
2018-10-04 14:55:34 +05:30

38 lines
864 B
Vue

<template>
<nav class="frappe-navbar navbar navbar-light bg-light row no-gutters border-bottom">
<form v-if="showSearch" class="form-inline col-4 pr-3">
<input type="text"
v-model="searchValue"
@input="updateSearch"
name="search"
class="form-control shadow-none w-100"
:placeholder="_('Search...')">
</form>
<div class="navbar-text">&nbsp;</div>
</nav>
</template>
<script>
import { debounce } from 'lodash';
export default {
data() {
return {
searchValue: ''
};
},
computed: {
showSearch() {
// TODO: Make this configurable
return /list|edit/.test(this.$route.path)
}
},
mounted() {
this.$root.$on('newList', () => this.searchValue = '')
},
methods: {
updateSearch: debounce(function() {
this.$root.$emit('navbarSearch', this.searchValue)
}, 500)
}
};
</script>