Skip to content

Commit

Permalink
Merge pull request #2175 from MushroomObserver/nimmo-fix-project-mess…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
nimmolo committed Jun 11, 2024
2 parents 38b163f + b50cdad commit 310c503
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
3 changes: 3 additions & 0 deletions app/controllers/observations_controller/validators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def validate_projects(params)

@suspect_checked_projects = checked_project_conflicts -
@observation.projects
if @suspect_checked_projects.any?
flash_warning(:form_observations_there_is_a_problem_with_projects.t)
end
@suspect_checked_projects.empty?
end

Expand Down
58 changes: 26 additions & 32 deletions app/views/controllers/observations/form/_projects.html.erb
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
<%# Projects section of create_observation form %>
<% if @suspect_checked_projects.any? %>
<% flash_warning(:form_observations_there_is_a_problem_with_projects.t) %>

<div class="alert alert-warning"
id="project_messages">
<%= tag.p(
"#{:form_observations_projects_out_of_range.t(
date: @observation.when,
place_name: @observation.place_name
)}:"
) %>
<ul>
<% @suspect_checked_projects.each do |proj| %>
<%= tag.li("#{proj.title} (#{proj.constraints})") %>
<% end %>
</ul>
<%= tag.p(
:form_observations_projects_out_of_range_help.
t(button_name: button_name)
)%>
</div>
<% end %>
<%= fields_for(:project) do |f_p| %>
<% if @suspect_checked_projects.any? %>
<div class="mt-3 row" id="observation_projects">
<%= check_box_with_label(
form: f_p, field: :ignore_proj_conflicts,
label: :form_observations_projects_ignore_project_constraints.t,
class: "alert alert-warning"
) %>
</div>
<% end %>

<div class="mt-3 row" id="observation_projects">
<% if @suspect_checked_projects.any? %>
<div class="col-xs-12">
<div class="alert alert-warning"
id="project_messages">
<%= tag.p(
"#{:form_observations_projects_out_of_range.t(
date: @observation.when,
place_name: @observation.place_name
)}:"
) %>
<ul>
<% @suspect_checked_projects.each do |proj| %>
<%= tag.li("#{proj.title} (#{proj.constraints})") %>
<% end %>
</ul>
<%= tag.p(
:form_observations_projects_out_of_range_help.
t(button_name: button_name)
)%>
</div>
<%= check_box_with_label(
form: f_p, field: :ignore_proj_conflicts,
label: :form_observations_projects_ignore_project_constraints.t
) %>
</div>
<% end %>
<div class="col-xs-12 col-sm-6 col-sm-push-6">
<%= help_block_with_arrow("left", id: "project_help") do %>
<%= :form_observations_project_help.t %>
Expand Down

0 comments on commit 310c503

Please sign in to comment.