feat: sous-pages — parent_id, sidebar hiérarchique, bouton +New sub-page
- DB: parent_id dans table pages (ALTER TABLE migration auto) - Sidebar: pages parent_id IS NULL affichées, sous-pages indentées en dessous - API: create_page accepte parent_id (0 = racine) - JS: newSubPage extrait page ID et passe parent_id - page_editor: liste les sous-pages + bouton '+ New sub-page'
This commit is contained in:
@@ -69,11 +69,36 @@
|
||||
<button class="sidebar-new-chat" style="width:auto; padding:8px 16px;" @click="insertMd('# Meeting Notes\n\n**Date:** \n**Attendees:** \n\n## Agenda\n\n- \n\n## Notes\n\n- \n\n## Action Items\n\n- [ ] \n', '')">🎤 Meeting Notes</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sub-pages -->
|
||||
<div style="margin-top:32px; border-top:1px solid var(--border); padding-top:16px;">
|
||||
<h3 style="font-size:14px; font-weight:600; margin-bottom:12px;">Sub-pages</h3>
|
||||
{% for sub in sub_pages %}
|
||||
<a href="/pages/{{ sub.id }}" style="display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius:6px; text-decoration:none; color:var(--text-primary); font-size:13px;"
|
||||
onmouseover="this.style.background='var(--bg-hover)'" onmouseout="this.style.background='transparent'">
|
||||
<span>📄</span> {{ sub.title }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
<button class="kanban-new-card" style="margin-top:8px;"
|
||||
@click="createSubPage()">+ New sub-page</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
function createSubPage() {
|
||||
const csrf = document.cookie.match(/csrf_token=([^;]+)/);
|
||||
const token = csrf ? csrf[1] : '';
|
||||
const project = document.querySelector('[x-data]')?.__x?.$data?.workspaceKey || '';
|
||||
fetch(`/board/api/pages?title=New%20sub-page§ion=Private&project=${encodeURIComponent(project)}&parent_id={{ page.id }}`, {
|
||||
method: 'POST',
|
||||
headers: { 'X-CSRF-Token': token }
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => { window.location.href = `/pages/${data.id}`; })
|
||||
.catch(err => { alert('Failed: ' + err.message); });
|
||||
}
|
||||
// Simple Markdown-to-HTML renderer
|
||||
function renderMarkdown(md) {
|
||||
let html = md
|
||||
|
||||
Reference in New Issue
Block a user