feat: validate and store the size choice in redmine_tonalmine (T6)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 09:17:23 +02:00
co-authored by Claude Opus 5.5
parent 7ef21c739a
commit 94a9bd066e
@@ -1,12 +1,13 @@
module RedmineTonalmine
# Validates appearance hashes ({mode, contrast, palette, seed, css}) coming from users and from
# Validates appearance hashes ({mode, contrast, size, palette, seed, css}) coming from users and from
# the Display settings form. Any part may be missing: it then falls back to the default.
module Appearance
MODES = %w[auto light dark].freeze
CONTRASTS = %w[standard medium high].freeze
SIZES = %w[compact normal large].freeze
# Ids must match PALETTES in tonalmine/javascripts/theme.js (tools/palettes checks this).
PALETTES = %w[purple blue green orange].freeze
KEYS = %w[mode contrast palette seed css].freeze
KEYS = %w[mode contrast size palette seed css].freeze
MAX_CSS = 32.kilobytes
module_function
@@ -21,6 +22,7 @@ module RedmineTonalmine
end
errors << 'invalid mode' if prefs['mode'] && !MODES.include?(prefs['mode'])
errors << 'invalid contrast' if prefs['contrast'] && !CONTRASTS.include?(prefs['contrast'])
errors << 'invalid size' if prefs['size'] && !SIZES.include?(prefs['size'])
errors.concat(custom_errors(prefs))
errors
end
@@ -30,6 +32,7 @@ module RedmineTonalmine
prefs = normalize(hash)
prefs.delete('mode') unless MODES.include?(prefs['mode'])
prefs.delete('contrast') unless CONTRASTS.include?(prefs['contrast'])
prefs.delete('size') unless SIZES.include?(prefs['size'])
prefs = prefs.except('palette', 'seed', 'css') if custom_errors(prefs).any?
prefs.compact
end