fix: Expose getSchemaProperty, disable upload widget, handle bracket notation arrays

Multiple fixes for array-of-objects and form processing:

1. Expose getSchemaProperty to window (plugins_manager.js):
   - getSchemaProperty was defined inside IIFE but needed by global functions
   - Added window.getSchemaProperty = getSchemaProperty before IIFE closes
   - Updated window.addArrayObjectItem to use window.getSchemaProperty
   - Fixes ReferenceError when dynamically adding array items

2. Disable upload widget for custom feeds (plugin_config.html):
   - File input and Upload button were still active but should be disabled
   - Removed onchange/onclick handlers, added disabled and aria-disabled
   - Added visible disabled styling and tooltip
   - Existing logos continue to display but uploads are prevented
   - Matches PR objectives to disable upload until fully implemented

3. Handle bracket notation array fields (api_v3.py):
   - checkbox-group uses name="field_name[]" which sends multiple values
   - request.form.to_dict() collapses duplicate keys (only keeps last value)
   - Added handling to detect fields ending with "[]" before to_dict()
   - Use request.form.getlist() to get all values, combine as comma-separated
   - Processed before existing array index field handling
   - Fixes checkbox-group losing all but last selected value
This commit is contained in:
Chuck
2026-01-08 13:45:23 -05:00
parent 8c2e3500bf
commit deef9a1e1e
3 changed files with 36 additions and 6 deletions

View File

@@ -6467,8 +6467,9 @@ window.updateImageScheduleDay = function(fieldId, imageId, imageIdx, day) {
window.updateImageList(fieldId, currentImages);
}
// Expose renderArrayObjectItem to window for use by window.addArrayObjectItem
// Expose renderArrayObjectItem and getSchemaProperty to window for use by global functions
window.renderArrayObjectItem = renderArrayObjectItem;
window.getSchemaProperty = getSchemaProperty;
})(); // End IIFE
@@ -6491,7 +6492,7 @@ if (typeof window !== 'undefined') {
if (!schema) return;
// Use getSchemaProperty to properly handle nested schemas (e.g., news.custom_feeds)
const arraySchema = getSchemaProperty(schema, fullKey);
const arraySchema = window.getSchemaProperty(schema, fullKey);
if (!arraySchema || arraySchema.type !== 'array' || !arraySchema.items) {
return;
}