Failed to execute template. Cause: [Access denied when checking [script] access to [xwiki:Collaboratory.UX.HbpSkin.WebHome] for user [xwiki:XWiki.Admin]]. Click on this message for details.

Context Search - HBP Wiki

IAM21 instance, do not create collab nor modify a team, your changes will be lost


Changes for page Context Search

Last modified by bougault on 2023/02/20 16:29

From version 27.54
edited by bougault
on 2022/11/17 14:21
Change comment: There is no comment for this version
To version 27.36
edited by bougault
on 2022/11/17 13:48
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -43,7 +43,6 @@
43 43   this.rolesFilter = [];
44 44   this.filterUrl = new URL(`${document.location.origin}/rest/v1/collabs?search=&offset=0&orderField=title&order=asc&limit=10000&favorite=false&roles=`);
45 45   this.results = [];
46 - this.resultsCache = [];
47 47   }
48 48   toggleRoleFilter(roleName) {
49 49   if(this.rolesFilter.indexOf(roleName) === -1) {
... ... @@ -58,37 +58,25 @@
58 58   setSearchText(e) {
59 59   this.searchText = e.target.value;
60 60   }
61 - handleSearch(textSearch) {
62 - if(this.searchText !== "" || textSearch) {
60 + handleSearch() {
61 +
62 + if(this.searchText !== "") {
63 63   if(this.searchText !== this.prevSearchText) {
64 - this.clearResults();
64 + console.log("1st")
65 + console.log(this.searchText, this.prevSearchText);
65 65   this.prevSearchText = this.searchText;
66 - this.fetchWikiSearch().then(results => {
67 - console.log(results);
68 - this.resultsCache = results;
69 - if(this.hasActiveFilters()) {
70 - this.fetchFilterSearch().then(this.filterResults);
71 - } else {
72 - this.results = results;
73 - }
74 - })
75 - /*
76 76   Promise.all([
77 77   this.fetchWikiSearch(),
78 78   this.fetchFilterSearch()
79 79   ]).then(([wikiSearchResults, collabSearchResults]) => {
80 80   this.results = wikiSearchResults;
81 - this.resultsCache = wikiSearchResults;
82 82   console.log(wikiSearchResults, collabSearchResults);
83 83   });
84 - */
85 - } else if (this.searchText === this.prevSearchText && this.hasActiveFilters()) {
74 + } else if (this.searchText === this.prevSearchText) {
75 + console.log("Only apply filter on results");
86 86   this.fetchFilterSearch().then(this.filterResults)
87 - } else {
88 - this.results = this.resultsCache;
89 89   }
90 90   } else {
91 - this.clearResults();
92 92   console.log("no search text, should return filter search results if any");
93 93   this.fetchFilterSearch().then(collabs => {
94 94   console.log("Format and display collabs", collabs);
... ... @@ -113,13 +113,11 @@
113 113   });
114 114   }
115 115   filterResults = (filteredCollabs) => {
103 + console.log("filteredCollabs:", filteredCollabs, "search results:", this.results);
116 116   const collabSpaces = filteredCollabs.map(collab => `Collabs.${collab.name}`);
117 - this.results = this.resultsCache.filter(result => collabSpaces.some(space => result.space.startsWith(space)));
105 + const filteredResults = this.results.filter(result => collabSpaces.some(space => result.space.startsWith(space)));
106 + this.results = filteredResults;
118 118   }
119 - clearResults() {
120 - this.results = [];
121 - this.resultsCache = [];
122 - }
123 123   getLink(xwikiDocSpace) {
124 124   return `/bin/view/${xwikiDocSpace.replaceAll('.', '/')}`;
125 125   }
... ... @@ -128,7 +128,7 @@
128 128  <div>
129 129   <div>
130 130   <input @change="${this.setSearchText}" type="text" placeholder="Search..." />
131 - <button @click="${() => this.handleSearch(true)}">Search</button>
116 + <button @click="${this.handleSearch}">Search</button>
132 132   </div>
133 133   <div>
134 134   <label><input type="checkbox" @change="${() => this.toggleRoleFilter('administrator')}" .checked="${this.administratorFilter}"/> Administrator</label>