From 37eaafe78879fe1c7ebac309d6fc9c49e22f8a05 Mon Sep 17 00:00:00 2001 From: Chuck Date: Thu, 8 Jan 2026 15:18:19 -0500 Subject: [PATCH] fix: Fix checkbox-group serialization and array-of-objects key leakage Multiple fixes for array-of-objects and checkbox-group widgets: 1. Fix checkbox-group serialization (JS and template): - Changed from indexed names (categories.0, categories.1) to _data pattern - Added updateCheckboxGroupData() function to sync selected values - Hidden input stores JSON array of selected enum values - Checkboxes use data-checkbox-group and data-option-value attributes - Fixes issue where config.categories became {0: true, 1: true} instead of ['nfl', 'nba'] - Now correctly serializes to array using existing _data handling logic 2. Prevent array-of-objects per-item key leakage: - Added skip pattern in handlePluginConfigSubmit for _item__ names - Removed name attributes from per-item inputs in renderArrayObjectItem - Per-item inputs now rely solely on hidden _data field - Prevents feeds_item_0_name from leaking into flatConfig 3. Add type coercion to updateArrayObjectData: - Consults itemsSchema.properties[propKey].type for coercion - Handles integer and number types correctly - Preserves string values as-is - Ensures numeric fields in array items are stored as numbers 4. Ensure currentPluginConfig is always available: - Updated addArrayObjectItem to check window.currentPluginConfig first - Added error logging if schema not available - Prevents ReferenceError when global helpers need schema This ensures checkbox-group arrays serialize correctly and array-of-objects per-item fields don't leak extra keys into the configuration. --- plugins/basketball-scoreboard | 2 +- web_interface/static/v3/plugins_manager.js | 84 +++++++++++++++++-- .../templates/v3/partials/plugin_config.html | 6 +- 3 files changed, 81 insertions(+), 11 deletions(-) diff --git a/plugins/basketball-scoreboard b/plugins/basketball-scoreboard index f593b3bc..a250ebe8 160000 --- a/plugins/basketball-scoreboard +++ b/plugins/basketball-scoreboard @@ -1 +1 @@ -Subproject commit f593b3bc39a4754ae72a8716518c5bccbf89c931 +Subproject commit a250ebe8f1858b3350c13101b5d949838aa0e19a diff --git a/web_interface/static/v3/plugins_manager.js b/web_interface/static/v3/plugins_manager.js index 370fab28..0b5d4bb5 100644 --- a/web_interface/static/v3/plugins_manager.js +++ b/web_interface/static/v3/plugins_manager.js @@ -2243,6 +2243,12 @@ function handlePluginConfigSubmit(e) { continue; } + // Skip array-of-objects per-item inputs (they're handled by the hidden _data input) + // Pattern: feeds_item_0_name, feeds_item_1_url, etc. + if (key.includes('_item_') && /_item_\d+_/.test(key)) { + continue; + } + // Try to get schema property - handle both dot notation and underscore notation let propSchema = getSchemaPropertyType(schema, key); let actualKey = key; @@ -2529,7 +2535,6 @@ function renderArrayObjectItem(fieldId, fullKey, itemProperties, itemValue, inde