add filtering and sorting features; enhance events and articles pages with URL state persistence

This commit is contained in:
ImBenji
2026-04-23 23:03:11 +01:00
parent bec6763191
commit 194442ec4c
8 changed files with 274 additions and 16 deletions
+27
View File
@@ -1,9 +1,23 @@
// intelligence → knowledge table
// filter/sort/pagination persisted via url query params
// depends on: app.js, intel-shared.js
let knowledgeOffset = 0;
function syncUrl() {
const companyId = document.getElementById("i-company").value;
const type = document.getElementById("i-type").value;
const sort = document.getElementById("i-sort").value;
queryWrite({
company_id: companyId,
type: type,
sort: sort && sort !== "id" ? sort : "",
offset: knowledgeOffset > 0 ? knowledgeOffset : "",
});
}
async function loadKnowledge() {
const companyId = document.getElementById("i-company").value;
const type = document.getElementById("i-type").value;
@@ -45,19 +59,32 @@ async function loadKnowledge() {
document.addEventListener("DOMContentLoaded", async () => {
document.getElementById("iPrevBtn").onclick = () => {
knowledgeOffset = Math.max(0, knowledgeOffset - PAGE);
syncUrl();
loadKnowledge();
};
document.getElementById("iNextBtn").onclick = () => {
knowledgeOffset += PAGE;
syncUrl();
loadKnowledge();
};
document.getElementById("i-filter-btn").onclick = () => {
knowledgeOffset = 0;
syncUrl();
loadKnowledge();
};
const ok = await loadIntelStatsRow();
if (!ok) return;
await loadIntelCompanies();
// restore from url (after dropdown is populated so company_id options exist)
queryApplyToInputs({
"i-company": "company_id",
"i-type": "type",
"i-sort": "sort",
});
knowledgeOffset = parseInt(queryGet("offset"), 10) || 0;
loadKnowledge();
});