count: number;
title: string;
pages?: number;
+ pageNo?: number;
searchID?: number;
template?: string;
};
private initEventListener(): void {
this.form.addEventListener("submit", (event) => {
event.preventDefault();
+ this.activePage = 1;
void this.search();
});
this.typeInput.addEventListener("change", () => this.changeType());
const request = dboAction("search", "wcf\\data\\search\\SearchAction").payload(this.getFormData());
this.lastSearchRequest = request.getAbortController();
- const { count, searchID, title, pages, template } = (await request.dispatch()) as ResponseSearch;
+ const { count, searchID, title, pages, pageNo, template } = (await request.dispatch()) as ResponseSearch;
document.querySelector(".contentTitle")!.textContent = title;
this.searchID = searchID;
- this.activePage = 1;
this.removeSearchResults();
if (count > 0) {
this.pages = pages!;
+ this.activePage = pageNo!;
this.showSearchResults(template!);
}
}
parameters.push([key, value.toString().trim()]);
}
});
+ if (this.activePage > 1) {
+ parameters.push(["pageNo", this.activePage.toString()]);
+ }
url.search += new URLSearchParams(parameters);
window.history.replaceState({}, document.title, url.toString());
data[key] = value;
}
});
+ if (this.activePage > 1) {
+ data["pageNo"] = this.activePage;
+ }
return data;
}
private initQueryString(): void {
const url = new URL(window.location.href);
url.searchParams.forEach((value, key) => {
+ if (key === "pageNo") {
+ this.activePage = parseInt(value, 10);
+ if (this.activePage < 1) this.activePage = 1;
+ return;
+ }
+
const element = this.form.elements[key] as HTMLElement;
if (value && element) {
if (element instanceof RadioNodeList) {
initEventListener() {
this.form.addEventListener("submit", (event) => {
event.preventDefault();
+ this.activePage = 1;
void this.search();
});
this.typeInput.addEventListener("change", () => this.changeType());
(_a = this.lastSearchRequest) === null || _a === void 0 ? void 0 : _a.abort();
const request = (0, Ajax_1.dboAction)("search", "wcf\\data\\search\\SearchAction").payload(this.getFormData());
this.lastSearchRequest = request.getAbortController();
- const { count, searchID, title, pages, template } = (await request.dispatch());
+ const { count, searchID, title, pages, pageNo, template } = (await request.dispatch());
document.querySelector(".contentTitle").textContent = title;
this.searchID = searchID;
- this.activePage = 1;
this.removeSearchResults();
if (count > 0) {
this.pages = pages;
+ this.activePage = pageNo;
this.showSearchResults(template);
}
}
parameters.push([key, value.toString().trim()]);
}
});
+ if (this.activePage > 1) {
+ parameters.push(["pageNo", this.activePage.toString()]);
+ }
url.search += new URLSearchParams(parameters);
window.history.replaceState({}, document.title, url.toString());
}
data[key] = value;
}
});
+ if (this.activePage > 1) {
+ data["pageNo"] = this.activePage;
+ }
return data;
}
initQueryString() {
const url = new URL(window.location.href);
url.searchParams.forEach((value, key) => {
+ if (key === "pageNo") {
+ this.activePage = parseInt(value, 10);
+ if (this.activePage < 1)
+ this.activePage = 1;
+ return;
+ }
const element = this.form.elements[key];
if (value && element) {
if (element instanceof RadioNodeList) {
$this->readString('endDate', true);
$this->readString('sortField', true);
$this->readString('sortOrder', true);
+ $this->readInteger('pageNo', true);
if (empty($this->parameters['q']) && empty($this->parameters['username'])) {
throw new UserInputException('q');
];
}
- $resultHandler = new SearchResultHandler($search);
+ $startIndex = 0;
+ if ($this->parameters['pageNo'] > 1) {
+ $startIndex = SEARCH_RESULTS_PER_PAGE * ($this->parameters['pageNo'] - 1);
+ }
+ $resultHandler = new SearchResultHandler($search, $startIndex);
$resultHandler->loadSearchResults();
$templateName = $resultHandler->getTemplateName();
'query' => $resultHandler->getQuery(),
]),
'pages' => \ceil($resultHandler->countSearchResults() / SEARCH_RESULTS_PER_PAGE),
+ 'pageNo' => $this->parameters['pageNo'] ?: 1,
'searchID' => $search->searchID,
'template' => WCF::getTPL()->fetch($templateName['templateName'], $templateName['application']),
];