Before this change, two important things depend on the format of each key, where to render it in the administration panel and which kind of interface to use for each setting. Following this strategy led us to a very complex code, very difficult to maintain or modify. So, we do not want to depend on the setting key structure anymore to decide how or where to render each setting. With this commit, we get rid of the key format-based rules. Now we render each setting explicitly passing to it the type and the tab where it belongs.
23 lines
405 B
Ruby
23 lines
405 B
Ruby
class Admin::Settings::RowComponent < ApplicationComponent
|
|
attr_reader :key, :tab, :type
|
|
delegate :dom_id, to: :helpers
|
|
|
|
def initialize(key, type: :text, tab: nil)
|
|
@key = key
|
|
@type = type
|
|
@tab = tab
|
|
end
|
|
|
|
def setting
|
|
@setting ||= Setting.find_by!(key: key)
|
|
end
|
|
|
|
def content_type_setting?
|
|
type == :content_type
|
|
end
|
|
|
|
def featured_setting?
|
|
type == :feature
|
|
end
|
|
end
|