Merge pull request #2650 from aamarill/2586-split_admin_settings
Split admin settings
This commit is contained in:
@@ -212,5 +212,12 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</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>
|
</ul>
|
||||||
</div>
|
</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>
|
<div class="tabs-panel is-active" id="tab-configuration">
|
||||||
<tbody>
|
<%= render "configuration" %>
|
||||||
<% @settings.each do |setting| %>
|
</div>
|
||||||
<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>
|
|
||||||
|
|
||||||
<h2><%= t("admin.settings.index.feature_flags") %></h2>
|
<div class="tabs-panel" id="tab-feature-flags">
|
||||||
|
<%= render "feature_flags" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table>
|
<div class="tabs-panel" id="tab-banner-styles">
|
||||||
<tbody>
|
<%= render "banner_styles" %>
|
||||||
<% @feature_flags.each do |feature_flag| %>
|
</div>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<strong><%= t("settings.#{feature_flag.key}") %></strong>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
<div class="tabs-panel" id="tab-banner-images">
|
||||||
<%= feature_flag.enabled? ? t("admin.settings.index.features.enabled") : t("admin.settings.index.features.disabled") %>
|
<%= render "banner_images" %>
|
||||||
</td>
|
</div>
|
||||||
|
|
||||||
<td class="text-right">
|
<div class="tabs-panel" id="tab-map-configuration">
|
||||||
<%= form_for(feature_flag, url: admin_setting_path(feature_flag), html: { id: "edit_#{dom_id(feature_flag)}"}) do |f| %>
|
<%= render "map_configuration" %>
|
||||||
|
</div>
|
||||||
<%= f.hidden_field :value, id: dom_id(feature_flag), value: (feature_flag.enabled? ? "" : "active") %>
|
</div>
|
||||||
<%= 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 %>
|
|
||||||
|
|||||||
@@ -921,6 +921,8 @@ en:
|
|||||||
index:
|
index:
|
||||||
banners: Banner styles
|
banners: Banner styles
|
||||||
banner_imgs: Banner images
|
banner_imgs: Banner images
|
||||||
|
no_banners_images: No banner images
|
||||||
|
no_banners_styles: No banner styles
|
||||||
title: Configuration settings
|
title: Configuration settings
|
||||||
update_setting: Update
|
update_setting: Update
|
||||||
feature_flags: Features
|
feature_flags: Features
|
||||||
|
|||||||
@@ -919,8 +919,10 @@ es:
|
|||||||
flash:
|
flash:
|
||||||
updated: Valor actualizado
|
updated: Valor actualizado
|
||||||
index:
|
index:
|
||||||
banners: Banner style
|
banners: Estilo del banner
|
||||||
banner_imgs: Banner images
|
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
|
title: Configuración global
|
||||||
update_setting: Actualizar
|
update_setting: Actualizar
|
||||||
feature_flags: Funcionalidades
|
feature_flags: Funcionalidades
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ feature 'Admin settings' do
|
|||||||
admin = create(:administrator).user
|
admin = create(:administrator).user
|
||||||
login_as(admin)
|
login_as(admin)
|
||||||
visit admin_settings_path
|
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
|
end
|
||||||
|
|
||||||
scenario "Should be able when map feature activated" do
|
scenario "Should be able when map feature activated" do
|
||||||
@@ -44,8 +45,9 @@ feature 'Admin settings' do
|
|||||||
admin = create(:administrator).user
|
admin = create(:administrator).user
|
||||||
login_as(admin)
|
login_as(admin)
|
||||||
visit admin_settings_path
|
visit admin_settings_path
|
||||||
|
find("#map-tab").click
|
||||||
|
|
||||||
expect(page).to have_content "Map configuration"
|
expect(page).to have_css("#admin-map")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Should show successful notice" do
|
scenario "Should show successful notice" do
|
||||||
@@ -78,6 +80,7 @@ feature 'Admin settings' do
|
|||||||
login_as(admin)
|
login_as(admin)
|
||||||
|
|
||||||
visit admin_settings_path
|
visit admin_settings_path
|
||||||
|
find("#map-tab").click
|
||||||
find("#admin-map").click
|
find("#admin-map").click
|
||||||
within "#map-form" do
|
within "#map-form" do
|
||||||
click_on "Update"
|
click_on "Update"
|
||||||
@@ -96,6 +99,7 @@ feature 'Admin settings' do
|
|||||||
setting = Setting.where(key: "feature.user.skip_verification").first
|
setting = Setting.where(key: "feature.user.skip_verification").first
|
||||||
|
|
||||||
visit admin_settings_path
|
visit admin_settings_path
|
||||||
|
find("#features-tab").click
|
||||||
|
|
||||||
accept_alert do
|
accept_alert do
|
||||||
find("#edit_setting_#{setting.id} .button").click
|
find("#edit_setting_#{setting.id} .button").click
|
||||||
@@ -109,6 +113,7 @@ feature 'Admin settings' do
|
|||||||
setting = Setting.where(key: "feature.user.skip_verification").first
|
setting = Setting.where(key: "feature.user.skip_verification").first
|
||||||
|
|
||||||
visit admin_settings_path
|
visit admin_settings_path
|
||||||
|
find("#features-tab").click
|
||||||
|
|
||||||
accept_alert do
|
accept_alert do
|
||||||
find("#edit_setting_#{setting.id} .button").click
|
find("#edit_setting_#{setting.id} .button").click
|
||||||
@@ -121,4 +126,4 @@ feature 'Admin settings' do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user