From 01efae960b48af934d69aaeea9038f12d4d91adf Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 12 Sep 2023 17:06:55 +0200 Subject: [PATCH] fix component --- app/components/profile/api_token_component.rb | 4 ++-- .../api_token_component/api_token_component.html.haml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/components/profile/api_token_component.rb b/app/components/profile/api_token_component.rb index 7b91244eb..9ff127222 100644 --- a/app/components/profile/api_token_component.rb +++ b/app/components/profile/api_token_component.rb @@ -7,10 +7,10 @@ class Profile::APITokenComponent < ApplicationComponent private def procedures_to_allow_options - @api_token.procedures_to_allow.map { ["#{_1.id} – #{_1.libelle}", _1.id] } + @api_token.targetable_procedures.map { ["#{_1.id} – #{_1.libelle}", _1.id] } end def procedures_to_allow_select_options - { selected: @api_token.procedures_to_allow.first&.id } + { selected: @api_token.targetable_procedures.first&.id } end end diff --git a/app/components/profile/api_token_component/api_token_component.html.haml b/app/components/profile/api_token_component/api_token_component.html.haml index c4d064fc0..f27e2ba8b 100644 --- a/app/components/profile/api_token_component/api_token_component.html.haml +++ b/app/components/profile/api_token_component/api_token_component.html.haml @@ -40,13 +40,13 @@ = button_to t('.delete'), @api_token, method: :patch, params: { api_token: { disallow_procedure_id: procedure.id } }, class: "fr-btn fr-btn--secondary" .fr-card__end - = form_for @api_token, namespace: dom_id(@api_token, :allowed_procedures), html: { class: 'form form-ds-fr-white mb-3', data: { turbo: true } } do |f| - = f.label :allowed_procedure_ids do + = form_for @api_token, namespace: dom_id(@api_token, :allowed_procedures), html: { class: 'mb-3', data: { turbo: true } } do |f| + = f.label :allowed_procedure_ids, class: 'fr-label' do = t('.action_choice') - @api_token.allowed_procedures.each do |procedure| = f.hidden_field :allowed_procedure_ids, value: procedure.id, multiple: true, id: dom_id(procedure, :allowed_procedure) .flex.justify-between.align-center{ 'data-turbo-force': :server } - = f.select :allowed_procedure_ids, procedures_to_allow_options, {prompt: t('.prompt_choose_procedure')}, { class: 'no-margin width-66 small', name: "api_token[allowed_procedure_ids][]" } + = f.select :allowed_procedure_ids, procedures_to_allow_options, {prompt: t('.prompt_choose_procedure')}, { class: 'fr-select ', name: "api_token[allowed_procedure_ids][]" } = f.button type: :submit, class: "fr-btn fr-btn--secondary" do = t('.add')