fix: document view navigates back to project, not dashboard
This commit is contained in:
@@ -3,17 +3,25 @@
|
||||
import { api } from '../api.js';
|
||||
|
||||
export async function renderDocument(app) {
|
||||
const { id } = app.state.params;
|
||||
const { id, projectId } = app.state.params;
|
||||
let doc;
|
||||
|
||||
try {
|
||||
doc = await api.getDocument(id);
|
||||
} catch (e) {
|
||||
app.showToast('Failed to load document', 'error');
|
||||
app.navigate('dashboard');
|
||||
app.navigate('projects');
|
||||
return;
|
||||
}
|
||||
|
||||
const backToProject = () => {
|
||||
if (projectId) {
|
||||
app.navigate('project', { id: projectId });
|
||||
} else {
|
||||
app.navigate('projects');
|
||||
}
|
||||
};
|
||||
|
||||
const appEl = document.getElementById('app');
|
||||
|
||||
function render() {
|
||||
@@ -23,7 +31,7 @@ export async function renderDocument(app) {
|
||||
|
||||
appEl.innerHTML = `
|
||||
<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">
|
||||
<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>
|
||||
@@ -84,7 +92,7 @@ export async function renderDocument(app) {
|
||||
// Store the tag to filter by in app state so dashboard can pick it up
|
||||
app.state.selectedTag = tag;
|
||||
app.state.selectedLibrary = null;
|
||||
app.navigate('dashboard');
|
||||
backToProject();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -117,7 +125,7 @@ export async function renderDocument(app) {
|
||||
try {
|
||||
await api.deleteDocument(id);
|
||||
app.showToast('Document deleted', 'success');
|
||||
app.navigate('dashboard');
|
||||
backToProject();
|
||||
} catch (e) {
|
||||
app.showToast('Failed to delete', 'error');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user