2017-04-15 14:16:07 -04:00
|
|
|
let data = {
|
|
|
|
id: null,
|
|
|
|
type: '',
|
|
|
|
searching: false,
|
|
|
|
searchTerm: '',
|
|
|
|
searchResults: '',
|
|
|
|
};
|
|
|
|
|
|
|
|
let computed = {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let methods = {
|
|
|
|
|
|
|
|
searchBook() {
|
|
|
|
if (this.searchTerm.trim().length === 0) return;
|
|
|
|
this.searching = true;
|
|
|
|
this.searchResults = '';
|
|
|
|
let url = window.baseUrl(`/search/${this.type}/${this.id}`);
|
|
|
|
url += `?term=${encodeURIComponent(this.searchTerm)}`;
|
|
|
|
this.$http.get(url).then(resp => {
|
|
|
|
this.searchResults = resp.data;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
checkSearchForm() {
|
|
|
|
this.searching = this.searchTerm > 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
clearSearch() {
|
|
|
|
this.searching = false;
|
|
|
|
this.searchTerm = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
function mounted() {
|
|
|
|
this.id = Number(this.$el.getAttribute('entity-id'));
|
|
|
|
this.type = this.$el.getAttribute('entity-type');
|
|
|
|
}
|
|
|
|
|
2018-11-09 16:17:35 -05:00
|
|
|
export default {
|
2017-04-15 14:16:07 -04:00
|
|
|
data, computed, methods, mounted
|
|
|
|
};
|