-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display tree structure of a group
- Loading branch information
seb-by-ouidou
committed
Feb 2, 2024
1 parent
5e7f3c6
commit 0d96463
Showing
21 changed files
with
137 additions
and
32 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...nents/groupe_gestionnaire/groupe_gestionnaire_tree_structures/tree_structure_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,8 @@ | ||
class GroupeGestionnaire::GroupeGestionnaireTreeStructures::TreeStructureComponent < ApplicationComponent | ||
include ApplicationHelper | ||
|
||
def initialize(parent:, children:) | ||
@parent = parent | ||
@children = children | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
..._gestionnaire_tree_structures/tree_structure_component/tree_structure_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,6 @@ | ||
= @parent.name | ||
- unless @children.empty? | ||
%ul | ||
- @children.each do |parent, children| | ||
%li | ||
= render(GroupeGestionnaire::GroupeGestionnaireTreeStructures::TreeStructureComponent.new(parent: parent, children: children)) |
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/views/gestionnaires/groupe_gestionnaire_administrateurs/create.turbo_stream.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
- if @administrateur.present? | ||
= turbo_stream.update 'administrateurs' do | ||
= render GroupeGestionnaire::GroupeGestionnaireAdministrateurs::AdministrateurComponent.with_collection(@groupe_gestionnaire.administrateurs.order('users.email'), groupe_gestionnaire: @groupe_gestionnaire) | ||
= turbo_stream.replace "new_administrateur", partial: 'add_admin_form', locals: { groupe_gestionnaire: @groupe_gestionnaire } | ||
= turbo_stream.replace "new_administrateur", partial: 'add_administrateur_form', locals: { groupe_gestionnaire: @groupe_gestionnaire } | ||
= turbo_stream.focus 'administrateur_email' |
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/views/gestionnaires/groupe_gestionnaire_children/create.turbo_stream.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
- if @child.present? | ||
= turbo_stream.update 'children' do | ||
= render GroupeGestionnaire::GroupeGestionnaireChildren::ChildComponent.with_collection(@groupe_gestionnaire.children, groupe_gestionnaire: @groupe_gestionnaire) | ||
= turbo_stream.replace "new_child", partial: 'add_admin_form', locals: { groupe_gestionnaire: @groupe_gestionnaire } | ||
= turbo_stream.replace "new_child", partial: 'add_child_form', locals: { groupe_gestionnaire: @groupe_gestionnaire } | ||
= turbo_stream.focus 'groupe_gestionnaire_name' |
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/views/gestionnaires/groupe_gestionnaire_gestionnaires/create.turbo_stream.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
- if @gestionnaire.present? | ||
= turbo_stream.update 'gestionnaires' do | ||
= render GroupeGestionnaire::GroupeGestionnaireGestionnaires::GestionnaireComponent.with_collection(@groupe_gestionnaire.gestionnaires.order('users.email'), groupe_gestionnaire: @groupe_gestionnaire) | ||
= turbo_stream.replace "new_gestionnaire", partial: 'add_admin_form', locals: { groupe_gestionnaire: @groupe_gestionnaire } | ||
= turbo_stream.replace "new_gestionnaire", partial: 'add_gestionnaire_form', locals: { groupe_gestionnaire: @groupe_gestionnaire } | ||
= turbo_stream.focus 'gestionnaire_email' |
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
14 changes: 14 additions & 0 deletions
14
app/views/gestionnaires/groupe_gestionnaires/tree_structure.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,14 @@ | ||
= render partial: 'gestionnaires/breadcrumbs', | ||
locals: { steps: [['Groupes gestionnaire', gestionnaire_groupe_gestionnaires_path], | ||
["#{@groupe_gestionnaire.name.truncate_words(10)}", gestionnaire_groupe_gestionnaire_path(@groupe_gestionnaire)], | ||
['Arborescence']], preview: false } | ||
|
||
.fr-container | ||
%h1 Arborescence de « #{@groupe_gestionnaire.name} » | ||
|
||
.fr-mt-4w | ||
%ul | ||
- @tree_structure.each do |parent, children| | ||
%li | ||
= render(GroupeGestionnaire::GroupeGestionnaireTreeStructures::TreeStructureComponent.new(parent: parent, children: children)) | ||
|
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
16 changes: 16 additions & 0 deletions
16
.../groupe_gestionnaire/groupe_gestionnaire_tree_structures/tree_structure_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,16 @@ | ||
RSpec.describe GroupeGestionnaire::GroupeGestionnaireTreeStructures::TreeStructureComponent, type: :component do | ||
let(:component) do | ||
described_class.new( | ||
parent: groupe_gestionnaire, | ||
children: { child_groupe_gestionnaire => {} } | ||
) | ||
end | ||
let(:gestionnaire) { create(:gestionnaire) } | ||
let!(:groupe_gestionnaire) { create(:groupe_gestionnaire, gestionnaires: [gestionnaire]) } | ||
let!(:child_groupe_gestionnaire) { create(:groupe_gestionnaire, ancestry: "/#{groupe_gestionnaire.id}/", gestionnaires: []) } | ||
|
||
subject { render_inline(component).to_html } | ||
|
||
it { is_expected.to include(groupe_gestionnaire.name) } | ||
it { is_expected.to include(child_groupe_gestionnaire.name) } | ||
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
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