Skip to content

Commit

Permalink
Inlining review and fact check activity fields
Browse files Browse the repository at this point in the history
www.agileplannerapp.com/boards/173808/cards/5629

... with edition form. these were left out earlier,
causing review activities to not save edition changes.

part of a larger change:

#251
  • Loading branch information
Vinay Patel committed Sep 10, 2014
1 parent 34556c2 commit 7649d01
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/controllers/editions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def update
# it at the wrong time.
assign_to = new_assignee

activity_attempted = Edition::BASIC_EVENTS.invert[params[:commit]]
activity_attempted = Edition::EVENTS.invert[params[:commit]]
activity_params = params[:edition]["activity_#{activity_attempted}_attributes"]

update! do |success, failure|
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/edition_activity_buttons_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def build_review_button(edition, activity, title)

def review_buttons(edition)
[
["Needs more work", "request_amendments"],
["Needs more work", "request_amendments"],
["OK for publication", "approve_review"]
].map{ |title, activity|
build_review_button(edition, activity, title)
Expand All @@ -19,7 +19,7 @@ def review_buttons(edition)

def fact_check_buttons(edition)
[
["Needs major changes", "request_amendments"],
["Needs major changes", "request_amendments"],
["Minor or no changes required", "approve_fact_check"]
].map{ |title, activity|
build_review_button(edition, activity, title)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/edition_activity_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module EditionActivityHelper
def edition_activities_fields(f, edition)
activities_fields = Edition::BASIC_EVENTS.map do |activity, title|
activities_fields = Edition::EVENTS.map do |activity, title|
content_tag(:div, modal_attributes.merge(id: "#{activity}_form")) do
edition_activity_fields(edition, title, activity, f, inline: true)
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/editions/diff.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<p>(It's unpublished from the website but you can still see the latest edition here in Publisher.)</p>
</div>
<% else %>
<%= render 'shared/ready_or_review_or_fact_check' %>
<%= render 'shared/ready_or_review_or_fact_check', render_activity_forms: true %>
<% end %>

<p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/editions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</div><!--/.well -->
<% # cancel scheduled publishing doesn't require the edition to be saved when requesting an activity,
# because this action is triggered from a view where editing is not allowed. %>
<%= edition_activities_forms(@resource, Edition::SCHEDULED_PUBLISHING_EVENTS) %>
<%= edition_activities_forms(@resource, Edition::CANCEL_SCHEDULED_PUBLISHING_EVENT) %>
</div>
<div class="tab-pane" id="metadata">
<div class="well">
Expand Down
4 changes: 3 additions & 1 deletion app/views/shared/_fact_check_received.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
<div class="workflow-buttons">
<%= fact_check_buttons(@resource)%>
</div>
<%= fact_check_forms(@resource)%>
<% if render_activity_forms %>
<%= fact_check_forms(@resource)%>
<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/shared/_ready.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="alert alert-info">
<p>Request this edition to be amended further.</p>
<%= render 'shared/request_amendments' %>
<%= render 'shared/request_amendments', locals: { render_activity_forms: render_activity_forms } %>
</div>
15 changes: 10 additions & 5 deletions app/views/shared/_ready_or_review_or_fact_check.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<% # edition transitions are done using fields inlined in the edition form.
# we need to render activity forms to allow edition transitions on views
# where activity fields are not inlined with edition form.
render_activity_forms = false unless defined?(:render_activity_forms) %>

<% if @resource.in_review? %>
<%= render '/shared/review' %>
<%= render '/shared/review', render_activity_forms: render_activity_forms %>
<% elsif @resource.fact_check? %>
<%= render '/shared/fact_check' %>
<%= render '/shared/fact_check', render_activity_forms: render_activity_forms %>
<% elsif @resource.fact_check_received? %>
<%= render '/shared/fact_check_received' %>
<%= render '/shared/fact_check_received', render_activity_forms: render_activity_forms %>
<% elsif @resource.fact_check_skipped? %>
<div class="alert alert-info">
<p>Fact check was skipped for this edition.</p>
</div>
<%= render '/shared/ready' %>
<%= render '/shared/ready', render_activity_forms: render_activity_forms %>
<% elsif @resource.ready? %>
<%= render '/shared/ready' %>
<%= render '/shared/ready', render_activity_forms: render_activity_forms %>
<% end %>
6 changes: 5 additions & 1 deletion app/views/shared/_request_amendments.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
<% render_activity_forms = false unless defined?(:render_activity_forms) %>

<%= build_review_button(@resource, "request_amendments", "Needs more work").html_safe %>
<%= edition_activities_forms(@resource, request_amendments: "Request amendments") %>
<% if render_activity_forms %>
<%= edition_activities_forms(@resource, request_amendments: "Request amendments") %>
<% end %>
4 changes: 3 additions & 1 deletion app/views/shared/_review.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<div class="workflow-buttons">
<%= review_buttons(@resource)%>
</div>
<%= review_forms(@resource)%>
<% if render_activity_forms %>
<%= review_forms(@resource)%>
<% end %>
<% end %>
<% else %>
<p>We're having trouble accessing the action data. This Edition has been requested to be reviewed.</p>
Expand Down
15 changes: 6 additions & 9 deletions lib/enhancements/edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@ class Edition
class ResurrectionError < RuntimeError
end

BASIC_EVENTS = {
EVENTS = {
send_fact_check: "Send to Fact check",
request_review: "Send to 2nd pair of eyes",
schedule_for_publishing: "Schedule for publishing",
publish: "Send to publish"
}
REVIEW_EVENTS = {
request_amendments: "Request amendments",
approve_review: "OK for publication"
}
FACT_CHECK_EVENTS = {
publish: "Send to publish",
approve_review: "OK for publication",
request_amendments: "Request amendments",
approve_fact_check: "Approve fact check"
}
SCHEDULED_PUBLISHING_EVENTS = {
REVIEW_EVENTS = EVENTS.slice(:request_amendments, :approve_review)
FACT_CHECK_EVENTS = EVENTS.slice(:request_amendments, :approve_fact_check)
CANCEL_SCHEDULED_PUBLISHING_EVENT = {
cancel_scheduled_publishing: "Cancel scheduled publishing"
}

Expand Down

0 comments on commit 7649d01

Please sign in to comment.