Add SDG goals/targets to legislation proposals

This commit is contained in:
Javi Martín
2021-02-24 20:20:40 +01:00
parent 3d97708cc5
commit 45517f659e
12 changed files with 31 additions and 11 deletions

View File

@@ -58,6 +58,7 @@
} }
&.legislation-link, &.legislation-link,
&.legislation-proposals-link,
&.legislation-processes-link { &.legislation-processes-link {
@include icon(file-alt, solid); @include icon(file-alt, solid);
} }

View File

@@ -32,7 +32,11 @@ class SDG::FilterLinksComponent < ApplicationComponent
end end
def index_by(advanced_search) def index_by(advanced_search)
polymorphic_path(related_model, advanced_search: advanced_search) if related_model.name == "Legislation::Proposal"
legislation_process_proposals_path(params[:id], advanced_search: advanced_search, filter: params[:filter])
else
polymorphic_path(related_model, advanced_search: advanced_search)
end
end end
def i18n_namespace def i18n_namespace

View File

@@ -112,7 +112,7 @@ class Legislation::ProcessesController < Legislation::BaseController
set_process set_process
@phase = :proposals_phase @phase = :proposals_phase
@proposals = ::Legislation::Proposal.where(process: @process) @proposals = ::Legislation::Proposal.where(process: @process).filter_by(params[:advanced_search])
@proposals = @proposals.search(params[:search]) if params[:search].present? @proposals = @proposals.search(params[:search]) if params[:search].present?
@current_filter = "winners" if params[:filter].blank? && @proposals.winners.any? @current_filter = "winners" if params[:filter].blank? && @proposals.winners.any?

View File

@@ -6,6 +6,7 @@ module SDG::Related
Budget::Investment Budget::Investment
Debate Debate
Legislation::Process Legislation::Process
Legislation::Proposal
Poll Poll
Proposal Proposal
].freeze ].freeze

View File

@@ -13,6 +13,7 @@ class Legislation::Proposal < ApplicationRecord
include Notifiable include Notifiable
include Imageable include Imageable
include Randomizable include Randomizable
include SDG::Relatable
accepts_nested_attributes_for :documents, allow_destroy: true accepts_nested_attributes_for :documents, allow_destroy: true

View File

@@ -1282,6 +1282,7 @@ en:
budget_investments: "Search investments by title, description or heading" budget_investments: "Search investments by title, description or heading"
debates: "Search debates by title or description" debates: "Search debates by title or description"
legislation_processes: "Search processes by title or description" legislation_processes: "Search processes by title or description"
legislation_proposals: "Search proposals by title or description"
local_census_records: "Search by document number" local_census_records: "Search by document number"
organizations: "Name, email or phone number" organizations: "Name, email or phone number"
poll_officers: "Search poll officers" poll_officers: "Search poll officers"

View File

@@ -11,7 +11,8 @@ en:
menu: menu:
budget_investments: "Participatory budgets" budget_investments: "Participatory budgets"
debates: "Debates" debates: "Debates"
legislation_processes: "Collaborative legislation" legislation_processes: "Legislation processes"
legislation_proposals: "Legislation proposals"
polls: "Polls" polls: "Polls"
proposals: "Proposals" proposals: "Proposals"
sdg_content: "Goals and Targets" sdg_content: "Goals and Targets"

View File

@@ -1281,6 +1281,7 @@ es:
budget_investments: "Buscar proyectos por título, descripción o partida" budget_investments: "Buscar proyectos por título, descripción o partida"
debates: "Buscar debates por título o descripción" debates: "Buscar debates por título o descripción"
legislation_processes: "Buscar procesos por título o descripción" legislation_processes: "Buscar procesos por título o descripción"
legislation_proposals: "Buscar propuestas por título o descripción"
local_census_records: "Búsqueda por número de documento" local_census_records: "Búsqueda por número de documento"
organizations: "Nombre, email o teléfono" organizations: "Nombre, email o teléfono"
poll_officers: "Buscar presidentes de mesa" poll_officers: "Buscar presidentes de mesa"

View File

@@ -11,7 +11,8 @@ es:
menu: menu:
budget_investments: "Presupuestos participativos" budget_investments: "Presupuestos participativos"
debates: "Debates" debates: "Debates"
legislation_processes: "Legislación colaborativa" legislation_processes: "Procesos legislativos"
legislation_proposals: "Propuestas legislativas"
polls: "Votaciones" polls: "Votaciones"
proposals: "Propuestas" proposals: "Propuestas"
sdg_content: "Objetivos y Metas" sdg_content: "Objetivos y Metas"

View File

@@ -20,7 +20,8 @@ describe SDGManagement::MenuComponent, type: :component do
expect(page).to have_link "SDG homepage" expect(page).to have_link "SDG homepage"
expect(page).to have_link "Participatory budgets" expect(page).to have_link "Participatory budgets"
expect(page).to have_link "Debates" expect(page).to have_link "Debates"
expect(page).to have_link "Collaborative legislation" expect(page).to have_link "Legislation processes"
expect(page).to have_link "Legislation proposals"
expect(page).to have_link "Polls" expect(page).to have_link "Polls"
expect(page).to have_link "Proposals" expect(page).to have_link "Proposals"
end end
@@ -71,7 +72,8 @@ describe SDGManagement::MenuComponent, type: :component do
expect(page).to have_link "Goals and Targets" expect(page).to have_link "Goals and Targets"
expect(page).to have_link "SDG homepage" expect(page).to have_link "SDG homepage"
expect(page).to have_link "Participatory budgets" expect(page).to have_link "Participatory budgets"
expect(page).to have_link "Collaborative legislation" expect(page).to have_link "Legislation processes"
expect(page).to have_link "Legislation proposals"
expect(page).to have_link "Polls" expect(page).to have_link "Polls"
expect(page).to have_link "Proposals" expect(page).to have_link "Proposals"
@@ -92,7 +94,8 @@ describe SDGManagement::MenuComponent, type: :component do
expect(page).to have_link "Polls" expect(page).to have_link "Polls"
expect(page).to have_link "Proposals" expect(page).to have_link "Proposals"
expect(page).not_to have_link "Collaborative legislation" expect(page).not_to have_link "Legislation processes"
expect(page).not_to have_link "Legislation proposals"
end end
end end
end end

View File

@@ -33,8 +33,8 @@ describe SDG::ProcessEnabled do
end end
it "returns false when record or name are not a relatable type" do it "returns false when record or name are not a relatable type" do
expect(SDG::ProcessEnabled.new(build(:legislation_proposal))).not_to be_enabled expect(SDG::ProcessEnabled.new(build(:legislation_question))).not_to be_enabled
expect(SDG::ProcessEnabled.new("Legislation::Proposal")).not_to be_enabled expect(SDG::ProcessEnabled.new("Legislation::Question")).not_to be_enabled
expect(SDG::ProcessEnabled.new("officing/booth")).not_to be_enabled expect(SDG::ProcessEnabled.new("officing/booth")).not_to be_enabled
end end
end end

View File

@@ -26,10 +26,16 @@ describe "SDG Relations", :js do
expect(page).to have_css "h2", exact_text: "Debates" expect(page).to have_css "h2", exact_text: "Debates"
expect(page).to have_css "li.is-active h2", exact_text: "Pending" expect(page).to have_css "li.is-active h2", exact_text: "Pending"
within("#side_menu") { click_link "Collaborative legislation" } within("#side_menu") { click_link "Legislation processes" }
expect(page).to have_current_path "/sdg_management/legislation/processes" expect(page).to have_current_path "/sdg_management/legislation/processes"
expect(page).to have_css "h2", exact_text: "Collaborative legislation" expect(page).to have_css "h2", exact_text: "Legislation processes"
expect(page).to have_css "li.is-active h2", exact_text: "Pending"
within("#side_menu") { click_link "Legislation proposals" }
expect(page).to have_current_path "/sdg_management/legislation/proposals"
expect(page).to have_css "h2", exact_text: "Legislation proposals"
expect(page).to have_css "li.is-active h2", exact_text: "Pending" expect(page).to have_css "li.is-active h2", exact_text: "Pending"
within("#side_menu") { click_link "Polls" } within("#side_menu") { click_link "Polls" }