@@ -45,7 +51,7 @@
month: "long",
day: "2-digit",
year: "numeric",
- timeZone: 'UTC'
+ timeZone: "UTC",
})}
{/if}
@@ -65,12 +71,12 @@
{formatDistance(
- trail.distance
+ trail.distance,
)}
{formatElevation(
- trail.elevation_gain
+ trail.elevation_gain,
)}
void;
let openShareModal: () => void;
+ const allowEdit =
+ trail.author == $currentUser?.id ||
+ trail.expand.trail_share_via_trail?.some((s) => s.permission == "edit");
+
const dropdownItems: DropdownItem[] = [
mode == "overview"
? { text: $_("show-on-map"), value: "show", icon: "map" }
@@ -49,9 +55,15 @@
: []),
{ text: $_("print"), value: "print", icon: "print" },
{ text: $_("add-to-list"), value: "list", icon: "bookmark" },
- { text: $_("share"), value: "share", icon: "share" },
- { text: $_("edit"), value: "edit", icon: "pen" },
- { text: $_("delete"), value: "delete", icon: "trash" },
+ ...(trail.author != pb.authStore.model?.id
+ ? []
+ : [{ text: $_("share"), value: "share", icon: "share" }]),
+ ...(allowEdit
+ ? [{ text: $_("edit"), value: "edit", icon: "pen" }]
+ : []),
+ ...(trail.author == $currentUser?.id
+ ? [{ text: $_("delete"), value: "delete", icon: "trash" }]
+ : []),
];
async function handleDropdownClick(item: { text: string; value: any }) {
@@ -72,7 +84,7 @@
?.focus();
} else if (item.value == "print") {
goto(`/map/trail/${trail.id}/print`);
- } else if (item.value == "share") {
+ } else if (item.value == "share") {
openShareModal();
} else if (item.value == "download") {
openExportModal();
@@ -189,4 +201,4 @@
bind:openModal={openExportModal}
on:export={(e) => exportTrail(e.detail)}
>
-
+
diff --git a/web/src/lib/components/trail/trail_info_panel.svelte b/web/src/lib/components/trail/trail_info_panel.svelte
index 76293a94..6ef0bd1a 100644
--- a/web/src/lib/components/trail/trail_info_panel.svelte
+++ b/web/src/lib/components/trail/trail_info_panel.svelte
@@ -31,6 +31,7 @@
import Textarea from "../base/textarea.svelte";
import CommentCard from "../comment/comment_card.svelte";
import PhotoGallery from "../photo_gallery.svelte";
+ import TrailShareInfo from "./trail_share_info.svelte";
export let trail: Trail;
export let mode: "overview" | "map" = "map";
@@ -93,7 +94,7 @@
shadowUrl: "",
},
})
- .on("loaded", function (e) {
+ .on("loaded", function (e) {
map.fitBounds(e.target.getBounds());
})
.addTo(map);
@@ -152,14 +153,31 @@
- {#if $currentUser && $currentUser.id == trail.author}
+ {#if ($currentUser && $currentUser.id == trail.author) || trail.expand.trail_share_via_trail?.length}
{/if}
diff --git a/web/src/lib/components/trail/trail_list_item.svelte b/web/src/lib/components/trail/trail_list_item.svelte
index 5dc38b8f..ee5aa231 100644
--- a/web/src/lib/components/trail/trail_list_item.svelte
+++ b/web/src/lib/components/trail/trail_list_item.svelte
@@ -1,5 +1,4 @@
+
+
+
(showInfo = false)}
+ >
+ {#if showInfo}
+
+ {/if}
+
diff --git a/web/src/lib/components/trail/trail_share_modal.svelte b/web/src/lib/components/trail/trail_share_modal.svelte
index 61f5d369..ab3204f0 100644
--- a/web/src/lib/components/trail/trail_share_modal.svelte
+++ b/web/src/lib/components/trail/trail_share_modal.svelte
@@ -1,15 +1,35 @@
updateUsers(e.detail)}
+ on:click={(e) => shareTrail(e.detail)}
placeholder={`${$_("username")}`}
items={searchItems}
- >
+ >
+

+
+
{$_('shared-with')}
+
+ {#if $shares.length == 0}
+
+ {$_('trail-not-shared')}
+
+ {:else}
+ {#each $shares as share}
+ {#if share.expand}
+
+

+
{share.expand.user.username}
+
{$_('can')}
+
+
+
+
+
+
+ {/if}
+ {/each}
+ {/if}