Skip to content

Commit

Permalink
Merge branch 'production' into chore/upgrade-slim-5
Browse files Browse the repository at this point in the history
  • Loading branch information
adipasquale authored Jan 6, 2025
2 parents 7ac9291 + 02c05fb commit fa5172f
Show file tree
Hide file tree
Showing 37 changed files with 231 additions and 199 deletions.
4 changes: 2 additions & 2 deletions app/controllers/admin/creneaux_search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def form_submitted?

def prepare_form
@motifs = Agent::MotifPolicy::Scope.apply(current_agent, current_organisation.motifs).active.ordered_by_name
@services = Service.where(id: @motifs.pluck(:service_id).uniq)
@services = Service.where(id: @motifs.map(&:service_id).uniq)
@form.service_id = @services.first.id if @services.count == 1
@teams = current_organisation.territory.teams
@teams = Agent::TeamPolicy::Scope.apply(current_agent, current_territory.teams)
@agents = policy_scope(Agent, policy_scope_class: Agent::AgentPolicy::Scope)
.joins(:organisations).where(organisations: { id: current_organisation.id })
.complete.active.ordered_by_last_name
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/visioplainte/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def reset
return unless ENV["VISIOPLAINTE_API_KEY"].start_with?("visioplainte-staging-api-key-")
return unless ENV["FRANCECONNECT_HOST"] == "fcp.integ01.dev-franceconnect.fr"

territory = Territory.find_by(name: Territory::VISIOPLAINTE_NAME)
territory = Territory.visioplainte.first

territory.organisations.find_each do |organisation|
organisation.plage_ouvertures.delete_all
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/visioplainte/creneaux_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def prochain
end

def self.find_motif
Motif.joins(organisation: :territory).where(territories: { name: Territory::VISIOPLAINTE_NAME })
Motif.joins(organisation: :territory).merge(Territory.visioplainte)
.joins(:service).find_by(service: { name: GENDARMERIE_SERVICE_NAME })
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/visioplainte/guichets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Api::Visioplainte::GuichetsController < Api::Visioplainte::BaseController
def self.guichets
Agent.joins(roles: { organisation: :territory }).where(territories: { name: Territory::VISIOPLAINTE_NAME })
Agent.joins(roles: { organisation: :territory }).merge(Territory.visioplainte)
.where(roles: { access_level: AgentRole::ACCESS_LEVEL_INTERVENANT })
.joins(:services).where(services: { name: GENDARMERIE_SERVICE_NAME })
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/visioplainte/rdvs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def find_rdv
end

def authorized_rdv_scope
Rdv.joins(organisation: :territory).where(territories: { name: Territory::VISIOPLAINTE_NAME })
Rdv.joins(organisation: :territory).merge(Territory.visioplainte)
end

def motif
Expand Down
6 changes: 3 additions & 3 deletions app/form_models/agent_creneaux_search_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class AgentCreneauxSearchForm
validates :organisation_id, :motif, presence: true

def organisation
Organisation.find_by(id: organisation_id)
Organisation.find_by(id: organisation_id) if organisation_id.present?
end

def service
Service.find_by(id: service_id)
Service.find_by(id: service_id) if service_id.present?
end

def motif
organisation.motifs.find_by(id: motif_id)
organisation.motifs.find_by(id: motif_id) if motif_id.present?
end

def users
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/stylesheets/components/_utilities_dsfr.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
color: var(--text-title-grey);
}

.rdv-color-text-default-grey {
color: var(--text-default-grey);
}

.rdv-font-size-1-6rem {
font-size: 1.6rem;
}
Expand Down
5 changes: 5 additions & 0 deletions app/models/territory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Territory < ApplicationRecord
where(id: Organisation.with_upcoming_rdvs.distinct.select(:territory_id))
}
scope :ordered_by_name, -> { order(Arel.sql("unaccent(LOWER(territories.name))")) }
scope :visioplainte, -> { where(name: VISIOPLAINTE_NAME) }

## -

Expand Down Expand Up @@ -102,6 +103,10 @@ def cn?
name == CNFS_NAME
end

def visioplainte?
name == VISIOPLAINTE_NAME
end

def sectorized?
sectors.joins(:attributions).any? && motifs.active.sectorized.any?
end
Expand Down
3 changes: 3 additions & 0 deletions app/services/creneaux_search/calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def plage_ouvertures_for(motif, lieu, datetime_range, agents)
.merge(motif.plage_ouvertures)
.in_range(datetime_range)
.includes(:agent)
scope = scope.includes(:organisation, organisation: :territory) if motif.organisation.territory.visioplainte?
scope = scope.where(agent: agents) if agents&.any?
scope = scope.where(lieu: lieu) if lieu.present?
scope
Expand Down Expand Up @@ -173,6 +174,8 @@ def absence_out_of_range?(absence)
end

def busy_times_from_off_days
return [] if @plage_ouverture.organisation.territory.visioplainte?

OffDays.all_in_date_range(range).map do |off_day|
BusyTime.new(off_day.beginning_of_day, off_day.end_of_day)
end
Expand Down
7 changes: 4 additions & 3 deletions app/views/admin/absences/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- else
= t(".create_absence_for", full_name: @agent.full_name_or_email)

.alert.alert-dismissible.alert-info
i.fa.fa-info-circle
|< Les jours fériés sont automatiquement considérés comme indisponibles.
- unless current_territory.visioplainte?
.alert.alert-dismissible.alert-info
i.fa.fa-info-circle
|< Les jours fériés sont automatiquement considérés comme indisponibles.
12 changes: 10 additions & 2 deletions app/views/admin/agent_agendas/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@
- content_for :breadcrumb do
= render "layouts/rdv_a_renseigner", agent: current_agent, organisation: current_organisation

ruby:
event_sources = [
admin_api_agenda_rdvs_path(agent_id: @agent, organisation_id: current_organisation.id, format: :json),
admin_api_agenda_absences_path(agent_id: @agent, organisation_id: current_organisation.id, format: :json),
admin_api_agenda_plage_ouvertures_path(agent_id: @agent, organisation_id: current_organisation.id, in_background: true, format: :json),
]
event_sources.push(OffDays.to_full_calendar_array) unless current_territory.visioplainte?

#calendar[
data-default-date-json="#{@date&.to_json}"
data-agent-id="#{@agent.id}"
data-selected-event-id="#{@selected_event_id}"
data-organisation-id="#{@organisation.id}"
data-display-saturdays="#{current_agent.display_saturdays}"
data-display-sundays="#{current_territory.name == Territory::VISIOPLAINTE_NAME}"
data-event-sources-json="#{[admin_api_agenda_absences_path(agent_id: @agent, organisation_id: current_organisation.id, format: :json), admin_api_agenda_rdvs_path(agent_id: @agent, organisation_id: current_organisation.id, format: :json), admin_api_agenda_plage_ouvertures_path(agent_id: @agent, organisation_id: current_organisation.id, in_background: true, format: :json), OffDays.to_full_calendar_array].to_json}"
data-display-sundays="#{current_territory.visioplainte?}"
data-event-sources-json="#{event_sources.to_json}"
data-sign-in-path="#{new_agent_session_path}"
]
.mt-3.flex-grow-1.text-right
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/territories/agents/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ h1
= t(".agent_teams_legend")
= simple_form_for @agent, url: update_teams_admin_territory_agent_path(current_territory, @agent) do |f|
.card-body
= f.input :team_ids, collection: current_territory.teams.ordered_by_name,
= f.input :team_ids, collection: Agent::TeamPolicy::Scope.apply(current_agent, current_territory.teams).ordered_by_name,
label: t(".teams"),
label_method: :name,
input_html: { \
Expand Down
2 changes: 1 addition & 1 deletion app/views/common/_recurrence.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

.weekly-select
- weekdays = { Lundi: "monday", Mardi: "tuesday", Mercredi: "wednesday", Jeudi: "thursday", Vendredi: "friday", Samedi: "saturday" }
- weekdays[:Dimanche] = "sunday" if current_territory.name == Territory::VISIOPLAINTE_NAME
- weekdays[:Dimanche] = "sunday" if current_territory.visioplainte?
= n.input :on, as: :check_boxes, label: "Répéter les", collection: weekdays, include_blank: false, input_html: { data: { target: "recurrence.on", action: "recurrence#updateRecurrence" }, class: "js-recurrence-on js-recurrence-input" }

.monthly-select.form-group
Expand Down
7 changes: 4 additions & 3 deletions app/views/search/_banner.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
section.py-2.rdv-background-color-flat-blue-ecume
section.py-2.rdv-background-color-alt-blue-ecume
.fr-container
h1.mb-3.rdv-color-white
= render(current_domain.search_banner_template_name, context: context)
.fr-col-12.fr-col-lg-10.fr-col-offset-lg-1
h1.fr-mb-3w.rdv-color-active-blue
= render(current_domain.search_banner_template_name, context: context)
62 changes: 25 additions & 37 deletions app/views/search/_lieu_selection.html.slim
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
.fr-container
= render "search/selected_motif_recap", context: context
- if context.shown_lieux.empty?
= render "search/nothing_to_show", context: context
- else
h3.rdv-font-weight-700 = t(".select_lieu")
p = t(".lieu_available", count: context.shown_lieux.count)
= render "search/selected_motif_recap", context: context
- if context.shown_lieux.empty?
= render "search/nothing_to_show", context: context
- else
h3 = t(".select_lieu")
p = t(".lieu_available", count: context.shown_lieux.count)
ul.fr-raw-list
- context.next_availability_by_lieux.each do |lieu, next_availability|
.card.mb-3 class=("card-hoverable" if next_availability)
.card-body
.row
.col-md
h4.card-title.mb-0.mt-0.rdv-color-text-default-success.rdv-font-weight-700= lieu.name
.mb-3.mt-0.rdv-color-text-default-success.rdv-font-weight-700.larger=lieu.organisation.name
.card-subtitle= lieu.address
.card-subtitle= context.service.name
.col-md.align-self-center.pt-3.pt-md-0.position-static
- motif = next_availability.motif
- if motif.restriction_for_rdv.blank?
= link_to prendre_rdv_path(context.query_params.merge(lieu_id: lieu.id, date: next_availability.starts_at)), class: "d-block stretched-link" do
.row
.col
= t(".next_availability")
br
strong= l(next_availability.starts_at, format: :human)
.col-auto.align-self-center
i.fa.fa-chevron-right
- else
= link_to prendre_rdv_path(context.query_params.merge(lieu_id: lieu.id, date: next_availability.starts_at)), class: "d-block stretched-link", "data-turbolinks": false, data: { toggle: "modal", target: "#js-rdv-restriction-motif#{lieu.id}" } do
.row
.col
= t(".next_availability")
br
strong= l(next_availability.starts_at, format: :human)
.col-auto.align-self-center
i.fa.fa-chevron-right
= render "/common/modal", id: "js-rdv-restriction-motif#{lieu.id}" , title: "À lire avant de prendre un rendez-vous", confirm_path: prendre_rdv_path(context.query_params.merge(lieu_id: lieu.id, date: next_availability.starts_at)) do
= restriction_for_rdv_to_html(motif)
- motif = next_availability.motif
- if motif.restriction_for_rdv.blank?
- link = link_to "#{lieu.name} - #{lieu.address}", prendre_rdv_path(context.query_params.merge(lieu_id: lieu.id, date: next_availability.starts_at))
- else
- link = link_to "#{lieu.name} - #{lieu.address}", prendre_rdv_path(context.query_params.merge(lieu_id: lieu.id, date: next_availability.starts_at)), "data-turbolinks": false, data: { toggle: "modal", target: "#js-rdv-restriction-motif#{lieu.id}" }
= render "/common/modal", id: "js-rdv-restriction-motif#{lieu.id}", title: "À lire avant de prendre un rendez-vous", confirm_path: prendre_rdv_path(context.query_params.merge(lieu_id: lieu.id, date: next_availability.starts_at)) do
= restriction_for_rdv_to_html(motif)
li.fr-card.fr-enlarge-link.fr-card--lg.fr-card--horizontal.fr-mb-3w
.fr-card__body
.fr-card__content
.fr-card__title = link
p.fr-card__desc = lieu.organisation.name
.fr-card__end
.fr-card__detail
p.fr-text.rdv-color-text-default-grey
span.fr-icon-calendar-2-fill.fr-mr-1w
= "#{t('.next_availability')} "
strong= l(next_availability.starts_at, format: :human)
52 changes: 34 additions & 18 deletions app/views/search/_motif_selection.html.slim
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
.fr-container
.card
.card-body
= link_to path_to_service_selection(params), class: "d-block stretched-link", title: "Retour à la selection du service" do
.row
.col-auto.align-self-center
i.fa.fa-chevron-left
.col
h2.fr-pb-0.fr-mb-0 = context.service.name
.fr-container
- if context.unique_motifs_by_name_and_location_type.empty?
= render "search/nothing_to_show", context: context
- else
h2.rdv-font-weight-700 Sélectionnez le motif de votre RDV&nbsp;:
.card
.card-body
= link_to path_to_service_selection(params), class: "d-block stretched-link", title: "Retour à la sélection du service" do
.row
.col-auto.align-self-center
i.fa.fa-chevron-left
.col
h2.fr-pb-0.fr-mb-0 = context.service.name
- if context.unique_motifs_by_name_and_location_type.empty?
= render "search/nothing_to_show", context: context
- else
h2 Sélectionnez le motif de votre RDV&nbsp;:
ul.fr-raw-list
- context.unique_motifs_by_name_and_location_type.each do |motif|
.card.card-hoverable.mb-3
= link_to prendre_rdv_path(context.query_params.merge(motif_name_with_location_type: motif.name_with_location_type)), class: "rdv-background-image-none" do
= render "search/motif_selection_card", motif: motif
= render "search/referent_booking_card", context: context
li.fr-card.fr-enlarge-link.fr-card--horizontal.fr-mb-2w
.fr-card__body
.fr-card__content
.fr-card__title
= link_to motif.name, prendre_rdv_path(context.query_params.merge(motif_name_with_location_type: motif.name_with_location_type))
.fr-card__start
ul.fr-badges-group
- case motif.location_type
- when "phone"
li.fr-badge.fr-badge--blue-cumulus.fr-icon-phone-fill.fr-badge--icon-left = motif.human_attribute_value(:location_type)
- when "home"
li.fr-badge.fr-badge--blue-cumulus.fr-icon-home-4-fill.fr-badge--icon-left = motif.human_attribute_value(:location_type)
- when "public_office"
li.fr-badge.fr-badge--blue-cumulus.fr-icon-building-fill.fr-badge--icon-left = motif.human_attribute_value(:location_type)
- when "visio"
li.fr-badge.fr-badge--blue-cumulus.fr-icon-mac-fill.fr-badge--icon-left = motif.human_attribute_value(:location_type)
- else
li.fr-badge.fr-badge--blue-cumulus = motif.human_attribute_value(:location_type)
- if motif.collectif?
li.fr-badge.fr-badge--purple-glycine.fr-icon-team-fill.fr-badge--icon-left = "RDV collectif"
= render "search/referent_booking_card", context: context
9 changes: 0 additions & 9 deletions app/views/search/_motif_selection_card.html.slim

This file was deleted.

12 changes: 6 additions & 6 deletions app/views/search/_organisation_card_subtitles.html.slim
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
- if organisation.website?
.card-subtitle.my-2
.fa.fa-earth-europe>
.fr-card__detail.fr-text--sm
span.fr-icon-global-fill.fr-mr-1w
= organisation.website
- if organisation.phone_number?
.card-subtitle.my-2
.fa.fa-phone>
.fr-card__detail.fr-text--sm
span.fr-icon-phone-fill.fr-mr-1w
= organisation.phone_number
- if organisation.email?
.card-subtitle.my-2
.fa.fa-envelope>
.fr-card__detail.fr-text--sm
span.fr-icon-mail-fill.fr-mr-1w
= organisation.email
37 changes: 17 additions & 20 deletions app/views/search/_organisation_selection.html.slim
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
.fr-container
= render "search/selected_motif_recap", context: context
- if context.next_availability_by_motifs_organisations.empty?
= render "search/nothing_to_show", context: context
- else
h3.rdv-font-weight-700 Sélectionnez la structure avec laquelle prendre RDV:
= render "search/selected_motif_recap", context: context
- if context.next_availability_by_motifs_organisations.empty?
= render "search/nothing_to_show", context: context
- else
h3 Sélectionnez la structure avec laquelle prendre RDV&nbsp;:
ul.fr-raw-list
- context.next_availability_by_motifs_organisations.each do |organisation, next_availability|
.card.mb-3 class="card-hoverable"
.card-body
.row
.col-md
h3.card-title.mb-3.mt-0.rdv-color-text-default-success.rdv-font-weight-700= organisation.name
li.fr-card.fr-enlarge-link.fr-card--horizontal.fr-mb-2w
.fr-card__body
.fr-card__content
.fr-card__title
= link_to organisation.name, prendre_rdv_path(context.query_params.merge(user_selected_organisation_id: organisation.id, date: next_availability.starts_at))
.fr-card__end
= render "search/organisation_card_subtitles", organisation: organisation
.col-md.align-self-center.pt-3.pt-md-0.position-static
= link_to prendre_rdv_path(context.query_params.merge(user_selected_organisation_id: organisation.id, date: next_availability.starts_at)), class: "d-block stretched-link" do
.row
.col
| Prochaine disponibilité le
br
strong= l(next_availability.starts_at, format: :human)
.col-auto.align-self-center
i.fa.fa-chevron-right
.fr-card__detail
p.fr-text.fr-mt-3w.rdv-color-text-default-grey
span.fr-icon-calendar-2-fill.fr-mr-1w
' Prochaine disponibilité le
strong= l(next_availability.starts_at, format: :human)
2 changes: 1 addition & 1 deletion app/views/search/_selected_motif_recap.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.card.card-hoverable
.card
.card-body
= link_to path_to_motif_selection(params), class: "d-block stretched-link", title: "Retour à la sélection du motif" do
.row
Expand Down
25 changes: 11 additions & 14 deletions app/views/search/_service_selection.html.slim
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
.fr-container
- if context.unique_motifs_by_name_and_location_type.empty?
= render "search/nothing_to_show", context: context
- else
h2.rdv-font-weight-700 Sélectionnez le service avec qui vous voulez prendre un RDV&nbsp;:
- unless context.invitation?
- context.services.each do |service|
.card.mb-3
= link_to prendre_rdv_path(context.query_params.merge(service_id: service.id)), class: "rdv-background-image-none" do
.card-body
.row
.col-md
h3.card-title.mb-3.mt-0.rdv-color-text-default-success.rdv-font-weight-700= service.name
= render "search/referent_booking_card", context: context
- if context.unique_motifs_by_name_and_location_type.empty?
= render "search/nothing_to_show", context: context
- else
h2 Sélectionnez le service avec qui vous voulez prendre un RDV&nbsp;:
- context.services.each do |service|
.fr-card.fr-enlarge-link.fr-card--horizontal.fr-mb-2w
.fr-card__body
.fr-card__content
.fr-card__title
= link_to service.name, prendre_rdv_path(context.query_params.merge(service_id: service.id))
= render "search/referent_booking_card", context: context
Loading

0 comments on commit fa5172f

Please sign in to comment.