fix: document view navigates back to project, not dashboard
This commit is contained in:
@@ -3,16 +3,24 @@
|
|||||||
import { api } from '../api.js';
|
import { api } from '../api.js';
|
||||||
|
|
||||||
export async function renderDocument(app) {
|
export async function renderDocument(app) {
|
||||||
const { id } = app.state.params;
|
const { id, projectId } = app.state.params;
|
||||||
let doc;
|
let doc;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
doc = await api.getDocument(id);
|
doc = await api.getDocument(id);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
app.showToast('Failed to load document', 'error');
|
app.showToast('Failed to load document', 'error');
|
||||||
app.navigate('dashboard');
|
app.navigate('projects');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const backToProject = () => {
|
||||||
|
if (projectId) {
|
||||||
|
app.navigate('project', { id: projectId });
|
||||||
|
} else {
|
||||||
|
app.navigate('projects');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const appEl = document.getElementById('app');
|
const appEl = document.getElementById('app');
|
||||||
|
|
||||||
@@ -23,7 +31,7 @@ export async function renderDocument(app) {
|
|||||||
|
|
||||||
appEl.innerHTML = `
|
appEl.innerHTML = `
|
||||||
<header class="app-header">
|
<header class="app-header">
|
||||||
<button type="button" class="btn btn-ghost" onclick="window.app.navigate('dashboard')">← Back</button>
|
<button type="button" class="btn btn-ghost" onclick="backToProject()">← Back</button>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<button type="button" class="btn btn-ghost" onclick="window.app.navigate('editor', {id: '${doc.id}'})">✏️ Edit</button>
|
<button type="button" class="btn btn-ghost" onclick="window.app.navigate('editor', {id: '${doc.id}'})">✏️ Edit</button>
|
||||||
<button type="button" class="btn btn-ghost" onclick="exportDoc()">📥 Export</button>
|
<button type="button" class="btn btn-ghost" onclick="exportDoc()">📥 Export</button>
|
||||||
@@ -84,7 +92,7 @@ export async function renderDocument(app) {
|
|||||||
// Store the tag to filter by in app state so dashboard can pick it up
|
// Store the tag to filter by in app state so dashboard can pick it up
|
||||||
app.state.selectedTag = tag;
|
app.state.selectedTag = tag;
|
||||||
app.state.selectedLibrary = null;
|
app.state.selectedLibrary = null;
|
||||||
app.navigate('dashboard');
|
backToProject();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +125,7 @@ export async function renderDocument(app) {
|
|||||||
try {
|
try {
|
||||||
await api.deleteDocument(id);
|
await api.deleteDocument(id);
|
||||||
app.showToast('Document deleted', 'success');
|
app.showToast('Document deleted', 'success');
|
||||||
app.navigate('dashboard');
|
backToProject();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
app.showToast('Failed to delete', 'error');
|
app.showToast('Failed to delete', 'error');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user