adds multiple qol changes

This commit is contained in:
Christian Beutel
2024-02-21 18:28:42 +01:00
parent 2363c677b7
commit a24662a56e
18 changed files with 1236 additions and 99 deletions

View File

@@ -4,30 +4,42 @@
import { trails_delete, trails_index } from "$lib/stores/trail_store";
import { currentUser } from "$lib/stores/user_store";
import { formatMeters, formatTimeHHMM } from "$lib/util/format_util";
import Dropdown from "../base/dropdown.svelte";
import Dropdown, { type DropdownItem } from "../base/dropdown.svelte";
export let trail: Trail;
export let mode: "show" | "edit" = "show";
const dropdownItems = [
{ text: "Edit", value: "edit" },
{ text: "Delete", value: "delete" },
const dropdownItems: DropdownItem[] = [
{ text: "Open", value: "open", icon: "up-right-from-square" },
{ text: "Show on map", value: "map", icon: "map" },
{ text: "Edit", value: "edit", icon: "pen" },
];
async function handleDropdownClick(
currentTrail: Trail,
item: { text: string; value: any },
) {
if (item.value == "edit") {
if (item.value == "open") {
goto(`/trail/view/${currentTrail.id}`);
} else if (item.value == "map") {
goto(`/map/?lat=${currentTrail.lat}&lon=${currentTrail.lon}`);
} else if (item.value == "edit") {
goto(`/trail/edit/${currentTrail.id}`);
} else if (item.value == "delete") {
await trails_delete(currentTrail);
await trails_index();
}
}
async function deleteTrail() {
await trails_delete(trail);
await trails_index();
}
</script>
<div class="trail-card rounded-2xl border sm:w-72 cursor-pointer" on:mouseenter on:mouseleave role="listitem">
<div
class="trail-card rounded-2xl border sm:w-72 cursor-pointer"
on:mouseenter
on:mouseleave
role="listitem"
>
<div class="w-full min-h-40 max-h-48 overflow-hidden rounded-t-2xl">
<img src={trail.thumbnail} alt="" />
</div>

View File

@@ -4,24 +4,26 @@
import { trails_delete, trails_index } from "$lib/stores/trail_store";
import { currentUser } from "$lib/stores/user_store";
import { formatMeters, formatTimeHHMM } from "$lib/util/format_util";
import Dropdown from "../base/dropdown.svelte";
import Dropdown, { type DropdownItem } from "../base/dropdown.svelte";
export let trail: Trail;
const dropdownItems = [
{ text: "Edit", value: "edit" },
{ text: "Delete", value: "delete" },
const dropdownItems: DropdownItem[] = [
{ text: "Open", value: "open", icon: "up-right-from-square" },
{ text: "Show on map", value: "map", icon: "map" },
{ text: "Edit", value: "edit", icon: "pen" },
];
async function handleDropdownClick(
currentTrail: Trail,
item: { text: string; value: any },
) {
if (item.value == "edit") {
if (item.value == "open") {
goto(`/trail/view/${currentTrail.id}`);
} else if (item.value == "map") {
goto(`/map/?lat=${currentTrail.lat}&lon=${currentTrail.lon}`);
} else if (item.value == "edit") {
goto(`/trail/edit/${currentTrail.id}`);
} else if (item.value == "delete") {
await trails_delete(currentTrail);
await trails_index();
}
}
</script>