Skip to content

Commit

Permalink
Désactivation des boutons de génération des décisions d'attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
tnicolas1 committed Nov 18, 2024
1 parent d9b9e7d commit ae25732
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
10 changes: 7 additions & 3 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def progress_badge(count, total, **args)
end
end

def attributive_decisions_download_button
def attributive_decisions_download_button(disabled, title)
return unless current_establishment.with_attributive_decisions?(selected_school_year)

count = current_establishment.schoolings.with_attributive_decisions
Expand All @@ -25,17 +25,21 @@ def attributive_decisions_download_button
school_year_establishment_download_attributive_decisions_path(selected_school_year, current_establishment),
method: :post,
class: "fr-btn fr-btn--primary",
disabled: disabled,
title: title,
data: { turbo: false }
)
end

def attributive_decisions_reissue_button
def attributive_decisions_reissue_button(disabled, title)
return unless current_establishment.with_attributive_decisions?(selected_school_year)

button_to "Rééditer les décisions d'attribution",
school_year_establishment_reissue_attributive_decisions_path(selected_school_year, current_establishment),
method: :post,
class: "fr-btn fr-btn--tertiary"
class: "fr-btn fr-btn--tertiary",
disabled: disabled,
title: title
end

def attributive_decisions_generation_form
Expand Down
4 changes: 0 additions & 4 deletions app/models/establishment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ def contract_type
end
end

def missing_attributive_decisions?(school_year)
schoolings_for_school_year(school_year).without_attributive_decisions.any?
end

def with_attributive_decisions?(school_year)
schoolings_for_school_year(school_year).with_attributive_decisions.any?
end
Expand Down
10 changes: 6 additions & 4 deletions app/views/classes/_attributive_decisions_panel.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
%p Les décisions d'attribution sont en train d'être éditées, veuillez rafraichir la page dans quelques minutes. Vous pouvez commencer à remplir des coordonnées bancaires ou des PFMPs pendant ce temps.
- else
.buttons-group
- if current_establishment.missing_attributive_decisions?(selected_school_year)
= attributive_decisions_generation_form
- disabled = current_user.director?
- title = disabled ? t("panels.attributive_decisions.not_validatable") : ""
- if current_establishment.with_attributive_decisions?(selected_school_year)
= attributive_decisions_reissue_button(disabled, title)
- else
= attributive_decisions_generation_form(disabled, title)
= attributive_decisions_download_button
- if current_establishment.with_attributive_decisions?(selected_school_year) && current_user.director?
= attributive_decisions_reissue_button
2 changes: 1 addition & 1 deletion app/views/home/_attributive_decision_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
= t("panels.attributive_decisions.confirm_director").html_safe
.fr-text--sm.fr-mt-1w= confirmed_director_information

= form.submit t("panels.attributive_decisions.generate", count: count), class: "fr-btn fr-btn--secondary"
= form.submit t("panels.attributive_decisions.generate", count: count), class: "fr-btn fr-btn--secondary", disabled: disabled, title: title
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ fr:
not_director: &not_director_error Vous devez être chef d'établissement
panels:
attributive_decisions:
not_validatable: "Vous ne pouvez pas valider cette demande de paiement car vous n'êtes pas directeur de l'établissement."
download:
one: Télécharger la décision d'attribution pour vérification et distribution
other: Télécharger %{count} décisions d'attribution pour vérification et distribution
Expand Down

0 comments on commit ae25732

Please sign in to comment.