Add new param to partial '_setting_table'

When we reuse the partial '_setting_table' to render the 3 types
of remote census settings, we need customize setting_name key by
default to clarify the information to render.

- Add new param 'setting_name' to partial '_setting_table'
- Create new setting helper method to use new setting_name param
  to display a more clarify setting name on table.
This commit is contained in:
taitus
2019-04-10 14:26:38 +02:00
committed by Javi Martín
parent 0a901cb82f
commit 12b6b1df05
7 changed files with 31 additions and 5 deletions

View File

@@ -8,4 +8,12 @@ module SettingsHelper
@all_settings ||= Hash[ Setting.all.map{|s| [s.key, s.value.presence]} ]
end
def display_setting_name(setting_name)
if setting_name == "setting"
t("admin.settings.setting_name")
else
t("admin.settings.#{setting_name}")
end
end
end

View File

@@ -1,9 +1,9 @@
<% if feature?(:remote_census) %>
<h2><%= t("admin.settings.index.remote_census.title") %></h2>
<%= render "settings_table", settings: @remote_census_general_settings %>
<%= render "settings_table", settings: @remote_census_request_settings %>
<%= render "settings_table", settings: @remote_census_response_settings %>
<%= render "settings_table", settings: @remote_census_general_settings, setting_name: "remote_census_general_name" %>
<%= render "settings_table", settings: @remote_census_request_settings, setting_name: "remote_census_request_name" %>
<%= render "settings_table", settings: @remote_census_response_settings, setting_name: "remote_census_response_name" %>
<% else %>
<div class="callout primary">
<%= t("admin.settings.index.remote_census.how_to_enable") %>

View File

@@ -1,7 +1,7 @@
<table>
<thead>
<tr>
<th><%= t("admin.settings.setting_name") %></th>
<th><%= display_setting_name(setting_name) %></th>
<th><%= t("admin.settings.setting_value") %></th>
</tr>
</thead>

View File

@@ -1314,6 +1314,9 @@ en:
remote_census:
title: Remote Census configuration
how_to_enable: 'To configure remote census (SOAP) you must enable "Configure connection to remote census (SOAP)" on "Features" tab.'
remote_census_general_name: General Information
remote_census_request_name: Request Data
remote_census_response_name: Response Data
setting: Feature
setting_actions: Actions
setting_name: Setting

View File

@@ -1315,6 +1315,9 @@ es:
remote_census:
title: Configuración del Censo Remoto
how_to_enable: 'Para configurar la conexión con el Censo Remoto (SOAP) se debe activar "Configurar la conexión al censo remoto (SOAP)" en la pestaña "Funcionalidades".'
remote_census_general_name: Datos Generales
remote_census_request_name: Datos Petición
remote_census_response_name: Datos Respuesta
setting: Funcionalidad
setting_actions: Acciones
setting_name: Configuración

View File

@@ -153,6 +153,9 @@ describe "Admin settings" do
visit admin_settings_path
find("#remote-census-tab").click
expect(page).to have_content("General Information")
expect(page).to have_content("Request Data")
expect(page).to have_content("Response Data")
expect(page).not_to have_content 'To configure remote census (SOAP) you must enable ' \
'"Configure connection to remote census (SOAP)" ' \
'on "Features" tab.'

View File

@@ -28,4 +28,13 @@ RSpec.describe SettingsHelper, type: :helper do
end
end
describe "#display_setting_name" do
it "returns correct setting_name" do
expect(display_setting_name("setting")).to eq("Setting")
expect(display_setting_name("remote_census_general_name")).to eq("General Information")
expect(display_setting_name("remote_census_request_name")).to eq("Request Data")
expect(display_setting_name("remote_census_response_name")).to eq("Response Data")
end
end
end