fix: Expose renderArrayObjectItem to window for addArrayObjectItem

Fix scope issue where renderArrayObjectItem is defined inside IIFE but
window.addArrayObjectItem is defined outside, causing the function check
to always fail and fallback to degraded HTML rendering.

Problem:
- renderArrayObjectItem (line 2469) is inside IIFE (lines 796-6417)
- window.addArrayObjectItem (line 6422) is outside IIFE
- Check 'typeof renderArrayObjectItem === function' at line 6454 always fails
- Fallback code lacks file upload widgets, URL input types, descriptions, styling

Solution:
- Expose renderArrayObjectItem to window object before IIFE closes
- Function maintains closure access to escapeHtml and other IIFE-scoped functions
- Newly added items now have full functionality matching initially rendered items
This commit is contained in:
Chuck
2026-01-08 13:31:34 -05:00
parent 89f9876c92
commit 520b87a198

View File

@@ -6414,6 +6414,9 @@ window.updateImageScheduleDay = function(fieldId, imageId, imageIdx, day) {
window.updateImageList(fieldId, currentImages);
}
// Expose renderArrayObjectItem to window for use by window.addArrayObjectItem
window.renderArrayObjectItem = renderArrayObjectItem;
})(); // End IIFE
// Functions to handle array-of-objects
@@ -6446,8 +6449,8 @@ if (typeof window !== 'undefined') {
const newIndex = currentItems.length;
// Use renderArrayObjectItem if available, otherwise create basic HTML
let itemHtml = '';
if (typeof renderArrayObjectItem === 'function') {
itemHtml = renderArrayObjectItem(fieldId, fullKey, itemsSchema.properties, {}, newIndex, itemsSchema);
if (typeof window.renderArrayObjectItem === 'function') {
itemHtml = window.renderArrayObjectItem(fieldId, fullKey, itemsSchema.properties, {}, newIndex, itemsSchema);
} else {
// Fallback: create basic HTML structure
itemHtml = `<div class="border border-gray-300 rounded-lg p-4 bg-gray-50 array-object-item" data-index="${newIndex}">`;