2019-04-03 17:29:03 +02:00
|
|
|
<template>
|
|
|
|
<b-input icon="magnify" type="search" rounded :placeholder="defaultPlaceHolder" v-model="searchText" @keyup.native.enter="enter" />
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
|
|
|
import { RouteName } from '@/router';
|
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class SearchField extends Vue {
|
|
|
|
@Prop({ type: String, required: false }) placeholder!: string;
|
|
|
|
searchText: string = '';
|
|
|
|
|
|
|
|
enter() {
|
|
|
|
this.$router.push({ name: RouteName.SEARCH, params: { searchTerm: this.searchText } });
|
|
|
|
}
|
|
|
|
|
|
|
|
get defaultPlaceHolder(): string {
|
|
|
|
// We can't use "this" inside @Prop's default value.
|
2019-09-12 11:34:01 +02:00
|
|
|
return this.placeholder || this.$t('Search') as string;
|
2019-04-03 17:29:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|