Add content to the Remote Census Configuration tab
- Render remote census configuration content on settings index. - Update type method from Setting On Admin::SettingsController#index we are using 'all_settings' to group all settings by 'type' method. 'type' method return the first part of key when split by '.' To allow use by example: all_settings["remote_census.general"] and recover only settings related with this key we have added new 'elsif' on 'type' method.
This commit is contained in:
@@ -14,6 +14,9 @@ class Admin::SettingsController < Admin::BaseController
|
||||
@participation_processes_settings = all_settings["process"]
|
||||
@map_configuration_settings = all_settings["map"]
|
||||
@proposals_settings = all_settings["proposals"]
|
||||
@remote_census_general_settings = all_settings["remote_census.general"]
|
||||
@remote_census_request_settings = all_settings["remote_census.request"]
|
||||
@remote_census_response_settings = all_settings["remote_census.response"]
|
||||
@uploads_settings = all_settings["uploads"]
|
||||
end
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ class Setting < ApplicationRecord
|
||||
def type
|
||||
if %w[feature process proposals map html homepage uploads].include? prefix
|
||||
prefix
|
||||
elsif %w[remote_census].include? prefix
|
||||
key.rpartition(".").first
|
||||
else
|
||||
"configuration"
|
||||
end
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<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 %>
|
||||
@@ -25,4 +25,8 @@
|
||||
<div class="tabs-panel" id="tab-proposals">
|
||||
<%= render "proposals_dashboard" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-remote-census-configuration">
|
||||
<%= render "remote_census_configuration_tab" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -53,6 +53,21 @@ describe Setting do
|
||||
expect(homepage_setting.type).to eq "homepage"
|
||||
end
|
||||
|
||||
it "returns the key prefix for 'remote_census.general' settings" do
|
||||
remote_census_general_setting = Setting.create(key: "remote_census.general.whatever")
|
||||
expect(remote_census_general_setting.type).to eq "remote_census.general"
|
||||
end
|
||||
|
||||
it "returns the key prefix for 'remote_census_request' settings" do
|
||||
remote_census_request_setting = Setting.create(key: "remote_census.request.whatever")
|
||||
expect(remote_census_request_setting.type).to eq "remote_census.request"
|
||||
end
|
||||
|
||||
it "returns the key prefix for 'remote_census_response' settings" do
|
||||
remote_census_response_setting = Setting.create(key: "remote_census.response.whatever")
|
||||
expect(remote_census_response_setting.type).to eq "remote_census.response"
|
||||
end
|
||||
|
||||
it "returns 'configuration' for the rest of the settings" do
|
||||
configuration_setting = Setting.create(key: "whatever")
|
||||
expect(configuration_setting.type).to eq "configuration"
|
||||
|
||||
Reference in New Issue
Block a user