Skip to content

Commit

Permalink
Merge pull request #459 from etalab/features/instruction/auto-submit
Browse files Browse the repository at this point in the history
  • Loading branch information
skelz0r authored Oct 2, 2024
2 parents 514beeb + 004ae1a commit e7f33d9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 39 deletions.
2 changes: 2 additions & 0 deletions app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Application } from '@hotwired/stimulus'
import { AutoSubmitFormController } from 'stimulus-library'

const application = Application.start()
application.register('auto-submit-form', AutoSubmitFormController)

// Configure Stimulus development experience
application.debug = false
Expand Down
7 changes: 0 additions & 7 deletions app/javascript/controllers/auto_submit_controller.js

This file was deleted.

56 changes: 29 additions & 27 deletions app/views/instruction/authorization_requests/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p class="fr-h2 fr-mt-5w"><%= t('.table.caption') %></p>

<%= search_form_for(@search_engine, url: instruction_authorization_requests_path, html: { method: :get, data: { turbo: false }, class: %w[search-box] }) do |f| %>
<%= search_form_for(@search_engine, url: instruction_authorization_requests_path, html: { method: :get, data: { controller: 'auto-submit-form', 'auto-submit-form-debounce-interval-value' => 300, 'auto-submit-form-event-mode-value' => 'input' }, class: %w[search-box] }) do |f| %>
<div class="search-inputs">
<div class="fr-input-group main-input input">
<%= f.label :within_data_or_organization_siret_or_applicant_email_or_applicant_family_name_cont, t('.search.main_input.label'), class: %w[fr-label] %>
Expand Down Expand Up @@ -28,34 +28,35 @@
</div>
<% end %>

<div class="fr-table fr-table--bordered">
<table>
<thead>
<tr>
<%
%w[
id
state
last_submitted_at
organization
project_name
authorization_request_kind
applicant_email
actions
].each do |attr|
%>
<th scope="col">
<% if %w[id state last_submitted_at].include?(attr) %>
<%= sort_link(@search_engine, attr) do %>
<turbo-frame id="authorization_requests_table">
<div class="fr-table fr-table--bordered">
<table>
<thead>
<tr>
<%
%w[
id
state
last_submitted_at
organization
project_name
authorization_request_kind
applicant_email
actions
].each do |attr|
%>
<th scope="col">
<% if %w[id state last_submitted_at].include?(attr) %>
<%= sort_link(@search_engine, attr) do %>
<%= t(".table.header.#{attr}") %>
<% end %>
<% else %>
<%= t(".table.header.#{attr}") %>
<% end %>
<% else %>
<%= t(".table.header.#{attr}") %>
<% end %>
</th>
<% end %>
</tr>
</thead>
</th>
<% end %>
</tr>
</thead>

<tbody>
<% @authorization_requests.each do |authorization_request| %>
Expand Down Expand Up @@ -95,3 +96,4 @@
</div>

<%= paginate @authorization_requests %>
</turbo-frame>
7 changes: 2 additions & 5 deletions app/views/profile/_authorization_notifications.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
</h3>

<div class="settings-block__container">
<%= form_with(model: current_user, url: notifications_settings_path, data: { controller: 'auto-submit' }) do |f| %>
<%= form_with(model: current_user, url: notifications_settings_path, data: { controller: 'auto-submit-form', 'auto-submit-form-debounce-interval-value' => 0 }) do |f| %>
<% %w[submit_notifications messages_notifications].each do |notification_kind| %>
<div class="fr-toggle">
<%=
f.check_box "instruction_#{notification_kind}_for_#{authorization_definition.id.underscore}",
class: 'fr-toggle__input',
data: {
action: 'change->auto-submit#perform'
}
class: 'fr-toggle__input'
%>
<%=
f.label "instruction_#{notification_kind}_for_#{authorization_definition.id.underscore}",
Expand Down

0 comments on commit e7f33d9

Please sign in to comment.