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 26.94
edited by bougault
on 2022/11/17 11:26
Change comment: There is no comment for this version
To version 27.6
edited by bougault
on 2022/11/17 13:00
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -40,7 +40,7 @@
40 40   this.editor = false;
41 41   this.viewer = false;
42 42   this.rolesFilter = [];
43 - this.filterUrl = new URL(`${document.location.origin}/rest/v1/collabs?search=&offset=0&orderField=title&order=asc&favorite=true&roles=`);
43 + this.filterUrl = new URL(`${document.location.origin}/rest/v1/collabs?search=&offset=0&orderField=title&order=asc&favorite=&roles=`);
44 44   this.results = [];
45 45   }
46 46   toggleRoleFilter(roleName) {
... ... @@ -51,22 +51,38 @@
51 51   }
52 52   this[roleName] = !this[roleName];
53 53   this.filterUrl.searchParams.set('roles', this.rolesFilter.join("+"));
54 + // if search text then apply filter
55 + // else return filters result
54 54   }
55 55   setSearchText(e) {
56 56   this.searchText = e.target.value;
57 57   }
58 58   handleSearch() {
59 - console.log(this.searchText);
60 60   if(this.searchText !== "") {
61 - this.fetchWikiSearch();
62 + Promise.all([
63 + this.fetchWikiSearch(),
64 + this.fetchFilterSearch()
65 + ])
66 + } else {
67 + console.log("no search text, should return filter search results if any");
62 62   }
63 63   }
70 + hasActiveFilters() {
71 + // we only look at role filters for POC.
72 + return this.roles.length > 0;
73 + }
64 64   fetchWikiSearch() {
65 65   // request should be built from component, not from "external" dependency. Leave it here like this for POC.
66 - handleXWikiSearch(this.searchText).then(results => this.results = results);
76 + return handleXWikiSearch(this.searchText);
67 67   }
68 - buildFilter() {
69 - //https://wiki-dev.ebrains.eu/rest/v1/collabs?search=&offset=0&orderField=title&order=asc&favorite=true&roles=
78 + fetchFilterSearch() {
79 + return new Promise((resolve) => {
80 + if(hasActiveFilters) {
81 + fetch(this.filterUrl).then(console.log);
82 + } else {
83 + resolve(null);
84 + }
85 + });
70 70   }
71 71   getLink(xwikiDocSpace) {
72 72   return `/bin/view/${xwikiDocSpace.replaceAll('.', '/')}`;