mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 19:03:45 +08:00
8d4f405da4
Why this change? On the `/admin/customize/themes/<:id>` route, we allow admins to edit all settings via a settings editor. Prior to this change, trying to edit and save a typed objects theme settings will result in an error on the server.
20 lines
494 B
Ruby
20 lines
494 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ThemeSettingsManager::Objects < ThemeSettingsManager
|
|
def value
|
|
has_record? ? db_record.json_value : default.map!(&:deep_stringify_keys)
|
|
end
|
|
|
|
def value=(objects)
|
|
objects = JSON.parse(objects) if objects.is_a?(::String)
|
|
ensure_is_valid_value!(objects)
|
|
record = has_record? ? update_record!(json_value: objects) : create_record!(json_value: objects)
|
|
theme.reload
|
|
record.json_value
|
|
end
|
|
|
|
def schema
|
|
@opts[:schema]
|
|
end
|
|
end
|