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
-5
@@ -110,6 +110,17 @@
|
||||
border-bottom: 1px solid var(--surface-4);
|
||||
padding-bottom: var(--size-2);
|
||||
}
|
||||
.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);
|
||||
}
|
||||
.post-image {
|
||||
max-width: 100%;
|
||||
border-radius: var(--radius-2);
|
||||
@@ -326,7 +337,6 @@
|
||||
const container = document.getElementById('post-content');
|
||||
const isOwner = currentUser && currentUser.id === currentJourney.owner_id;
|
||||
const canEdit = canEditJourney();
|
||||
const canComment = currentJourney.visibility === 'public' || isOwner;
|
||||
|
||||
// Build chapters from markers
|
||||
let chaptersHtml = '';
|
||||
@@ -363,14 +373,15 @@
|
||||
<div class="post-meta">
|
||||
<i class="fas fa-calendar-alt"></i> ${new Date(currentJourney.created_at).toLocaleDateString()}
|
||||
${currentJourney.visibility === 'public' ? '<span class="badge">Public</span>' : ''}
|
||||
${currentJourney.visibility === 'shared' && !isOwner ? `<span class="badge">${canEdit ? 'Shared edit' : 'Shared'}</span>` : ''}
|
||||
</div>
|
||||
${currentJourney.image ? `<img class="post-image" src="${currentJourney.image}" alt="${currentJourney.title}">` : ''}
|
||||
<div class="post-description">${escapeHtml(currentJourney.description).replace(/\n/g, '<br>')}</div>
|
||||
${chaptersHtml}
|
||||
${isOwner ? `
|
||||
${canEdit || isOwner ? `
|
||||
<div style="margin-top: var(--size-4); display: flex; gap: var(--size-2);">
|
||||
<a href="journey-edit.html?id=${currentJourney.id}" class="btn btn-sm"><i class="fas fa-edit"></i> Edit</a>
|
||||
<button id="delete-journey-btn" class="btn btn-danger btn-sm"><i class="fas fa-trash"></i> Delete</button>
|
||||
${canEdit ? `<a href="journey-edit.html?id=${currentJourney.id}" class="btn btn-sm"><i class="fas fa-edit"></i> Edit</a>` : ''}
|
||||
${isOwner ? `<button id="delete-journey-btn" class="btn btn-danger btn-sm"><i class="fas fa-trash"></i> Delete</button>` : ''}
|
||||
</div>
|
||||
` : ''}
|
||||
</article>
|
||||
@@ -398,6 +409,17 @@
|
||||
&& currentJourney.shared_edit.includes(currentUser.id);
|
||||
}
|
||||
|
||||
function canViewJourney() {
|
||||
if (!currentUser || !currentJourney) return false;
|
||||
if (currentUser.id === currentJourney.owner_id) return true;
|
||||
if (currentJourney.visibility === 'public') return true;
|
||||
return currentJourney.visibility === 'shared'
|
||||
&& (
|
||||
(Array.isArray(currentJourney.shared_read) && currentJourney.shared_read.includes(currentUser.id))
|
||||
|| (Array.isArray(currentJourney.shared_edit) && currentJourney.shared_edit.includes(currentUser.id))
|
||||
);
|
||||
}
|
||||
|
||||
function getMarkerImages(marker) {
|
||||
return marker.images || (marker.image ? [marker.image] : []);
|
||||
}
|
||||
@@ -551,7 +573,7 @@
|
||||
function renderComments(comments) {
|
||||
const container = document.getElementById('comments-section');
|
||||
const isOwner = currentUser && currentUser.id === currentJourney.owner_id;
|
||||
const canComment = currentJourney.visibility === 'public' || isOwner;
|
||||
const canComment = canViewJourney();
|
||||
|
||||
if (!comments.length) {
|
||||
container.innerHTML = `
|
||||
|
||||
Reference in new issue
Block a user