Refactor Admin settings tabs
- Rename partial views for tabs. - Extract tables settings to reuse across the tabs.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
class Admin::SettingsController < Admin::BaseController
|
||||
|
||||
def index
|
||||
all_settings = Setting.all.group_by { |s| s.type }
|
||||
@settings = all_settings["common"]
|
||||
@feature_flags = all_settings["feature"]
|
||||
all_settings = Setting.all.group_by { |setting| setting.type }
|
||||
@configuration_settings = all_settings["configuration"]
|
||||
@feature_settings = all_settings["feature"]
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<h2><%= t("admin.settings.index.title") %></h2>
|
||||
|
||||
<%= render "settings_table", settings: @configuration_settings %>
|
||||
@@ -1,5 +1,3 @@
|
||||
<h2><%= t("admin.settings.index.feature_flags") %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -9,18 +7,18 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @feature_flags.each do |feature_flag| %>
|
||||
<% features.each do |feature| %>
|
||||
<tr>
|
||||
<td class="small-8">
|
||||
<strong><%= t("settings.#{feature_flag.key}") %></strong>
|
||||
<strong><%= t("settings.#{feature.key}") %></strong>
|
||||
<br>
|
||||
<span class="small">
|
||||
<%= t("settings.#{feature_flag.key}_description", default: t("admin.settings.no_description")) %>
|
||||
<%= t("settings.#{feature.key}_description", default: t("admin.settings.no_description")) %>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<% if feature_flag.enabled? %>
|
||||
<% if feature.enabled? %>
|
||||
<span class="enabled">
|
||||
<strong>
|
||||
<%= t ("admin.settings.index.features.enabled") %>
|
||||
@@ -34,11 +32,11 @@
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
<%= form_for(feature_flag, url: admin_setting_path(feature_flag), html: { id: "edit_#{dom_id(feature_flag)}"}) do |f| %>
|
||||
<%= form_for(feature, url: admin_setting_path(feature), html: { id: "edit_#{dom_id(feature)}"}) do |f| %>
|
||||
|
||||
<%= f.hidden_field :value, id: dom_id(feature_flag), value: (feature_flag.enabled? ? "" : "active") %>
|
||||
<%= f.submit(t("admin.settings.index.features.#{feature_flag.enabled? ? 'disable' : 'enable'}"),
|
||||
class: "button expanded #{feature_flag.enabled? ? 'hollow alert' : 'success'}",
|
||||
<%= f.hidden_field :value, id: dom_id(feature), value: (feature.enabled? ? "" : "active") %>
|
||||
<%= f.submit(t("admin.settings.index.features.#{feature.enabled? ? 'disable' : 'enable'}"),
|
||||
class: "button expanded #{feature.enabled? ? 'hollow alert' : 'success'}",
|
||||
data: {confirm: t("admin.actions.confirm")}) %>
|
||||
<% end %>
|
||||
</td>
|
||||
3
app/views/admin/settings/_features_tab.html.erb
Normal file
3
app/views/admin/settings/_features_tab.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<h2><%= t("admin.settings.index.feature_flags") %></h2>
|
||||
|
||||
<%= render "featured_settings_table", features: @feature_settings %>
|
||||
@@ -1,5 +1,3 @@
|
||||
<h2><%= t("admin.settings.index.title") %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -8,7 +6,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @settings.each do |setting| %>
|
||||
<% settings.each do |setting| %>
|
||||
<tr>
|
||||
<td class="small-6">
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
@@ -3,14 +3,14 @@
|
||||
<%= render "filter_subnav" %>
|
||||
|
||||
<div class="tabs-panel is-active" id="tab-configuration">
|
||||
<%= render "configuration" %>
|
||||
<%= render "configuration_settings_tab" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-feature-flags">
|
||||
<%= render "feature_flags" %>
|
||||
<%= render "features_tab" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-map-configuration">
|
||||
<%= render "map_configuration" %>
|
||||
<%= render "map_configuration_tab" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user