fix(options): guard JSON.parse of optionCssFiles so the options page works at global level
On the GLOBAL theme options page the hidden #optionCssFiles holds the
literal string "inherit" (not JSON). options.js did an unguarded
JSON.parse($('#optionCssFiles').val()) in the ThemeOptions constructor,
which threw and meant run() never executed: no change handlers and no
save handler were bound, so Save posted the stale options JSON and
nothing changed in the UI (e.g. colors on the Default fonts and colors
tab) was saved. Fall back to an empty file list on parse failure.
OPTIONS_JS_TOKEN bumped to 20261125.4.
Verified against the live page (themeOptions/update&id=497, where
optionCssFiles="inherit"): constructor no longer throws, picker
input/change handlers bind, and the save click writes the new color
into TemplateConfiguration[options]; real HTTP POST confirmed the
value lands in lime_template_configuration.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
588199086a
commit
44e0e871d4
2 changed files with 12 additions and 2 deletions
|
|
@ -19,7 +19,17 @@ var ThemeOptions = function () {
|
||||||
"general_inherit": 1
|
"general_inherit": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
var optionCssFiles = JSON.parse($('#optionCssFiles').val());
|
// THEME FIX: on the GLOBAL theme-options page the hidden #optionCssFiles can
|
||||||
|
// hold the literal string "inherit" (not JSON) — an unguarded JSON.parse then
|
||||||
|
// throws inside this constructor, so run() never executes: no change handlers
|
||||||
|
// and no save handler get bound, and Save silently posts the stale options
|
||||||
|
// JSON (nothing changed in the UI is saved). Fall back to an empty file list.
|
||||||
|
var optionCssFiles;
|
||||||
|
try {
|
||||||
|
optionCssFiles = JSON.parse($('#optionCssFiles').val());
|
||||||
|
} catch (e) {
|
||||||
|
optionCssFiles = { add: [], replace: [], remove: [] };
|
||||||
|
}
|
||||||
//get the global form
|
//get the global form
|
||||||
var globalForm = $('.action_update_options_string_form');
|
var globalForm = $('.action_update_options_string_form');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control).
|
heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control).
|
||||||
Re-register it with a version token: bump OPTIONS_JS_TOKEN below whenever
|
Re-register it with a version token: bump OPTIONS_JS_TOKEN below whenever
|
||||||
options/options.js changes, so every browser fetches the new file once. #}
|
options/options.js changes, so every browser fetches the new file once. #}
|
||||||
{% set OPTIONS_JS_TOKEN = '20261125.3' %}
|
{% set OPTIONS_JS_TOKEN = '20261125.4' %}
|
||||||
{{ unregisterScriptFile(optionsPath ~ '/options.js') }}
|
{{ unregisterScriptFile(optionsPath ~ '/options.js') }}
|
||||||
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
|
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue