Merge pull request #2650 from aamarill/2586-split_admin_settings
Split admin settings
This commit is contained in:
@@ -212,5 +212,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="section-title <%= "active" if controller_name == "settings" %>">
|
||||
<%= link_to admin_settings_path do %>
|
||||
<span class="icon-settings"></span>
|
||||
<strong><%= t("admin.settings.index.title") %></strong>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
24
app/views/admin/settings/_banner_images.html.erb
Normal file
24
app/views/admin/settings/_banner_images.html.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
<% if @banner_imgs.present?%>
|
||||
<h2><%= t("admin.settings.index.banner_imgs") %></h2>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% @banner_imgs.each do |setting| %>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button small success") %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<h3><%= t("admin.settings.index.no_banners_images") %></h3>
|
||||
<% end %>
|
||||
24
app/views/admin/settings/_banner_styles.html.erb
Normal file
24
app/views/admin/settings/_banner_styles.html.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
<% if @banner_styles.present? %>
|
||||
<h2><%= t("admin.settings.index.banners") %></h2>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% @banner_styles.each do |setting| %>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow") %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<h3><%= t("admin.settings.index.no_banners_styles") %></h3>
|
||||
<% end %>
|
||||
23
app/views/admin/settings/_configuration.html.erb
Normal file
23
app/views/admin/settings/_configuration.html.erb
Normal file
@@ -0,0 +1,23 @@
|
||||
<h2><%= t("admin.settings.index.title") %></h2>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% @settings.each do |setting| %>
|
||||
<tr>
|
||||
<td class="small-12 medium-4">
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
</td>
|
||||
<td class="small-12 medium-8">
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<div class="small-12 medium-6 large-9 column">
|
||||
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 large-3 column">
|
||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
27
app/views/admin/settings/_feature_flags.html.erb
Normal file
27
app/views/admin/settings/_feature_flags.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<h2><%= t("admin.settings.index.feature_flags") %></h2>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% @feature_flags.each do |feature_flag| %>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t("settings.#{feature_flag.key}") %></strong>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<%= feature_flag.enabled? ? t("admin.settings.index.features.enabled") : t("admin.settings.index.features.disabled") %>
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
<%= form_for(feature_flag, url: admin_setting_path(feature_flag), html: { id: "edit_#{dom_id(feature_flag)}"}) 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'}",
|
||||
data: {confirm: t("admin.actions.confirm")}) %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
31
app/views/admin/settings/_filter_subnav.html.erb
Normal file
31
app/views/admin/settings/_filter_subnav.html.erb
Normal file
@@ -0,0 +1,31 @@
|
||||
<ul class="tabs" data-tabs id="settings-tabs">
|
||||
<li class="tabs-title is-active">
|
||||
<%= link_to "#tab-configuration" do %>
|
||||
<%= t("admin.settings.index.title") %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li class="tabs-title" id="features-tab">
|
||||
<%= link_to "#tab-feature-flags" do %>
|
||||
<%= t("admin.settings.index.feature_flags") %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-banner-styles" do %>
|
||||
<%= t("admin.settings.index.banners") %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-banner-images" do %>
|
||||
<%= t("admin.settings.index.banner_imgs") %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li class="tabs-title" id="map-tab">
|
||||
<%= link_to "#tab-map-configuration" do %>
|
||||
<%= t("admin.settings.index.map.title") %>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
8
app/views/admin/settings/_map_configuration.html.erb
Normal file
8
app/views/admin/settings/_map_configuration.html.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<% if feature?(:map) %>
|
||||
<h2><%= t("admin.settings.index.map.title") %></h2>
|
||||
<p><%= t("admin.settings.index.map.help") %></p>
|
||||
|
||||
<%= render "map_form" %>
|
||||
<% else %>
|
||||
<h3>No map to show.</h3>
|
||||
<% end %>
|
||||
@@ -1,105 +1,24 @@
|
||||
<h2><%= t("admin.settings.index.title") %></h2>
|
||||
<h1>Settings</h1>
|
||||
<div class="tabs-content" data-tabs-content="settings-tabs">
|
||||
<%= render "filter_subnav" %>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% @settings.each do |setting| %>
|
||||
<tr>
|
||||
<td class="small-12 medium-4">
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
</td>
|
||||
<td class="small-12 medium-8">
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<div class="small-12 medium-6 large-9 column">
|
||||
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 large-3 column">
|
||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="tabs-panel is-active" id="tab-configuration">
|
||||
<%= render "configuration" %>
|
||||
</div>
|
||||
|
||||
<h2><%= t("admin.settings.index.feature_flags") %></h2>
|
||||
<div class="tabs-panel" id="tab-feature-flags">
|
||||
<%= render "feature_flags" %>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% @feature_flags.each do |feature_flag| %>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t("settings.#{feature_flag.key}") %></strong>
|
||||
</td>
|
||||
<div class="tabs-panel" id="tab-banner-styles">
|
||||
<%= render "banner_styles" %>
|
||||
</div>
|
||||
|
||||
<td>
|
||||
<%= feature_flag.enabled? ? t("admin.settings.index.features.enabled") : t("admin.settings.index.features.disabled") %>
|
||||
</td>
|
||||
<div class="tabs-panel" id="tab-banner-images">
|
||||
<%= render "banner_images" %>
|
||||
</div>
|
||||
|
||||
<td class="text-right">
|
||||
<%= form_for(feature_flag, url: admin_setting_path(feature_flag), html: { id: "edit_#{dom_id(feature_flag)}"}) 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'}",
|
||||
data: {confirm: t("admin.actions.confirm")}) %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% if @banner_styles.present? %>
|
||||
<h2><%= t("admin.settings.index.banners") %></h2>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% @banner_styles.each do |setting| %>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow") %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% if @banner_imgs.present?%>
|
||||
<h2><%= t("admin.settings.index.banner_imgs") %></h2>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% @banner_imgs.each do |setting| %>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<%= form_for(setting, url: admin_setting_path(setting), html: { id: "edit_#{dom_id(setting)}"}) do |f| %>
|
||||
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
|
||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button small success") %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:map) %>
|
||||
<h2><%= t("admin.settings.index.map.title") %></h2>
|
||||
<p><%= t("admin.settings.index.map.help") %></p>
|
||||
|
||||
<%= render "map_form" %>
|
||||
|
||||
<% end %>
|
||||
<div class="tabs-panel" id="tab-map-configuration">
|
||||
<%= render "map_configuration" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -921,6 +921,8 @@ en:
|
||||
index:
|
||||
banners: Banner styles
|
||||
banner_imgs: Banner images
|
||||
no_banners_images: No banner images
|
||||
no_banners_styles: No banner styles
|
||||
title: Configuration settings
|
||||
update_setting: Update
|
||||
feature_flags: Features
|
||||
|
||||
@@ -919,8 +919,10 @@ es:
|
||||
flash:
|
||||
updated: Valor actualizado
|
||||
index:
|
||||
banners: Banner style
|
||||
banner_imgs: Banner images
|
||||
banners: Estilo del banner
|
||||
banner_imgs: Imagenes del banner
|
||||
no_banners_images: No hay imagenes de banner
|
||||
no_banners_styles: No hay estilos de banner
|
||||
title: Configuración global
|
||||
update_setting: Actualizar
|
||||
feature_flags: Funcionalidades
|
||||
|
||||
@@ -35,8 +35,9 @@ feature 'Admin settings' do
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
find("#map-tab").click
|
||||
|
||||
expect(page).not_to have_content "Map configuration"
|
||||
expect(page).not_to have_css("#admin-map")
|
||||
end
|
||||
|
||||
scenario "Should be able when map feature activated" do
|
||||
@@ -44,8 +45,9 @@ feature 'Admin settings' do
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
find("#map-tab").click
|
||||
|
||||
expect(page).to have_content "Map configuration"
|
||||
expect(page).to have_css("#admin-map")
|
||||
end
|
||||
|
||||
scenario "Should show successful notice" do
|
||||
@@ -78,6 +80,7 @@ feature 'Admin settings' do
|
||||
login_as(admin)
|
||||
|
||||
visit admin_settings_path
|
||||
find("#map-tab").click
|
||||
find("#admin-map").click
|
||||
within "#map-form" do
|
||||
click_on "Update"
|
||||
@@ -96,6 +99,7 @@ feature 'Admin settings' do
|
||||
setting = Setting.where(key: "feature.user.skip_verification").first
|
||||
|
||||
visit admin_settings_path
|
||||
find("#features-tab").click
|
||||
|
||||
accept_alert do
|
||||
find("#edit_setting_#{setting.id} .button").click
|
||||
@@ -109,6 +113,7 @@ feature 'Admin settings' do
|
||||
setting = Setting.where(key: "feature.user.skip_verification").first
|
||||
|
||||
visit admin_settings_path
|
||||
find("#features-tab").click
|
||||
|
||||
accept_alert do
|
||||
find("#edit_setting_#{setting.id} .button").click
|
||||
@@ -121,4 +126,4 @@ feature 'Admin settings' do
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user