Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation de la bannière jaune pour les rdv à renseigner #4907

Open
wants to merge 6 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/controllers/admin/agent_agendas_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Admin::AgentAgendasController < AgentAuthController
def show
@hide_rdv_a_renseigner_in_main_layout = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool de supprimer ça 👍

@agent = Agent.find(params[:id])
authorize(AgentAgenda.new(agent: @agent, organisation: current_organisation), policy_class: Agent::AgentAgendaPolicy)
@status = params[:status]
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/rdv_wizard_steps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class Admin::RdvWizardStepsController < AgentAuthController
include RdvsHelper

before_action :set_agent
before_action { @hide_rdv_a_renseigner_in_main_layout = true } # L'agent ne va pas interrompre sa création de rdv pour renseigner des rdvs

PERMITTED_PARAMS = [
:motif_id, :duration_in_min, :starts_at, :lieu_id, :context, :service_id,
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/admin/rdvs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ def index
end

def a_renseigner
@hide_rdv_a_renseigner_in_main_layout = true
skip_authorization # on fait un policy scope à la ligne suivante
@rdvs = policy_scope(current_agent.rdvs, policy_scope_class: Agent::RdvPolicy::Scope)
.past.where(status: "unknown")
@rdvs = policy_scope(current_agent.rdvs.a_renseigner, policy_scope_class: Agent::RdvPolicy::Scope)
.order({ starts_at: :desc }).page(page_number).per(20)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def access_rights_for_territory(territory)
end

def update_unknown_past_rdv_count!
update_column(:unknown_past_rdv_count, rdvs.status(:unknown_past).count) if persisted?
update_column(:unknown_past_rdv_count, rdvs.a_renseigner.count) if persisted?
end

# This method is called when calling #current_agent on a controller action that is automatically generated
Expand Down
1 change: 1 addition & 0 deletions app/models/rdv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def nested_lieu_attributes
end
}
scope :requires_ants_predemande_number, -> { joins(:motif).merge(Motif.requires_ants_predemande_number) }
scope :a_renseigner, -> { past.where(status: "unknown").where("starts_at > ?", 2.weeks.ago) }

# Delegations
delegate :domain, to: :organisation
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/agent_agendas/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
- else
| Agenda de #{@agent.full_name_and_service}

- content_for :breadcrumb do
= render "layouts/rdv_a_renseigner", agent: current_agent, organisation: current_organisation

#calendar[
data-default-date-json="#{@date&.to_json}"
data-agent-id="#{@agent.id}"
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/_agent_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ header.header.bg-white
i.fa.fa-bars.text-primary-blue
#navbarSupportedContent.collapse.navbar-collapse
ul.navbar-nav.ml-auto.align-items-start.align-items-lg-center
= render "layouts/rdv_a_renseigner", organisation: defined?(current_organisation) && current_organisation
li.list-inline-item
#js-headway-anchor.btn.text-primary-blue.link-dsfr.d-flex.justify-content-center
| Nouveautés
Expand Down
17 changes: 6 additions & 11 deletions app/views/layouts/_rdv_a_renseigner.html.slim
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
- agent_already_busy = controller.action_name.in?(["new", "create", "edit", "update"]) # Un agent qui remplit un formulaire ne va pas interrompre son action pour renseigner des rdvs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense aussi que ça n’est plus pertinent maintenant que le message est dans le header, ça serait même un peu perturbant de le voir apparaître - disparaître

- if organisation.present? && agent && agent.unknown_past_rdv_count > 0 \
&& !agent_already_busy \
&& !agent.conseiller_numerique? # See https://github.com/betagouv/rdv-solidarites.fr/issues/2245
= link_to a_renseigner_admin_organisation_rdvs_path(organisation)
.navbar.alert-warning.p-2
div.mr-4
.fa.fa-exclamation-triangle.alert-link>
span.ml-1.alert-link = t(".unknown_past_rdv_count", count: agent.unknown_past_rdv_count )
button.btn.rdv-status-unknown_past.float-right = t(".link_to_unknown_past_rdv")
/ locals(organisation: nil)
- if current_agent.unknown_past_rdv_count > 0 && !current_agent.conseiller_numerique? # See https://github.com/betagouv/rdv-solidarites.fr/issues/2245
li.list-inline-item.fr-mr-2w
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion tout à fait minime et absolument pas bloquante: on pourrait introduire un alias de unknown_past_rdv_count appelé rdv_a_renseigner_count pour aligner les API dans ce fichier.
(on pourrait aussi carrément renommer la colonne mais c’est beaucoup de travail)

= link_to a_renseigner_admin_organisation_rdvs_path(organisation || current_agent.rdvs.a_renseigner.first.organisation_id), class: "btn text-primary-blue link-dsfr" do
span.fr-icon--sm.fr-mr-1v.fr-icon-warning-fill[aria-hidden="true"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note à moi-même : le cas sans orga passée en param se produit sur le layout config de territoire. Avant cette PR l’info des RDV à renseigner n’apparaissait pas dans cette interface.

image

= "#{current_agent.unknown_past_rdv_count} RDV à renseigner"
2 changes: 0 additions & 2 deletions app/views/layouts/application_agent.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ html lang="fr"
= render "layouts/left_menu"
main.content-page[style="flex-grow: 1;"]
.content
- unless @hide_rdv_a_renseigner_in_main_layout
= render "layouts/rdv_a_renseigner", agent: current_agent, organisation: defined?(current_organisation) ? current_organisation : nil
.fr-mx-2w= render "layouts/flash_dsfr"
.container-fluid
- if content_for :title
Expand Down
3 changes: 1 addition & 2 deletions spec/features/agents/renseigner_rdv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

it "works from the main page", js: true do
visit root_path
expect(page).to have_content "Vous avez 1 rendez-vous à renseigner"
click_link "Voir ces RDV"
click_link "1 RDV à renseigner"
find(".fr-btn", text: "Rendez-vous honoré").click
sleep 1 # Pour attendre que la requête ajax se finisse
expect(page).to have_content("Rendez-vous mis à jour")
Expand Down
Loading