Implement class-based template differentiation and fix collection item creation

- Add class-based template comparison to differentiate styling variants
- Implement template deduplication based on structure + class signatures
- Add GetCollectionTemplate method to repository interface and implementations
- Fix collection item creation by replacing unimplemented CreateCollectionItemAtomic
- Add template selection modal with auto-default selection in frontend
- Generate meaningful template names from distinctive CSS classes
- Fix unique constraint violations with timestamp-based collection item IDs
- Add collection templates API endpoint for frontend template fetching
- Update simple demo with featured/compact/dark testimonial variants for testing
This commit is contained in:
2025-10-27 21:02:59 +01:00
parent 0bad96d866
commit 00255cb105
10 changed files with 486 additions and 33 deletions

View File

@@ -242,6 +242,29 @@ export class ApiClient {
}
}
/**
* Get available templates for a collection
* @param {string} collectionId - Collection ID
* @returns {Promise<Array>} Array of collection templates
*/
async getCollectionTemplates(collectionId) {
try {
const collectionsUrl = this.getCollectionsUrl();
const response = await fetch(`${collectionsUrl}/${collectionId}/templates?site_id=${this.siteId}`);
if (response.ok) {
const result = await response.json();
return result.templates || [];
} else {
console.warn(`⚠️ Failed to fetch collection templates (${response.status}): ${collectionId}`);
return [];
}
} catch (error) {
console.error('Failed to fetch collection templates:', collectionId, error);
return [];
}
}
/**
* Reorder collection items in bulk
* @param {string} collectionId - Collection ID