Browse Source

Extract unresolved path and fix a link

pull/1035/head
Kat 4 years ago
parent
commit
3f11a4c832
  1. 4
      app/controllers/lettings_logs_controller.rb
  2. 4
      app/models/form.rb
  3. 2
      app/views/logs/index.html.erb
  4. 2
      app/views/logs/update_logs.html.erb

4
app/controllers/lettings_logs_controller.rb

@ -54,7 +54,7 @@ class LettingsLogsController < LogsController
@log = current_user.lettings_logs.find_by(id: params[:id]) @log = current_user.lettings_logs.find_by(id: params[:id])
if @log if @log
if @log.unresolved if @log.unresolved
redirect_to(send("lettings_log_#{@log.form.unresolved_log_redirect_page_id}_path", @log)) redirect_to(send(@log.form.unresolved_log_path, @log))
else else
render("logs/edit", locals: { current_user: }) render("logs/edit", locals: { current_user: })
end end
@ -116,7 +116,7 @@ private
end end
def resolve_logs! def resolve_logs!
if @log&.unresolved == true && @log.location.present? && @log.scheme.present? && @log.update(unresolved: false) if @log&.unresolved && @log.location.present? && @log.scheme.present? && @log&.update(unresolved: false)
unresolved_logs_count_for_user = current_user.lettings_logs.unresolved.created_by(current_user).count unresolved_logs_count_for_user = current_user.lettings_logs.unresolved.created_by(current_user).count
flash.now[:notice] = helpers.flash_notice_for_resolved_logs(unresolved_logs_count_for_user) flash.now[:notice] = helpers.flash_notice_for_resolved_logs(unresolved_logs_count_for_user)
end end

4
app/models/form.rb

@ -87,6 +87,10 @@ class Form
"#{log.class.name.underscore}_#{page.subsection.id}_check_answers_path" "#{log.class.name.underscore}_#{page.subsection.id}_check_answers_path"
end end
def unresolved_log_path
"#{form_type}_#{unresolved_log_redirect_page_id}_path"
end
def next_incomplete_section_redirect_path(subsection, log) def next_incomplete_section_redirect_path(subsection, log)
subsection_ids = subsections.map(&:id) subsection_ids = subsections.map(&:id)

2
app/views/logs/index.html.erb

@ -12,7 +12,7 @@
) do |notification_banner| %> ) do |notification_banner| %>
<% notification_banner.heading(text: "A scheme has changed and it has affected #{@unresolved_count} #{'log'.pluralize(@unresolved_count)}") %> <% notification_banner.heading(text: "A scheme has changed and it has affected #{@unresolved_count} #{'log'.pluralize(@unresolved_count)}") %>
<div class="govuk-notification-banner__heading"> <div class="govuk-notification-banner__heading">
<a class="govuk-notification-banner__link" href="<%= update_logs_lettings_logs_path %>">Update logs</a> <%= govuk_link_to "Update logs", update_logs_lettings_logs_path, class: "govuk-notification-banner__link" %>
</div> </div>
<% end %> <% end %>
<% end %> <% end %>

2
app/views/logs/update_logs.html.erb

@ -35,7 +35,7 @@
scope: "row", scope: "row",
class: "govuk-!-text-align-right", class: "govuk-!-text-align-right",
}) do %> }) do %>
<%= govuk_link_to("Update now", send("lettings_log_#{log.form.unresolved_log_redirect_page_id}_path", log)) %> <%= govuk_link_to("Update now", send(log.form.unresolved_log_path, log)) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

Loading…
Cancel
Save