feat: implement single POST upsert API with automatic ID generation
- Replace separate POST/PUT endpoints with unified POST upsert - Add automatic content ID generation from element context when no ID provided - Implement version history preservation before content updates - Add element context support for backend ID generation - Update frontend to use single endpoint for all content operations - Enhanced demo site with latest database content including proper content IDs
This commit is contained in:
@@ -106,24 +106,14 @@ export class InsertrCore {
|
||||
getElementMetadata(element) {
|
||||
const existingId = element.getAttribute('data-content-id');
|
||||
|
||||
if (existingId) {
|
||||
// Enhanced site - use existing ID
|
||||
return {
|
||||
contentId: existingId,
|
||||
contentType: element.getAttribute('data-content-type') || this.detectContentType(element),
|
||||
element: element,
|
||||
hasExistingId: true
|
||||
};
|
||||
} else {
|
||||
// Non-enhanced site - prepare context for backend ID generation
|
||||
return {
|
||||
contentId: null, // Backend will generate
|
||||
contentType: this.detectContentType(element),
|
||||
element: element,
|
||||
elementContext: this.extractElementContext(element),
|
||||
hasExistingId: false
|
||||
};
|
||||
}
|
||||
// Always provide both existing ID (if any) and element context
|
||||
// Backend will use existing ID if provided, or generate new one from context
|
||||
return {
|
||||
contentId: existingId, // null if new content, existing ID if updating
|
||||
contentType: element.getAttribute('data-content-type') || this.detectContentType(element),
|
||||
element: element,
|
||||
elementContext: this.extractElementContext(element)
|
||||
};
|
||||
}
|
||||
|
||||
// Extract element context for backend ID generation
|
||||
|
||||
Reference in New Issue
Block a user