]> BookStack Code Mirror - bookstack/blob - resources/assets/js/vues/entity-dashboard.js
Merge pull request #1072 from CliffyPrime/german_update
[bookstack] / resources / assets / js / vues / entity-dashboard.js
1 let data = {
2     id: null,
3     type: '',
4     searching: false,
5     searchTerm: '',
6     searchResults: '',
7 };
8
9 let computed = {
10
11 };
12
13 let methods = {
14
15     searchBook() {
16         if (this.searchTerm.trim().length === 0) return;
17         this.searching = true;
18         this.searchResults = '';
19         let url = window.baseUrl(`/search/${this.type}/${this.id}`);
20         url += `?term=${encodeURIComponent(this.searchTerm)}`;
21         this.$http.get(url).then(resp => {
22             this.searchResults = resp.data;
23         });
24     },
25
26     checkSearchForm() {
27         this.searching = this.searchTerm > 0;
28     },
29
30     clearSearch() {
31         this.searching = false;
32         this.searchTerm = '';
33     }
34
35 };
36
37 function mounted() {
38     this.id = Number(this.$el.getAttribute('entity-id'));
39     this.type = this.$el.getAttribute('entity-type');
40 }
41
42 export default {
43     data, computed, methods, mounted
44 };