merge trails function added (#627)

* merge trails function added

* fix conflict resolve issues

* avoid incorrect authorship when merging trail comments

* require edit access for all selected trails before merge

* fix likes checkbox binding in trail merge modal

* improve error handling

* require editable target and deletable sources for merge

* avoid duplicate trail fetch during merge

* prevent duplicate likes when merging trails

* check photo download responses during trail merge

* add merge completion toast notifications

* cleanup

* small fixes

* move merge code to backend, option to merge single trail selection with similar one, automatic merge for integrations add as option, maintenance page to find and merge similar trails added

* fix build error

* fix

* docu, beautifying, refactoring

---------

Co-authored-by: Flomp <Flomp@users.noreply.github.com>
This commit is contained in:
slothful-vassal
2026-05-09 13:09:26 +02:00
committed by GitHub
parent d2268429c7
commit b5739cb72e
43 changed files with 5232 additions and 216 deletions

View File

@@ -1,7 +1,8 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { page } from "$app/state";
import Tabs from "$lib/components/base/tabs.svelte";
import TrailDropdown from "$lib/components/trail/trail_dropdown.svelte";
import TrailDropdown, { type MergeResult } from "$lib/components/trail/trail_dropdown.svelte";
import { Comment } from "$lib/models/comment";
import type { Trail } from "$lib/models/trail";
@@ -269,6 +270,21 @@
summitLogs.set(newSummitLogList);
}
function handleTrailMerge(result: MergeResult) {
if (!trail.id || !result.deletedTrailIds.includes(trail.id)) {
return;
}
const targetHandle = handleFromRecordWithIRI(result.targetTrail);
const targetPath =
mode === "map"
? `/map/trail/${targetHandle}/${result.targetTrail.id}`
: `/trail/view/${targetHandle}/${result.targetTrail.id}`;
const search = page.url.searchParams.toString();
goto(search ? `${targetPath}?${search}` : targetPath);
}
async function markTrailAsCompleted() {
trail.completed = true;
const updatedTrail: Trail = { ...trail };
@@ -430,6 +446,7 @@
trails={new Set<Trail>([trail])}
onDelete={() =>
history.length ? history.back() : goto("/trails")}
onMerge={handleTrailMerge}
{mode}
></TrailDropdown>
</div>