add user texts and text detail pages
new /texts page lets a user manage their own texts (list +
create form linking to /texts/{id}); /texts/{id} reuses
text.js for the node tree, with a back link to /texts. home
gains a 'My texts' link in the header. the admin texts page
now sources its cross-user list from /api/texts/all.
This commit is contained in:
parent
7473af4163
commit
6d11f7e887
5 changed files with 111 additions and 4 deletions
|
|
@ -3,17 +3,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
const form = document.getElementById('texts-form');
|
||||
|
||||
async function loadTexts() {
|
||||
const res = await fetch('/api/texts', {
|
||||
const res = await fetch('/api/texts/all', {
|
||||
credentials: 'same-origin',
|
||||
});
|
||||
const texts = await res.json();
|
||||
textsList.innerHTML = texts.map(text =>
|
||||
'<li class="card"><a class="card-link"'
|
||||
textsList.innerHTML = texts.map(function (text) {
|
||||
return '<li class="card"><a class="card-link"'
|
||||
+ ' href=/admin/texts/'
|
||||
+ text.id
|
||||
+ '>'
|
||||
+ text.name
|
||||
+ '</a></li>').join('');
|
||||
+ '</a></li>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
form.addEventListener('submit', async (e) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue