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
|
class Admin::SettingsController < Admin::BaseController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
all_settings = Setting.all.group_by { |s| s.type }
|
all_settings = Setting.all.group_by { |setting| setting.type }
|
||||||
@settings = all_settings["common"]
|
@configuration_settings = all_settings["configuration"]
|
||||||
@feature_flags = all_settings["feature"]
|
@feature_settings = all_settings["feature"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
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>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -9,18 +7,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @feature_flags.each do |feature_flag| %>
|
<% features.each do |feature| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="small-8">
|
<td class="small-8">
|
||||||
<strong><%= t("settings.#{feature_flag.key}") %></strong>
|
<strong><%= t("settings.#{feature.key}") %></strong>
|
||||||
<br>
|
<br>
|
||||||
<span class="small">
|
<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>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<% if feature_flag.enabled? %>
|
<% if feature.enabled? %>
|
||||||
<span class="enabled">
|
<span class="enabled">
|
||||||
<strong>
|
<strong>
|
||||||
<%= t ("admin.settings.index.features.enabled") %>
|
<%= t ("admin.settings.index.features.enabled") %>
|
||||||
@@ -34,11 +32,11 @@
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="text-right">
|
<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.hidden_field :value, id: dom_id(feature), value: (feature.enabled? ? "" : "active") %>
|
||||||
<%= f.submit(t("admin.settings.index.features.#{feature_flag.enabled? ? 'disable' : 'enable'}"),
|
<%= f.submit(t("admin.settings.index.features.#{feature.enabled? ? 'disable' : 'enable'}"),
|
||||||
class: "button expanded #{feature_flag.enabled? ? 'hollow alert' : 'success'}",
|
class: "button expanded #{feature.enabled? ? 'hollow alert' : 'success'}",
|
||||||
data: {confirm: t("admin.actions.confirm")}) %>
|
data: {confirm: t("admin.actions.confirm")}) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</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>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -8,7 +6,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @settings.each do |setting| %>
|
<% settings.each do |setting| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="small-6">
|
<td class="small-6">
|
||||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||||
@@ -3,14 +3,14 @@
|
|||||||
<%= render "filter_subnav" %>
|
<%= render "filter_subnav" %>
|
||||||
|
|
||||||
<div class="tabs-panel is-active" id="tab-configuration">
|
<div class="tabs-panel is-active" id="tab-configuration">
|
||||||
<%= render "configuration" %>
|
<%= render "configuration_settings_tab" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tabs-panel" id="tab-feature-flags">
|
<div class="tabs-panel" id="tab-feature-flags">
|
||||||
<%= render "feature_flags" %>
|
<%= render "features_tab" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tabs-panel" id="tab-map-configuration">
|
<div class="tabs-panel" id="tab-map-configuration">
|
||||||
<%= render "map_configuration" %>
|
<%= render "map_configuration_tab" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user