Browse Source

Add UnresolvedLogHelper and extract flack notice message

pull/1035/head
Kat 4 years ago
parent
commit
2ede6577ef
  1. 4
      app/controllers/lettings_logs_controller.rb
  2. 6
      app/helpers/unresolved_log_helper.rb

4
app/controllers/lettings_logs_controller.rb

@ -118,10 +118,8 @@ private
def resolve_logs! def resolve_logs!
if @log&.unresolved == true && @log.location.present? && @log.scheme.present? && @log.update(unresolved: false) if @log&.unresolved == true && @log.location.present? && @log.scheme.present? && @log.update(unresolved: false)
notice_message = "You’ve updated all the fields affected by the scheme change."
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
notice_message << " <a href=\"/lettings-logs/update-logs\">Update #{unresolved_logs_count_for_user} more logs</a>" if unresolved_logs_count_for_user.positive? flash.now[:notice] = helpers.flash_notice_for_resolved_logs(unresolved_logs_count_for_user)
flash[:notice] = notice_message.html_safe
end end
end end
end end

6
app/helpers/unresolved_log_helper.rb

@ -0,0 +1,6 @@
module UnresolvedLogHelper
def flash_notice_for_resolved_logs(count)
notice_message = "You’ve updated all the fields affected by the scheme change.</br>"
notice_message << " <a href=\"/lettings-logs/update-logs\">Update #{count} more logs</a>" if count.positive?
end
end
Loading…
Cancel
Save