| ... |
... |
@@ -41,17 +41,15 @@ |
| 41 |
41 |
this.editor = false; |
| 42 |
42 |
this.viewer = false; |
| 43 |
43 |
this.rolesFilter = []; |
| 44 |
|
- this.filterUrl = new URL(`${document.location.origin}/rest/v1/collabs?search=&offset=0&orderField=title&order=asc&limit=10000&favorite=false&roles=`); |
|
44 |
+ this.filterUrl = new URL(`${document.location.origin}/rest/v1/collabs?search=&offset=0&orderField=title&order=asc&favorite=&roles=`); |
| 45 |
45 |
this.results = []; |
| 46 |
46 |
} |
| 47 |
47 |
toggleRoleFilter(roleName) { |
| 48 |
|
- console.log("toggleRoleFilter", roleName, this.rolesFilter, this.rolesFilter.indexOf(roleName)); |
| 49 |
|
- if(this.rolesFilter.indexOf(roleName) === -1) { |
|
48 |
+ if(this.rolesFilter.indexOf(roleName) == -1) { |
| 50 |
50 |
this.rolesFilter.push(roleName); |
| 51 |
51 |
} else { |
| 52 |
52 |
this.rolesFilter.filter(role => role !== roleName); |
| 53 |
53 |
} |
| 54 |
|
- console.log(this.rolesFilter); |
| 55 |
55 |
this[roleName] = !this[roleName]; |
| 56 |
56 |
this.filterUrl.searchParams.set('roles', this.rolesFilter.join("+")); |
| 57 |
57 |
this.handleSearch(); |
| ... |
... |
@@ -60,22 +60,21 @@ |
| 60 |
60 |
this.searchText = e.target.value; |
| 61 |
61 |
} |
| 62 |
62 |
handleSearch() { |
| 63 |
|
- console.log(this.rolesFilter) |
| 64 |
64 |
if(this.searchText !== "") { |
| 65 |
|
- if(this.searchText !== this.prevSearchText) { |
| 66 |
|
- console.log(this.searchText, this.prevSearchText); |
| 67 |
|
- this.prevSearchText = this.searchText; |
| 68 |
|
- Promise.all([ |
| 69 |
|
- this.fetchWikiSearch(), |
| 70 |
|
- this.fetchFilterSearch() |
| 71 |
|
- ]).then(([wikiSearchResults, collabSearchResults]) => { |
| 72 |
|
- this.results = wikiSearchResults; |
| 73 |
|
- console.log(wikiSearchResults, collabSearchResults); |
| 74 |
|
- }); |
| 75 |
|
- } else if (this.searchText === this.prevSearchText) { |
| 76 |
|
- console.log("Only apply filter on results"); |
| 77 |
|
- this.fetchFilterSearch().then(this.filterResults) |
| 78 |
|
- } |
|
62 |
+ if(this.searchText !== this.prevSearchText) { |
|
63 |
+ console.log(this.searchText, this.prevSearchText); |
|
64 |
+ this.prevSearchText = this.searchText; |
|
65 |
+ Promise.all([ |
|
66 |
+ this.fetchWikiSearch(), |
|
67 |
+ this.fetchFilterSearch() |
|
68 |
+ ]).then(([wikiSearchResults, collabSearchResults]) => { |
|
69 |
+ this.results = wikiSearchResults; |
|
70 |
+ console.log(wikiSearchResults, collabSearchResults); |
|
71 |
+ }); |
|
72 |
+ } else if (this.searchText === this.prevSearchText) { |
|
73 |
+ console.log("Only apply filter on results"); |
|
74 |
+ this.fetchFilterSearch().then(this.filterResults) |
|
75 |
+ } |
| 79 |
79 |
} else { |
| 80 |
80 |
console.log("no search text, should return filter search results if any"); |
| 81 |
81 |
this.fetchFilterSearch().then(collabs => { |
| ... |
... |
@@ -94,7 +94,7 @@ |
| 94 |
94 |
} |
| 95 |
95 |
fetchFilterSearch() { |
| 96 |
96 |
return new Promise((resolve) => { |
| 97 |
|
- if(this.hasActiveFilters()) { |
|
94 |
+ if(this.hasActiveFilters) { |
| 98 |
98 |
fetch(this.filterUrl).then(res => res.json()).then(resolve); |
| 99 |
99 |
} else { |
| 100 |
100 |
resolve(null); |
| ... |
... |
@@ -104,7 +104,7 @@ |
| 104 |
104 |
filterResults = (filteredCollabs) => { |
| 105 |
105 |
console.log("filteredCollabs:", filteredCollabs, "search results:", this.results); |
| 106 |
106 |
const collabSpaces = filteredCollabs.map(collab => `Collabs.${collab.name}`); |
| 107 |
|
- const filteredResults = this.results.filter(result => collabSpaces.some(space => result.space.startsWith(space))); |
|
104 |
+ const filteredResults = this.results.filter(result => collabsSpace.some(space => result.startsWith(space))); |
| 108 |
108 |
console.log(filteredResults); |
| 109 |
109 |
} |
| 110 |
110 |
getLink(xwikiDocSpace) { |