mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 05:25:16 -05:00
FEATURE: Ability to add components to all themes (#8404)
* FEATURE: Ability to add components to all themes This is the first and functional step from that topic https://dev.discourse.org/t/adding-a-theme-component-is-too-much-work/15398/16 The idea here is that when a new component is added, the user can easily assign it to all themes (parents). To achieve that, I needed to change a site-setting component to accept `setDefaultValues` action and `setDefaultValuesLabel` translated label. Also, I needed to add `allowAny` option to disable that for theme selector. I also refactored backend to accept both parent and child ids with one method to avoid duplication (Renamed `add_child_theme!` to more general `add_relative_theme!`) * FIX: Improvement after code review * FIX: Improvement after code review2 * FIX: use mapBy and filterBy directly
This commit is contained in:
+7
-2
@@ -376,10 +376,15 @@ class Theme < ActiveRecord::Base
|
||||
fields.values
|
||||
end
|
||||
|
||||
def add_child_theme!(theme)
|
||||
new_relation = child_theme_relation.new(child_theme_id: theme.id)
|
||||
def add_relative_theme!(kind, theme)
|
||||
new_relation = if kind == :child
|
||||
child_theme_relation.new(child_theme_id: theme.id)
|
||||
else
|
||||
parent_theme_relation.new(parent_theme_id: theme.id)
|
||||
end
|
||||
if new_relation.save
|
||||
child_themes.reload
|
||||
parent_themes.reload
|
||||
save!
|
||||
Theme.clear_cache!
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user