feat(database): full-page database conversion (Notion-style)
- Migration: add collection_id column to pages table
- POST /api/pages/{id}/convert-to-database: transforms page into database
- GET /api/collections/{id}/table-data: returns props + pages for table view
- POST /api/collections/{id}/pages: creates new row in collection
- New page_editor_collection.html template for database view
- _database_table.html: Notion-style table with columns, rows, New Page, Add Property
- Alpine.js component for cell editing, new page creation, property mgmt
- CSS: complete database table styling (view bar, table, cells, modals, dropdowns)
- Frontend: createDatabase() now converts page to full-page DB (was inline embed)
This commit is contained in:
@@ -325,20 +325,19 @@
|
||||
// ── v4.5.0+: Get Started actions ──
|
||||
inlineDBs:[],
|
||||
async createDatabase(){
|
||||
const name=prompt('Database name:','New Database');
|
||||
const name=prompt('Database name:',this.pageTitle||'New Database');
|
||||
if(!name||!name.trim())return;
|
||||
const csrf=document.cookie.match(/csrf_token=([^;]+)/);
|
||||
try{
|
||||
const r=await fetch('/db/inline/api',{
|
||||
const r=await fetch(`/api/pages/${this.pid}/convert-to-database`,{
|
||||
method:'POST',headers:{'Content-Type':'application/json','X-CSRF-Token':csrf?csrf[1]:''},
|
||||
body:JSON.stringify({name:name.trim(),parent_page_id:this.pid})
|
||||
body:JSON.stringify({name:name.trim()})
|
||||
});
|
||||
const d=await r.json();
|
||||
if(d.id){
|
||||
this.inlineDBs.push({id:d.id,name:d.name,view_type:'table'});
|
||||
this.showToast('Database created — '+d.name);
|
||||
this.saveDBsToPage();
|
||||
this.renderInlineDBs();
|
||||
if(d.status==='converted'){
|
||||
this.showToast('Database created — reloading...');
|
||||
// Reload to show the database table view
|
||||
setTimeout(()=>{window.location.href=d.view_url;},500);
|
||||
}else{
|
||||
this.showToast('Failed to create database');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user