Add journey sharing and collaboration
This commit is contained in:
1 parent
770ab0e5df
commit
c136f01f2e
4 files changed
+262
-17
No files matched your search
+27
-2
@@ -217,6 +217,17 @@
|
||||
.filter-btn:hover {
|
||||
background: var(--surface-4);
|
||||
}
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: var(--size-2);
|
||||
padding: 2px var(--size-2);
|
||||
border-radius: var(--radius-2);
|
||||
background: var(--indigo-1);
|
||||
color: var(--indigo-8);
|
||||
font-size: var(--font-size-0);
|
||||
font-weight: var(--font-weight-6);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -227,6 +238,7 @@
|
||||
<div class="filter-tabs">
|
||||
<button class="filter-btn active" data-filter="all">All</button>
|
||||
<button class="filter-btn" data-filter="own">My Posts</button>
|
||||
<button class="filter-btn" data-filter="shared">Shared With Me</button>
|
||||
<button class="filter-btn" data-filter="public">Public Posts</button>
|
||||
</div>
|
||||
<nav class="site-nav">
|
||||
@@ -287,19 +299,32 @@
|
||||
<div class="post-card-meta">
|
||||
<i class="fas fa-calendar-alt"></i> ${new Date(journey.created_at).toLocaleDateString()}
|
||||
${journey.markers ? `<span style="margin-left: 12px;"><i class="fas fa-map-marker-alt"></i> ${journey.markers.length} chapters</span>` : ''}
|
||||
${journey.visibility === 'public' ? '<span class="badge">Public</span>' : ''}
|
||||
${getJourneyBadges(journey)}
|
||||
</div>
|
||||
<div class="post-card-excerpt">${escapeHtml(journey.description || journey.markers?.[0]?.text?.substring(0, 150) + '…')}</div>
|
||||
</div>
|
||||
</article>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function getJourneyBadges(journey) {
|
||||
const badges = [];
|
||||
const isOwner = journey.owner_id === currentUser?.id;
|
||||
const isShared = journey.visibility === 'shared' && !isOwner;
|
||||
|
||||
if (journey.visibility === 'public') badges.push('Public');
|
||||
if (isShared) badges.push(journey.can_edit ? 'Shared edit' : 'Shared');
|
||||
|
||||
return badges.map((badge) => `<span class="badge">${badge}</span>`).join('');
|
||||
}
|
||||
|
||||
function filterJourneys(filter) {
|
||||
if (filter === 'all') {
|
||||
renderJourneys(allJourneys);
|
||||
} else if (filter === 'own') {
|
||||
renderJourneys(allJourneys.filter(j => j.owner_id === currentUser?.id));
|
||||
} else if (filter === 'shared') {
|
||||
renderJourneys(allJourneys.filter(j => j.owner_id !== currentUser?.id && j.visibility === 'shared'));
|
||||
} else if (filter === 'public') {
|
||||
renderJourneys(allJourneys.filter(j => j.visibility === 'public'));
|
||||
}
|
||||
@@ -322,4 +347,4 @@
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in new issue
Block a user