Skip to content

Commit

Permalink
Fix type filter
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasstein committed Dec 6, 2024
1 parent b0f4e4c commit 61603d0
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export default class PortalItemLoaderWidgetController {

private async queryPortal(portal: __esri.Portal, pagination: any, searchText: string, spaceFilter: "all" | "organisation" | "my-content" | "fav", typeFilter: string,
sortAscending: boolean, sortByField: string): Promise<__esri.PortalQueryResult> {
const model = this.portalItemLoaderModel;
const page = pagination.page;
const rowsPerPage = pagination.rowsPerPage;

Expand Down Expand Up @@ -147,19 +146,23 @@ export default class PortalItemLoaderWidgetController {
}
query += "(title:" + searchText + " OR description:" + searchText + " OR snippet:" + searchText + " OR tags:" + searchText + ")";
}
if (typeFilter !== "all") {
if (typeFilter.length) {
if (query !== "") {
query += " AND ";
}
model.typeFilter.forEach((type: string, index: number) => {
if (index === 0) {
query += "(type:" + type;
} else if (index === model.typeFilters.length - 1) {
query += " OR type:" + type + ")";
} else {
query += " OR type:" + type;
}
});
if (typeFilter.length === 1) {
query += "type:" + typeFilter[0];
} else {
typeFilter.forEach((type: string, index: number) => {
if (index === 0) {
query += "(type:" + type;
} else if (index === typeFilter.length - 1) {
query += " OR type:" + type + ")";
} else {
query += " OR type:" + type;
}
});
}
}
const queryParams: __esri.PortalQueryParamsProperties = {
query: query,
Expand Down

0 comments on commit 61603d0

Please sign in to comment.