feat: US4.3.7.1 init manage gestionnaires of a group

This commit is contained in:
seb-by-ouidou 2023-09-28 15:45:39 +00:00
parent e79d81ed23
commit ea7a5e6761
27 changed files with 302 additions and 56 deletions

View file

@ -0,0 +1,42 @@
class GroupeGestionnaire::GroupeGestionnaireGestionnaires::GestionnaireComponent < ApplicationComponent
include ApplicationHelper
def initialize(groupe_gestionnaire:, gestionnaire:)
@groupe_gestionnaire = groupe_gestionnaire
@gestionnaire = gestionnaire
end
def email
if @gestionnaire == current_gestionnaire
"#{@gestionnaire.email} (Cest vous !)"
else
@gestionnaire.email
end
end
def created_at
try_format_datetime(@gestionnaire.created_at)
end
def registration_state
@gestionnaire.registration_state
end
def remove_button
if is_there_at_least_another_active_admin?
button_to 'Retirer',
gestionnaire_groupe_gestionnaire_gestionnaire_path(@groupe_gestionnaire, @gestionnaire),
method: :delete,
class: 'button',
form: { data: { turbo: true, turbo_confirm: "Retirer « #{@gestionnaire.email} » des gestionnaires de « #{@groupe_gestionnaire.name} » ?" } }
end
end
def is_there_at_least_another_active_admin?
if @gestionnaire.active?
@groupe_gestionnaire.gestionnaires.count(&:active?) > 1
else
@groupe_gestionnaire.gestionnaires.count(&:active?) >= 1
end
end
end

View file

@ -0,0 +1,5 @@
%tr{ id: dom_id(@gestionnaire) }
%td= email
%td= created_at
%td= registration_state
%td= remove_button