-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11193 from demarches-simplifiees/fix-10788
ETQ instructeur, sur la liste des démarches, je peux accéder directement à une démarche via une dropdown
- Loading branch information
Showing
12 changed files
with
162 additions
and
7 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
app/components/instructeurs/select_procedure_drop_down_list_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class Instructeurs::SelectProcedureDropDownListComponent < Dsfr::InputComponent | ||
def initialize(procedures:) | ||
@procedures = procedures | ||
end | ||
|
||
def render? | ||
@procedures.count > 3 | ||
end | ||
|
||
def react_props | ||
{ | ||
items:, | ||
placeholder: t('.placeholder'), | ||
name: "procedure_id", | ||
id: 'select-procedure-drop-down-list', | ||
'aria-describedby': 'select-procedure-drop-down-list-label', | ||
form: 'select-procedure-drop-down-list-component', | ||
data: { no_autosubmit: 'input blur', no_autosubmit_on_empty: 'true', autosubmit_target: 'input' } | ||
} | ||
end | ||
|
||
def items | ||
@procedures.map { ["n°#{_1.id} - #{_1.libelle}", _1.id] } | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
...elect_procedure_drop_down_list_component/select_procedure_drop_down_list_component.en.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
en: | ||
label: Direct access | ||
placeholder: Select a procedure |
4 changes: 4 additions & 0 deletions
4
...elect_procedure_drop_down_list_component/select_procedure_drop_down_list_component.fr.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
fr: | ||
label: Accès direct | ||
placeholder: Sélectionner une démarche |
17 changes: 17 additions & 0 deletions
17
...ct_procedure_drop_down_list_component/select_procedure_drop_down_list_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
= form_with url: url_for([:select_procedure, :instructeur, :procedures]), | ||
class: 'ml-auto', | ||
id: 'select-procedure-drop-down-list-component', | ||
data: { turbo: false, controller: 'autosubmit' } do | ||
|
||
.flex.align-center | ||
= label_tag :procedure_id, t('.label'), class: 'fr-label font-weight-bold fr-mr-2w', id: 'select-procedure-drop-down-list-label', for: 'select-procedure-drop-down-list' | ||
%react-fragment | ||
= render ReactComponent.new "ComboBox/SingleComboBox", **react_props | ||
|
||
%input.hidden{ | ||
type: 'submit', | ||
formmethod: 'get', | ||
formaction: url_for([:select_procedure, :instructeur, :procedures]), | ||
formnovalidate: 'true', | ||
data: { autosubmit_target: 'submitter' } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -461,6 +461,7 @@ | |
collection do | ||
get 'order_positions' | ||
patch 'update_order_positions' | ||
get 'select_procedure' | ||
end | ||
end | ||
|
||
|
37 changes: 37 additions & 0 deletions
37
spec/components/instructeurs/select_procedure_drop_down_list_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe Instructeurs::SelectProcedureDropDownListComponent, type: :component do | ||
subject do | ||
render_inline(described_class.new(procedures:)) | ||
end | ||
|
||
let(:procedures) { | ||
[ | ||
create(:procedure, libelle: "Procedure importante", id: 1001), | ||
create(:procedure, libelle: "Procedure facile", id: 1002), | ||
create(:procedure, libelle: "Procedure terminée", id: 1003), | ||
create(:procedure, libelle: "Procedure terminée 2", id: 1004), | ||
create(:procedure, libelle: "Procedure terminée 3", id: 1005) | ||
] | ||
} | ||
|
||
it "renders the label" do | ||
expect(subject).to have_text("Accès direct") | ||
end | ||
|
||
let(:react_component) { page.find('react-component') } | ||
let(:react_props_items) { JSON.parse(react_component['props']) } | ||
|
||
it "renders the procedures" do | ||
subject | ||
expect(react_props_items["items"]).to eq([ | ||
["n°1001 - Procedure importante", 1001], | ||
["n°1002 - Procedure facile", 1002], | ||
["n°1003 - Procedure terminée", 1003], | ||
["n°1004 - Procedure terminée 2", 1004], | ||
["n°1005 - Procedure terminée 3", 1005] | ||
]) | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
spec/components/previews/instructeurs/select_procedure_drop_down_list_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class Instructeurs::SelectProcedureDropDownListComponentPreview < ViewComponent::Preview | ||
def default | ||
@procedures = Procedure.limit(10) | ||
render(Instructeurs::SelectProcedureDropDownListComponent.new(procedures: @procedures)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters