mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-04 17:41:23 +01:00
Overview dialogs search (#1260)
* feat: add search functionality to overview components * feat: enhance search functionality * chore: correct typo in pull request template * chore: update version to 1.110.0 and add peer dependencies in package-lock.json; enhance versioning.js with new features * Fix null safety and performance in overview dialogs search (#1272) * Initial plan * fix: add optional chaining and optimize performance in overview dialogs Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
This commit is contained in:
parent
9e0eb03618
commit
f30ffd812e
9 changed files with 149 additions and 63 deletions
|
|
@ -4,18 +4,19 @@ function overviewMarkers() {
|
|||
closeDialogs("#markersOverview, .stable");
|
||||
if (!layerIsOn("toggleMarkers")) toggleMarkers();
|
||||
|
||||
const markerGroup = document.getElementById("markers");
|
||||
const body = document.getElementById("markersBody");
|
||||
const markersInverPin = document.getElementById("markersInverPin");
|
||||
const markersInverLock = document.getElementById("markersInverLock");
|
||||
const markersFooterNumber = document.getElementById("markersFooterNumber");
|
||||
const markersOverviewRefresh = document.getElementById("markersOverviewRefresh");
|
||||
const markersAddFromOverview = document.getElementById("markersAddFromOverview");
|
||||
const markersGenerationConfig = document.getElementById("markersGenerationConfig");
|
||||
const markersRemoveAll = document.getElementById("markersRemoveAll");
|
||||
const markersExport = document.getElementById("markersExport");
|
||||
const markerTypeInput = document.getElementById("addedMarkerType");
|
||||
const markerTypeSelector = document.getElementById("markerTypeSelector");
|
||||
const markerGroup = byId("markers");
|
||||
const body = byId("markersBody");
|
||||
const markersInverPin = byId("markersInverPin");
|
||||
const markersInverLock = byId("markersInverLock");
|
||||
const markersFooterNumber = byId("markersFooterNumber");
|
||||
const markersOverviewRefresh = byId("markersOverviewRefresh");
|
||||
const markersAddFromOverview = byId("markersAddFromOverview");
|
||||
const markersGenerationConfig = byId("markersGenerationConfig");
|
||||
const markersRemoveAll = byId("markersRemoveAll");
|
||||
const markersExport = byId("markersExport");
|
||||
const markerTypeInput = byId("addedMarkerType");
|
||||
const markerTypeSelector = byId("markerTypeSelector");
|
||||
const markersSearch = byId("markersSearch");
|
||||
|
||||
addLines();
|
||||
|
||||
|
|
@ -36,7 +37,8 @@ function overviewMarkers() {
|
|||
listen(markersGenerationConfig, "click", configMarkersGeneration),
|
||||
listen(markersRemoveAll, "click", triggerRemoveAll),
|
||||
listen(markersExport, "click", exportMarkers),
|
||||
listen(markerTypeSelector, "click", toggleMarkerTypeMenu)
|
||||
listen(markerTypeSelector, "click", toggleMarkerTypeMenu),
|
||||
listen(markersSearch, "input", addLines)
|
||||
];
|
||||
|
||||
const types = [{type: "empty", icon: "❓"}, ...Markers.getConfig()];
|
||||
|
|
@ -67,7 +69,17 @@ function overviewMarkers() {
|
|||
}
|
||||
|
||||
function addLines() {
|
||||
const lines = pack.markers
|
||||
let markers = pack.markers;
|
||||
|
||||
const searchText = byId("markersSearch").value.toLowerCase().trim();
|
||||
if (searchText) {
|
||||
markers = markers.filter(marker => {
|
||||
const type = (marker.type || "").toLowerCase();
|
||||
return type.includes(searchText);
|
||||
});
|
||||
}
|
||||
|
||||
const lines = markers
|
||||
.map(({i, type, icon, pinned, lock}) => {
|
||||
return /* html */ `
|
||||
<div class="states" data-i=${i} data-type="${type}">
|
||||
|
|
@ -91,7 +103,8 @@ function overviewMarkers() {
|
|||
.join("");
|
||||
|
||||
body.innerHTML = lines;
|
||||
markersFooterNumber.innerText = pack.markers.length;
|
||||
markersFooterNumber.innerText = markers.length;
|
||||
markersFooterTotal.innerText = pack.markers.length;
|
||||
|
||||
applySorting(markersHeader);
|
||||
}
|
||||
|
|
@ -127,7 +140,7 @@ function overviewMarkers() {
|
|||
}
|
||||
|
||||
function focusOnMarker(i) {
|
||||
highlightElement(document.getElementById(`marker${i}`), 2);
|
||||
highlightElement(byId(`marker${i}`), 2);
|
||||
}
|
||||
|
||||
function pinMarker(el, i) {
|
||||
|
|
@ -165,7 +178,7 @@ function overviewMarkers() {
|
|||
}
|
||||
|
||||
function toggleMarkerTypeMenu() {
|
||||
document.getElementById("markerTypeSelectMenu").classList.toggle("visible");
|
||||
byId("markerTypeSelectMenu").classList.toggle("visible");
|
||||
}
|
||||
|
||||
function toggleAddMarker() {
|
||||
|
|
@ -182,7 +195,7 @@ function overviewMarkers() {
|
|||
function removeMarker(i) {
|
||||
notes = notes.filter(note => note.id !== `marker${i}`);
|
||||
pack.markers = pack.markers.filter(marker => marker.i !== i);
|
||||
document.getElementById(`marker${i}`)?.remove();
|
||||
byId(`marker${i}`)?.remove();
|
||||
addLines();
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +213,7 @@ function overviewMarkers() {
|
|||
if (lock) return true;
|
||||
|
||||
const id = `marker${i}`;
|
||||
document.getElementById(id)?.remove();
|
||||
byId(id)?.remove();
|
||||
notes = notes.filter(note => note.id !== id);
|
||||
return false;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue