Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy into production #214

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/resources/web/app/qs-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class QsForm extends LitElement {
}
const controller = new AbortController();
this._abortController = controller;
this.dispatchEvent(new CustomEvent(QS_START_EVENT));
this.dispatchEvent(new CustomEvent(QS_START_EVENT, { detail: { page: this._page } }));
const data = this._readQueryInputs();
if (this.localSearch) {
this._localSearch();
Expand All @@ -123,15 +123,14 @@ export class QsForm extends LitElement {

this._jsonFetch(controller, 'GET', data, this._page > 0 ? this.initialTimeout : this.moreTimeout)
.then((r: any) => {
let event = QS_RESULT_EVENT;
if (this._page > 0) {
this._currentHitCount += r.hits.length;
} else {
this._currentHitCount = r.hits.length;
}
const total = r.total?.lowerBound;
const hasMoreHits = r.hits.length > 0 && total > this._currentHitCount;
this.dispatchEvent(new CustomEvent(event, {detail: {...r, page: this._page, hasMoreHits}}));
this.dispatchEvent(new CustomEvent(QS_RESULT_EVENT, {detail: {...r, search: data, page: this._page, hasMoreHits}}));
this.dispatchEvent(new CustomEvent(QS_END_EVENT));
}).catch(e => {
console.error('Could not run search: ' + e);
Expand Down Expand Up @@ -211,13 +210,14 @@ export class QsForm extends LitElement {
}

private _localSearch(): any {
let hits = LocalSearch.search(this._readQueryInputs());
let search = this._readQueryInputs();
let hits = LocalSearch.search(search);
if(!!hits) {
const result = {
hits,
total: hits.length
}
this.dispatchEvent(new CustomEvent(QS_RESULT_EVENT, {detail: {...result, page: 0, hasMoreHits: false}}));
this.dispatchEvent(new CustomEvent(QS_RESULT_EVENT, {detail: {...result, search, page: 0, hasMoreHits: false}}));
}
this.dispatchEvent(new CustomEvent(QS_END_EVENT));
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/web/app/qs-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ export class QsTarget extends LitElement {
this._result.hasMoreHits = e.detail.hasMoreHits;
}

private _loadingStart = () => {
private _loadingStart = (e:CustomEvent) => {
this._loading = true;
if(e.detail.page === 0) {
this._result = undefined;
}
}

private _loadingEnd = () => {
Expand Down
Loading