Rename sdg_related_list to related_sdg_list
To maintain consistency with the current names in the database with fields: :related_sdg_type and :related_sdg_id
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<div class="sdg-related-list-selector">
|
<div class="sdg-related-list-selector">
|
||||||
<div class="input-section">
|
<div class="input-section">
|
||||||
<%= f.label :sdg_related_list %>
|
<%= f.label :related_sdg_list %>
|
||||||
|
|
||||||
<ul aria-label="<%= t("sdg.related_list_selector.goal_list") %>">
|
<ul aria-label="<%= t("sdg.related_list_selector.goal_list") %>">
|
||||||
<% goals.each do |goal| %>
|
<% goals.each do |goal| %>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<%= f.text_field :sdg_related_list,
|
<%= f.text_field :related_sdg_list,
|
||||||
class: "input",
|
class: "input",
|
||||||
label: false,
|
label: false,
|
||||||
placeholder: t("sdg.related_list_selector.placeholder"),
|
placeholder: t("sdg.related_list_selector.placeholder"),
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
|||||||
:custom_list,
|
:custom_list,
|
||||||
:background_color,
|
:background_color,
|
||||||
:font_color,
|
:font_color,
|
||||||
:sdg_related_list,
|
:related_sdg_list,
|
||||||
translation_params(::Legislation::Process),
|
translation_params(::Legislation::Process),
|
||||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
|
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
|
||||||
image_attributes: image_attributes
|
image_attributes: image_attributes
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def poll_params
|
def poll_params
|
||||||
attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :budget_id, :sdg_related_list,
|
attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :budget_id, :related_sdg_list,
|
||||||
geozone_ids: [], image_attributes: image_attributes]
|
geozone_ids: [], image_attributes: image_attributes]
|
||||||
|
|
||||||
params.require(:poll).permit(*attributes, *report_attributes, translation_params(Poll))
|
params.require(:poll).permit(*attributes, *report_attributes, translation_params(Poll))
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ module Budgets
|
|||||||
|
|
||||||
def investment_params
|
def investment_params
|
||||||
attributes = [:heading_id, :tag_list, :organization_name, :location,
|
attributes = [:heading_id, :tag_list, :organization_name, :location,
|
||||||
:terms_of_service, :skip_map, :sdg_related_list,
|
:terms_of_service, :skip_map, :related_sdg_list,
|
||||||
image_attributes: image_attributes,
|
image_attributes: image_attributes,
|
||||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
|
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
|
||||||
map_location_attributes: [:latitude, :longitude, :zoom]]
|
map_location_attributes: [:latitude, :longitude, :zoom]]
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class DebatesController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def debate_params
|
def debate_params
|
||||||
attributes = [:tag_list, :terms_of_service, :sdg_related_list]
|
attributes = [:tag_list, :terms_of_service, :related_sdg_list]
|
||||||
params.require(:debate).permit(attributes, translation_params(Debate))
|
params.require(:debate).permit(attributes, translation_params(Debate))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class ProposalsController < ApplicationController
|
|||||||
|
|
||||||
def proposal_params
|
def proposal_params
|
||||||
attributes = [:video_url, :responsible_name, :tag_list, :terms_of_service,
|
attributes = [:video_url, :responsible_name, :tag_list, :terms_of_service,
|
||||||
:geozone_id, :skip_map, :sdg_related_list,
|
:geozone_id, :skip_map, :related_sdg_list,
|
||||||
image_attributes: image_attributes,
|
image_attributes: image_attributes,
|
||||||
documents_attributes: [:id, :title, :attachment, :cached_attachment,
|
documents_attributes: [:id, :title, :attachment, :cached_attachment,
|
||||||
:user_id, :_destroy],
|
:user_id, :_destroy],
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class SDGManagement::RelationsController < SDGManagement::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@record.sdg_related_list = params[@record.class.table_name.singularize][:sdg_related_list]
|
@record.related_sdg_list = params[@record.class.table_name.singularize][:related_sdg_list]
|
||||||
|
|
||||||
redirect_to({ action: :index }, notice: update_notice)
|
redirect_to({ action: :index }, notice: update_notice)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,11 +73,11 @@ module SDG::Relatable
|
|||||||
sdg_targets.sort.map(&:code).join(", ")
|
sdg_targets.sort.map(&:code).join(", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
def sdg_related_list
|
def related_sdg_list
|
||||||
related_sdgs.sort.map(&:code).join(", ")
|
related_sdgs.sort.map(&:code).join(", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
def sdg_related_list=(codes)
|
def related_sdg_list=(codes)
|
||||||
target_codes, goal_codes = codes.tr(" ", "").split(",").partition { |code| code.include?(".") }
|
target_codes, goal_codes = codes.tr(" ", "").split(",").partition { |code| code.include?(".") }
|
||||||
local_targets_codes, global_targets_codes = target_codes.partition { |code| code.split(".")[2] }
|
local_targets_codes, global_targets_codes = target_codes.partition { |code| code.split(".")[2] }
|
||||||
global_targets = global_targets_codes.map { |code| SDG::Target[code] }
|
global_targets = global_targets_codes.map { |code| SDG::Target[code] }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ en:
|
|||||||
attributes:
|
attributes:
|
||||||
geozone_id: "Scope of operation"
|
geozone_id: "Scope of operation"
|
||||||
results_enabled: "Show results"
|
results_enabled: "Show results"
|
||||||
sdg_related_list: "Sustainable Development Goals and Targets"
|
related_sdg_list: "Sustainable Development Goals and Targets"
|
||||||
stats_enabled: "Show stats"
|
stats_enabled: "Show stats"
|
||||||
advanced_stats_enabled: "Show advanced stats"
|
advanced_stats_enabled: "Show advanced stats"
|
||||||
name: Name
|
name: Name
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ es:
|
|||||||
attributes:
|
attributes:
|
||||||
geozone_id: "Ámbito de actuación"
|
geozone_id: "Ámbito de actuación"
|
||||||
results_enabled: "Mostrar resultados"
|
results_enabled: "Mostrar resultados"
|
||||||
sdg_related_list: "Objetivos de Desarrollo Sostenible y Metas"
|
related_sdg_list: "Objetivos de Desarrollo Sostenible y Metas"
|
||||||
stats_enabled: "Mostrar estadísticas"
|
stats_enabled: "Mostrar estadísticas"
|
||||||
advanced_stats_enabled: "Mostrar estadísticas avanzadas"
|
advanced_stats_enabled: "Mostrar estadísticas avanzadas"
|
||||||
name: Nombre
|
name: Nombre
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ describe SDG::RelatedListSelectorComponent, type: :component do
|
|||||||
expect(page).not_to have_css ".sdg-related-list-selector"
|
expect(page).not_to have_css ".sdg-related-list-selector"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders sdg_related_list field" do
|
it "renders related_sdg_list field" do
|
||||||
render_inline component
|
render_inline component
|
||||||
|
|
||||||
expect(page).to have_css ".sdg-related-list-selector .input"
|
expect(page).to have_css ".sdg-related-list-selector .input"
|
||||||
|
|||||||
@@ -99,13 +99,13 @@ describe SDG::Relatable do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#sdg_related_list" do
|
describe "#related_sdg_list" do
|
||||||
it "orders related list by code" do
|
it "orders related list by code" do
|
||||||
relatable.sdg_goals = [SDG::Goal[1], SDG::Goal[3], SDG::Goal[2]]
|
relatable.sdg_goals = [SDG::Goal[1], SDG::Goal[3], SDG::Goal[2]]
|
||||||
local_targets = %w[2.2.2 2.2.1 3.1.1].map { |code| create(:sdg_local_target, code: code) }
|
local_targets = %w[2.2.2 2.2.1 3.1.1].map { |code| create(:sdg_local_target, code: code) }
|
||||||
relatable.sdg_targets = [SDG::Target[2.2], SDG::Target[1.2], SDG::Target[2.1]] + local_targets
|
relatable.sdg_targets = [SDG::Target[2.2], SDG::Target[1.2], SDG::Target[2.1]] + local_targets
|
||||||
|
|
||||||
expect(relatable.sdg_related_list).to eq "1, 1.2, 2, 2.1, 2.2, 2.2.1, 2.2.2, 3, 3.1.1"
|
expect(relatable.related_sdg_list).to eq "1, 1.2, 2, 2.1, 2.2, 2.2.1, 2.2.2, 3, 3.1.1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -120,56 +120,56 @@ describe SDG::Relatable do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#sdg_related_list=" do
|
describe "#related_sdg_list=" do
|
||||||
it "assigns a single goal" do
|
it "assigns a single goal" do
|
||||||
relatable.sdg_related_list = "1"
|
relatable.related_sdg_list = "1"
|
||||||
|
|
||||||
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1]]
|
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1]]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns a single target" do
|
it "assigns a single target" do
|
||||||
relatable.sdg_related_list = "1.1"
|
relatable.related_sdg_list = "1.1"
|
||||||
|
|
||||||
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1]]
|
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1]]
|
||||||
expect(relatable.reload.sdg_targets).to match_array [SDG::Target[1.1]]
|
expect(relatable.reload.sdg_targets).to match_array [SDG::Target[1.1]]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns a single local target" do
|
it "assigns a single local target" do
|
||||||
relatable.sdg_related_list = local_target.code
|
relatable.related_sdg_list = local_target.code
|
||||||
|
|
||||||
expect(relatable.reload.sdg_goals).to match_array [local_target.goal]
|
expect(relatable.reload.sdg_goals).to match_array [local_target.goal]
|
||||||
expect(relatable.reload.sdg_local_targets).to match_array [local_target]
|
expect(relatable.reload.sdg_local_targets).to match_array [local_target]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns multiple targets" do
|
it "assigns multiple targets" do
|
||||||
relatable.sdg_related_list = "1.1,2.3"
|
relatable.related_sdg_list = "1.1,2.3"
|
||||||
|
|
||||||
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1], SDG::Goal[2]]
|
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1], SDG::Goal[2]]
|
||||||
expect(relatable.reload.sdg_targets).to match_array [SDG::Target[1.1], SDG::Target[2.3]]
|
expect(relatable.reload.sdg_targets).to match_array [SDG::Target[1.1], SDG::Target[2.3]]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns multiple goals" do
|
it "assigns multiple goals" do
|
||||||
relatable.sdg_related_list = "3,2,1"
|
relatable.related_sdg_list = "3,2,1"
|
||||||
|
|
||||||
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1], SDG::Goal[2], SDG::Goal[3]]
|
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1], SDG::Goal[2], SDG::Goal[3]]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns multiple local targets" do
|
it "assigns multiple local targets" do
|
||||||
relatable.sdg_related_list = "#{local_target.code}, #{another_local_target.code}"
|
relatable.related_sdg_list = "#{local_target.code}, #{another_local_target.code}"
|
||||||
|
|
||||||
expect(relatable.reload.sdg_goals).to match_array [local_target.goal, another_local_target.goal]
|
expect(relatable.reload.sdg_goals).to match_array [local_target.goal, another_local_target.goal]
|
||||||
expect(relatable.reload.sdg_local_targets).to match_array [local_target, another_local_target]
|
expect(relatable.reload.sdg_local_targets).to match_array [local_target, another_local_target]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "ignores trailing spaces and spaces between commas" do
|
it "ignores trailing spaces and spaces between commas" do
|
||||||
relatable.sdg_related_list = " 1.1, 2.3 "
|
relatable.related_sdg_list = " 1.1, 2.3 "
|
||||||
|
|
||||||
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1], SDG::Goal[2]]
|
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1], SDG::Goal[2]]
|
||||||
expect(relatable.reload.sdg_targets).to match_array [SDG::Target[1.1], SDG::Target[2.3]]
|
expect(relatable.reload.sdg_targets).to match_array [SDG::Target[1.1], SDG::Target[2.3]]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "assigns goals, targets and local_targets" do
|
it "assigns goals, targets and local_targets" do
|
||||||
relatable.sdg_related_list = "1.1,3,4,4.1,#{another_local_target.code}"
|
relatable.related_sdg_list = "1.1,3,4,4.1,#{another_local_target.code}"
|
||||||
|
|
||||||
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1], another_local_target.goal, SDG::Goal[3], SDG::Goal[4]]
|
expect(relatable.reload.sdg_goals).to match_array [SDG::Goal[1], another_local_target.goal, SDG::Goal[3], SDG::Goal[4]]
|
||||||
expect(relatable.reload.sdg_global_targets).to match_array [SDG::Target[1.1], SDG::Target[4.1]]
|
expect(relatable.reload.sdg_global_targets).to match_array [SDG::Target[1.1], SDG::Target[4.1]]
|
||||||
@@ -177,10 +177,10 @@ describe SDG::Relatable do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "touches the associated record" do
|
it "touches the associated record" do
|
||||||
relatable.sdg_related_list = "1.1, 2.1, 2.2"
|
relatable.related_sdg_list = "1.1, 2.1, 2.2"
|
||||||
|
|
||||||
travel(10.seconds) do
|
travel(10.seconds) do
|
||||||
relatable.sdg_related_list = "1.1, 2.1, 2.2, 3.1"
|
relatable.related_sdg_list = "1.1, 2.1, 2.2, 3.1"
|
||||||
|
|
||||||
expect(relatable.updated_at).to eq Time.current
|
expect(relatable.updated_at).to eq Time.current
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user