Adds homepage phase and tab to legislation processes show

This commit is contained in:
decabeza
2019-01-09 12:29:00 +01:00
parent 7724f9421f
commit 73637de0d0
6 changed files with 27 additions and 4 deletions

View File

@@ -18,8 +18,8 @@ class Legislation::Process < ActiveRecord::Base
translates :homepage, touch: true
include Globalizable
PHASES_AND_PUBLICATIONS = %i[draft_phase debate_phase allegations_phase proposals_phase
draft_publication result_publication].freeze
PHASES_AND_PUBLICATIONS = %i[homepage_phase draft_phase debate_phase allegations_phase
proposals_phase draft_publication result_publication].freeze
has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion',
foreign_key: 'legislation_process_id',
@@ -54,6 +54,10 @@ class Legislation::Process < ActiveRecord::Base
draft_end_date IS NOT NULL and (draft_start_date > ? or
draft_end_date < ?))", Date.current, Date.current) }
def homepage_phase
Legislation::Process::Phase.new(start_date, end_date, homepage_enabled)
end
def draft_phase
Legislation::Process::Phase.new(draft_start_date, draft_end_date, draft_phase_enabled)
end

View File

@@ -6,6 +6,15 @@
<% end %>
<ul class="key-dates">
<% if process.homepage_enabled? && process.homepage.present? %>
<li <%= 'class=is-active' if phase.to_sym == :homepage %>>
<%= link_to legislation_process_path(process) do %>
<h4><%= t("legislation.processes.shared.homepage") %></h4>
<br>
<% end %>
</li>
<% end %>
<% if process.debate_phase.enabled? %>
<li <%= 'class=is-active' if phase.to_sym == :debate_phase %>>
<%= link_to debate_legislation_process_path(process) do %>

View File

@@ -4,9 +4,9 @@
<%= render 'documents/additional_documents', documents: @process.documents %>
<%= render 'key_dates', process: @process, phase: :debate_phase %>
<%= render 'key_dates', process: @process, phase: :homepage %>
<div class="row">
<div class="row margin-top">
<div class="small-12 medium-9 column">
<%= AdminWYSIWYGSanitizer.new.sanitize(@process.homepage) %>
</div>

View File

@@ -83,6 +83,7 @@ en:
see_latest_comments_title: Comment on this process
shared:
key_dates: Participation phases
homepage: Homepage
debate_dates: Debate
draft_publication_date: Draft publication
allegations_dates: Comments

View File

@@ -83,6 +83,7 @@ es:
see_latest_comments_title: Aportar a este proceso
shared:
key_dates: Fases de participación
homepage: Inicio
debate_dates: Debate previo
draft_publication_date: Publicación borrador
allegations_dates: Comentarios

View File

@@ -201,6 +201,10 @@ feature 'Legislation' do
visit legislation_process_path(process)
within(".key-dates") do
expect(page).to have_content("Homepage")
end
expect(page).to have_content("This is the process homepage")
expect(page).not_to have_content("Participate in the debate")
end
@@ -213,6 +217,10 @@ feature 'Legislation' do
visit legislation_process_path(process)
within(".key-dates") do
expect(page).not_to have_content("Homepage")
end
expect(page).to have_content("This phase is not open yet")
expect(page).not_to have_content("This is the process homepage")
end