Refactor process phases pages

This commit is contained in:
Amaia Castro
2017-01-04 11:27:47 +01:00
parent b6b33ff85b
commit 2b6df62dd7
11 changed files with 69 additions and 62 deletions

View File

@@ -8,18 +8,53 @@ class Legislation::ProcessesController < Legislation::BaseController
end end
def show def show
if @process.show_phase?(:debate)
render :show
else
render :phase_not_open
end
end end
def draft_publication def draft_publication
phase :draft_publication phase :draft_publication
if @process.show_phase?(@phase)
if draft_version = @process.draft_versions.published.last
redirect_to legislation_process_draft_version_path(@process, draft_version)
else
render :phase_empty
end
else
render :phase_not_open
end
end end
def allegations def allegations
phase :allegations phase :allegations
if @process.show_phase?(@phase)
if draft_version = @process.draft_versions.published.last
redirect_to legislation_process_draft_version_path(@process, draft_version)
else
render :phase_empty
end
else
render :phase_not_open
end
end end
def final_version_publication def final_version_publication
phase :final_version_publication phase :final_version_publication
if @process.show_phase?(@phase)
if final_version = @process.final_draft_version
redirect_to legislation_process_draft_version_path(@process, final_version)
else
render :phase_empty
end
else
render :phase_not_open
end
end end
private private
@@ -27,6 +62,5 @@ class Legislation::ProcessesController < Legislation::BaseController
def phase(phase) def phase(phase)
@process = ::Legislation::Process.find(params[:process_id]) @process = ::Legislation::Process.find(params[:process_id])
@phase = phase @phase = phase
render :phase
end end
end end

View File

@@ -1,9 +0,0 @@
<% if process.draft_versions.any? %>
<ul>
<% process.draft_versions.published.each do |draft_version| %>
<li><%= link_to draft_version.title, legislation_process_draft_version_path(process, draft_version) %></li>
<% end %>
</ul>
<% else %>
<p><%= t('.empty') %></p>
<% end %>

View File

@@ -1,9 +0,0 @@
<% if process.draft_versions.any? %>
<ul>
<% process.draft_versions.published.each do |draft_version| %>
<li><%= link_to draft_version.title, legislation_process_draft_version_path(process, draft_version) %></li>
<% end %>
</ul>
<% else %>
<p><%= t('.empty') %></p>
<% end %>

View File

@@ -1,5 +0,0 @@
<% if process.final_draft_version %>
<p><%= legislation_process_draft_version_path(process.final_draft_version) %></p>
<% else %>
<p><%= t('.empty') %></p>
<% end %>

View File

@@ -1,13 +0,0 @@
<div class="debate-draft">
<div class="small-12 medium-7 column">
<h3><%= t('.not_open') %></h3>
<p>Suscríbete al proceso para recibir un aviso en el momento en que se abra.</p>
</div>
<div class="small-12 medium-5 column">
<button class="button-subscribe expanded button strong" title="Suscríbete al proceso" data-remote="true" rel="nofollow" data-method="post" href="/proposals/6-soluta-sed-sapiente-dolores/vote?value=yes">
<h3>Suscríbete al proceso</h3>
<p>Recibe notificaciones clave sobre el proceso</p>
</button>
</div>
</div>

View File

@@ -7,11 +7,7 @@
<div class="debate-chooser"> <div class="debate-chooser">
<div class="row"> <div class="row">
<% if @process.show_phase?(@phase) %> <p><%= t(".empty") %></p>
<%= render "phase_#{@phase}", process: @process %>
<% else %>
<%= render 'legislation/processes/phase_not_open' %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,25 @@
<% provide :title do %><%= @process.title %><% end %>
<%= render 'legislation/processes/header_full', process: @process %>
<div class="row">
<%= render 'legislation/processes/key_dates', process: @process, phase: @phase %>
<div class="debate-chooser">
<div class="row">
<div class="debate-draft">
<div class="small-12 medium-7 column">
<h3><%= t('.not_open') %></h3>
<p>Suscríbete al proceso para recibir un aviso en el momento en que se abra.</p>
</div>
<div class="small-12 medium-5 column">
<button class="button-subscribe expanded button strong" title="Suscríbete al proceso" data-remote="true" rel="nofollow" data-method="post" href="/proposals/6-soluta-sed-sapiente-dolores/vote?value=yes">
<h3>Suscríbete al proceso</h3>
<p>Recibe notificaciones clave sobre el proceso</p>
</button>
</div>
</div>
</div>
</div>
</div>

View File

@@ -7,11 +7,7 @@
<div class="debate-chooser"> <div class="debate-chooser">
<div class="row"> <div class="row">
<% if @process.show_phase?(:debate) %> <%= render 'debate', process: @process %>
<%= render 'debate', process: @process %>
<% else %>
<%= render 'phase_not_open' %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -256,12 +256,8 @@ en:
past: Past past: Past
phase_not_open: phase_not_open:
not_open: This phase is not open yet not_open: This phase is not open yet
phase_draft_publication: phase_empty:
empty: There are no drafts published empty: Nothing published yet
phase_allegations:
empty: There are no drafts published
phase_final_version_publication:
empty: Results have not been published yet
process: process:
see_latest_comments: See latest comments see_latest_comments: See latest comments
see_latest_comments_title: Comment on this process see_latest_comments_title: Comment on this process

View File

@@ -256,12 +256,8 @@ es:
past: Terminados past: Terminados
phase_not_open: phase_not_open:
not_open: Esta fase del proceso todavía no está abierta not_open: Esta fase del proceso todavía no está abierta
phase_draft_publication: phase_empty:
empty: No se ha publicado ningún borrador empty: No hay nada publicado todavía
phase_allegations:
empty: No se ha publicado ningún borrador
phase_final_version_publication:
empty: No se ha publicado el resultado todavía
process: process:
see_latest_comments: Ver últimas aportaciones see_latest_comments: Ver últimas aportaciones
see_latest_comments_title: Aportar a este proceso see_latest_comments_title: Aportar a este proceso

View File

@@ -69,7 +69,7 @@ feature 'Legislation' do
visit legislation_process_draft_publication_path(process) visit legislation_process_draft_publication_path(process)
expect(page).to have_content("There are no drafts published") expect(page).to have_content("Nothing published yet")
end end
end end
@@ -87,7 +87,7 @@ feature 'Legislation' do
visit legislation_process_allegations_path(process) visit legislation_process_allegations_path(process)
expect(page).to have_content("There are no drafts published") expect(page).to have_content("Nothing published yet")
end end
end end
@@ -105,7 +105,7 @@ feature 'Legislation' do
visit legislation_process_final_version_publication_path(process) visit legislation_process_final_version_publication_path(process)
expect(page).to have_content("Results have not been published yet") expect(page).to have_content("Nothing published yet")
end end
end end
end end