Files
grecia/app/components/admin/settings/table_component.rb
Senén Rodero Rodríguez f8835debae Move logic from key definition to views
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.
2024-01-25 18:29:38 +01:00

27 lines
637 B
Ruby

class Admin::Settings::TableComponent < ApplicationComponent
attr_reader :setting_name, :table_class
def initialize(setting_name:, table_class: "mixed-settings-table")
@setting_name = setting_name
@table_class = table_class
end
def key_header
if setting_name == "feature"
t("admin.settings.setting")
elsif setting_name == "setting"
t("admin.settings.setting_name")
else
t("admin.settings.#{setting_name}")
end
end
def value_header
if setting_name == "feature"
t("admin.settings.index.features.enabled")
else
t("admin.settings.setting_value")
end
end
end