Skip to content

Commit

Permalink
feat: wip - display of facets
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel committed Apr 24, 2024
1 parent 2b3ae2d commit c85b23f
Show file tree
Hide file tree
Showing 11 changed files with 634 additions and 82 deletions.
2 changes: 1 addition & 1 deletion frontend/public/off.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
</div>
<div class="row" style="padding-top: 1rem">
<div class="large-2 columns">
<strong>**TODO** Facets</strong>
<searchalicious-facets search-name="off"></searchalicious-facets>
</div>
<div class="large-10 columns">
<div id="search_results" style="clear: left">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/event-listener-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Constructor<T = {}> = new (...args: any[]) => T;

export declare class EventRegistrationInterface {
export interface EventRegistrationInterface {
/**
* Calls window.addEventListener if not remove before next AnimationFrame
* @param event - event name
Expand Down
1 change: 1 addition & 0 deletions frontend/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface SearchResultDetail extends BaseSearchDetail {
pageCount: number;
pageSize: number;
currentPage: number;
aggregations: Object; // FIXME: we could be more precise
}

/**
Expand Down
1 change: 1 addition & 0 deletions frontend/src/search-a-licious.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export {SearchaliciousBar} from './search-bar';
export {SearchaliciousButton} from './search-button';
export {SearchaliciousPages} from './search-pages';
export {SearchaliciousFacets} from './search-facets';
export {SearchaliciousResults} from './search-results';
10 changes: 8 additions & 2 deletions frontend/src/search-ctl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {LitElement} from 'lit';
import {property, state} from 'lit/decorators.js';
import {EventRegistrationMixin} from './event-listener-setup';
import {
EventRegistrationInterface,
EventRegistrationMixin,
} from './event-listener-setup';
import {SearchaliciousEvents} from './enums';
import {
ChangePageEvent,
Expand All @@ -12,7 +15,8 @@ import {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Constructor<T = {}> = new (...args: any[]) => T;

export declare class SearchaliciousSearchInterface {
export interface SearchaliciousSearchInterface
extends EventRegistrationInterface {
query: string;
name: string;
baseUrl: string;
Expand Down Expand Up @@ -177,6 +181,7 @@ export const SearchaliciousSearchMixin = <T extends Constructor<LitElement>>(
*/
async search(page?: number) {
const response = await fetch(this._searchUrl(page));
// FIXME data should be typed…
const data = await response.json();
this._results = data.hits;
this._count = data.count;
Expand All @@ -191,6 +196,7 @@ export const SearchaliciousSearchMixin = <T extends Constructor<LitElement>>(
pageCount: this._pageCount!,
currentPage: this._currentPage!,
pageSize: this.pageSize,
aggregations: data.aggregations,
};
this.dispatchEvent(
new CustomEvent(SearchaliciousEvents.NEW_RESULT, {
Expand Down
Loading

0 comments on commit c85b23f

Please sign in to comment.