From a9d4ff85e6b7a95e46e228b0183e562a165f4993 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 12 Jan 2023 17:55:01 +0100 Subject: [PATCH] refactor(js): more autosubmit controllers --- .../experts_procedures/index.html.haml | 12 ++++++------ .../_instructeurs_self_management.html.haml | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/views/administrateurs/experts_procedures/index.html.haml b/app/views/administrateurs/experts_procedures/index.html.haml index 68ebef395..f3df79249 100644 --- a/app/views/administrateurs/experts_procedures/index.html.haml +++ b/app/views/administrateurs/experts_procedures/index.html.haml @@ -15,8 +15,8 @@ method: :put, url: allow_expert_review_admin_procedure_path(@procedure), html: { class: 'form procedure-form__column--form no-background' } do |f| - %label.toggle-switch - = f.check_box :allow_expert_review, class: 'toggle-switch-checkbox', onchange: 'this.form.requestSubmit()' + %label.toggle-switch{ data: { controller: 'autosubmit' } } + = f.check_box :allow_expert_review, class: 'toggle-switch-checkbox' %span.toggle-switch-control.round %span.toggle-switch-label.on %span.toggle-switch-label.off @@ -29,8 +29,8 @@ method: :put, url: experts_require_administrateur_invitation_admin_procedure_path(@procedure), html: { class: 'form procedure-form__column--form no-background' } do |f| - %label.toggle-switch - = f.check_box :experts_require_administrateur_invitation, class: 'toggle-switch-checkbox', onchange: 'this.form.requestSubmit()' + %label.toggle-switch{ data: { controller: 'autosubmit' } } + = f.check_box :experts_require_administrateur_invitation, class: 'toggle-switch-checkbox' %span.toggle-switch-control.round %span.toggle-switch-label.on %span.toggle-switch-label.off @@ -79,8 +79,8 @@ method: :put, data: { turbo: true }, html: { class: 'form procedure-form__column--form no-background' } do |f| - %label.toggle-switch - = f.check_box :allow_decision_access, class: 'toggle-switch-checkbox', onchange: 'this.form.requestSubmit()' + %label.toggle-switch{ data: { controller: 'autosubmit' } } + = f.check_box :allow_decision_access, class: 'toggle-switch-checkbox' %span.toggle-switch-control.round %span.toggle-switch-label.on %span.toggle-switch-label.off diff --git a/app/views/administrateurs/groupe_instructeurs/_instructeurs_self_management.html.haml b/app/views/administrateurs/groupe_instructeurs/_instructeurs_self_management.html.haml index ee20f9d5a..5b85b3504 100644 --- a/app/views/administrateurs/groupe_instructeurs/_instructeurs_self_management.html.haml +++ b/app/views/administrateurs/groupe_instructeurs/_instructeurs_self_management.html.haml @@ -5,9 +5,10 @@ = form_for procedure, method: :patch, url: update_instructeurs_self_management_enabled_admin_procedure_groupe_instructeurs_path(procedure), + data: { controller: 'autosubmit', turbo: 'true' }, html: { class: 'form procedure-form__column--form no-background' } do |f| %label.toggle-switch - = f.check_box :instructeurs_self_management_enabled, class: 'toggle-switch-checkbox', onchange: 'this.form.submit()' + = f.check_box :instructeurs_self_management_enabled, class: 'toggle-switch-checkbox' %span.toggle-switch-control.round %span.toggle-switch-label.on %span.toggle-switch-label.off