import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { GameFilteringContainer } from './container';

@Component({})
export default class AppGameFilteringInput extends Vue {
	@Prop(Object) filtering!: GameFilteringContainer;

	query = '';

	created() {
		this.query = this.filtering.filters.query;
	}

	clear() {
		this.query = '';
		this.filtering.unsetFilter('query');
		this.filtering.onChanged();

	}

	sendSearch() {
		this.filtering.setFilter('query', this.query);
		this.filtering.onChanged();

		if (this.query) {
		} else {
		}
	}

	blur() {
		if (this.$refs.input) {
			(this.$refs.input as HTMLElement).blur();
		}
	}
}
