Skip to content

Commit

Permalink
prevent breaking array input globally
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaelvilleneuve committed Feb 10, 2025
1 parent c9e5379 commit 2dc0052
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
9 changes: 9 additions & 0 deletions app/views/common/_with_clean_users_query_params.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% url_params.except(*omit).each do |key, value| %>
<% if value.is_a?(Array) %>
<% value.each do |v| %>
<%= form.hidden_field key, value: v, multiple: true %>
<% end %>
<% else %>
<%= form.hidden_field key, value: value %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<%= render "common/remote_modal", title: "Filtrer par date de convocation" do %>
<%= form_with method: :get, local: true, url: structure_users_path, data: { "turbo-frame" => "_top" } do |form| %>
<% url_params.except(:convocation_date_before, :convocation_date_after, :department_id, :organisation_id).each do |key, value| %>
<%= form.hidden_field key, value: value %>
<% end %>
<%= render "common/with_clean_users_query_params", form:, omit: [:convocation_date_before, :convocation_date_after, :department_id, :organisation_id] %>

<div class="d-flex mb-2">
<%= form.text_field :convocation_date_after,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<%= render "common/remote_modal", title: "Filtrer par date de création" do %>
<%= form_with method: :get, local: true, url: structure_users_path, data: { "turbo-frame" => "_top" } do |form| %>
<% url_params.except(:creation_date_after, :creation_date_before).each do |key, value| %>
<%= form.hidden_field key, value: value %>
<% end %>

<%= render "common/with_clean_users_query_params", form:, omit: [:creation_date_after, :creation_date_before] %>

<p class="mb-2">Date de création</p>
<div class="d-flex mb-3">
<%= form.text_field :creation_date_after,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<%= render "common/remote_modal", title: "Filtrer par date d'invitation" do %>
<%= form_with method: :get, local: true, url: structure_users_path, data: { "turbo-frame" => "_top" } do |form| %>
<% url_params.except(:first_invitation_date_after, :first_invitation_date_before, :last_invitation_date_after, :last_invitation_date_before, :department_id, :organisation_id).each do |key, value| %>
<%= form.hidden_field key, value: value %>
<% end %>
<%= render "common/with_clean_users_query_params", form:, omit: [:first_invitation_date_after, :first_invitation_date_before, :last_invitation_date_after, :last_invitation_date_before, :department_id, :organisation_id] %>

<p class="mb-2">Première invitation</p>
<div class="d-flex mb-3">
Expand Down
10 changes: 1 addition & 9 deletions app/views/users/_search_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<%= form_with method: :get, url: url, local: true do |form| %>
<div class="d-flex">
<% url_params.except(:search_query, :motif_category_id).each do |key, value| %>
<% if value.is_a?(Array) %>
<% value.each do |v| %>
<%= form.hidden_field key, value: v, multiple: true %>
<% end %>
<% else %>
<%= form.hidden_field key, value: value %>
<% end %>
<% end %>
<%= render "common/with_clean_users_query_params", form:, omit: [:search_query, :motif_category_id] %>

<%= form.text_field :search_query, placeholder: "Prénom, nom, email, n° CAF...", class: "form-control mb-0", value: params[:search_query] %>
<%= form.submit "Rechercher", name: nil, class: "btn btn-blue-out ms-3" %>
Expand Down

0 comments on commit 2dc0052

Please sign in to comment.