- Create platform_service.py to move DB queries from platforms.py API - Create platform.py exceptions for PlatformNotFoundException - Update platforms.py API to use platform_service - Update vendor/content_pages.py to use vendor_service - Add get_vendor_by_id_optional method to VendorService - Fix platforms.js: add centralized logger and init guard - Fix content-page-edit.html: use modal macro instead of inline modal All 21 architecture validation errors resolved. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
/**
|
|
* Platforms Manager - Alpine.js Component
|
|
*
|
|
* Handles platform listing and management for multi-platform CMS.
|
|
*/
|
|
|
|
const platformsLog = window.LogConfig.createLogger('PLATFORMS');
|
|
|
|
function platformsManager() {
|
|
return {
|
|
// State
|
|
platforms: [],
|
|
loading: true,
|
|
error: null,
|
|
|
|
// Lifecycle
|
|
async init() {
|
|
// Duplicate initialization guard
|
|
if (window._adminPlatformsInitialized) return;
|
|
window._adminPlatformsInitialized = true;
|
|
|
|
this.currentPage = "platforms";
|
|
await this.loadPlatforms();
|
|
},
|
|
|
|
// API Methods
|
|
async loadPlatforms() {
|
|
this.loading = true;
|
|
this.error = null;
|
|
|
|
try {
|
|
const response = await apiClient.get("/admin/platforms");
|
|
this.platforms = response.platforms || [];
|
|
platformsLog.info(`Loaded ${this.platforms.length} platforms`);
|
|
} catch (err) {
|
|
platformsLog.error("Error loading platforms:", err);
|
|
this.error = err.message || "Failed to load platforms";
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
},
|
|
|
|
// Helper Methods
|
|
getPlatformIcon(code) {
|
|
const icons = {
|
|
oms: "clipboard-list",
|
|
loyalty: "star",
|
|
sitebuilder: "template",
|
|
default: "globe-alt",
|
|
};
|
|
return icons[code] || icons.default;
|
|
},
|
|
|
|
formatDate(dateString) {
|
|
if (!dateString) return "—";
|
|
const date = new Date(dateString);
|
|
return date.toLocaleDateString("fr-LU", {
|
|
year: "numeric",
|
|
month: "short",
|
|
day: "numeric",
|
|
});
|
|
},
|
|
};
|
|
}
|