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

Mgf 639 employers only #358

Open
wants to merge 3 commits into
base: review
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
29 changes: 17 additions & 12 deletions app/components/side_menu_component.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

class SideMenuComponent < ApplicationComponent
def initialize(candidatures_notice: ,
agreements_notice: ,
agreements_authorization: ,
delegate :employers_only?, to: :helpers

def initialize(candidatures_notice:,
agreements_notice:,
agreements_authorization:,
current_page_offers: false,
current_page_candidatures: false,
current_page_agreements: false)
Expand All @@ -13,43 +15,46 @@ def initialize(candidatures_notice: ,
@current_page_offers = current_page_offers
@current_page_candidatures = current_page_candidatures
@current_page_agreements = current_page_agreements

end

def link_options(menu_item)
link_options = {class: 'fr-sidemenu__link'}
link_options.merge!({:'aria-current'=>'page'}) if menu_item[:current_page]
link_options = { class: 'fr-sidemenu__link' }
link_options.merge!({ 'aria-current': 'page' }) if menu_item[:current_page]
link_options
end

def li_extra_class(menu_item)
menu_item[:current_page] ? "fr-sidemenu__item--active" : ""
menu_item[:current_page] ? 'fr-sidemenu__item--active' : ''
end

def before_render
@menu_collection = [
{
label: "Offres de stage",
label: 'Offres de stage',
path: helpers.dashboard_internship_offers_path,
notice: nil,
authorization: true,
current_page: @current_page_offers
},
}
]
# return if employers_only?

@menu_collection << [
{
label: "Candidatures",
label: 'Candidatures',
path: helpers.dashboard_candidatures_path,
notice: @candidatures_notice,
authorization: true,
current_page: @current_page_candidatures
},
{
label: "Conventions",
label: 'Conventions',
path: helpers.dashboard_internship_agreements_path,
notice: @agreements_notice,
authorization: @agreements_authorization,
current_page: @current_page_agreements
}
]
@menu_collection.flatten!
end

end
13 changes: 13 additions & 0 deletions app/front_assets/stylesheets/pages/home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,19 @@ p.fr-card__desc.std-height {

.fr-nav__link[aria-current] {
background-color: $blue-france-light;
.disabled_tab{
opacity: 0.5;
}
}

.disabled_tab{
background-color: $grey-975 !important;
opacity: 0.5;
.fr-card__content{
h3.fr-h4 {
color: grey
}
}
}

h1,
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def homepage?
current_page?(root_path)
end

def employers_only?
ENV.fetch('EMPLOYERS_ONLY', false) == 'true'
end

# def in_dashboard?
# request.path.include?('dashboard') || request.path.include?('tableau-de-bord')
# end
Expand Down
1 change: 1 addition & 0 deletions app/libs/services/api_requests_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Services
class ApiRequestsHelper
def get_request
# TODO: specific implementation not ok with inheritance !
uri = get_request_uri
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
Expand Down
2 changes: 1 addition & 1 deletion app/libs/services/immersion_facile.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Services
class ImmersionFacile < ApiRequestsHelper
IMMERSION_FACILE_ENDPOINT_URL = ENV['IMMERSION_FACILE_API_URL'] + '/search'
IMMERSION_FACILE_ENDPOINT_URL = "#{ENV['IMMERSION_FACILE_API_URL']}/search".freeze

# sample of json response : {
# [
Expand Down
9 changes: 4 additions & 5 deletions app/models/concerns/phone_computation.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module PhoneComputation
extend ActiveSupport::Concern

Expand All @@ -10,10 +9,10 @@ def compute_mobile_phone_prefix
return nil if phone.blank?

bare_prefix = phone[0..4]
french_prefix = %w(+3306 +3307 +2620 +5960 +5940 +6870 +6890)
french_prefix = %w[+3306 +3307 +2620 +5960 +5940 +6870 +6890]
return nil unless bare_prefix.in?(french_prefix)

bare_prefix.in?(%w(+3306 +3307)) ? '33' : bare_prefix[1..-2]
bare_prefix.in?(%w[+3306 +3307]) ? '33' : bare_prefix[1..-2]
end

def formatted_phone
Expand All @@ -25,7 +24,7 @@ def formatted_phone
def self.sanitize_mobile_phone_number(number, prefix = '')
return nil if number.blank?

thin_number = number.gsub(/[\s|;\,\.\:\(\)]/, '')
thin_number = number.gsub(/[\s|;,.:()]/, '')
if thin_number.match?(/\A\+(33|262|594|596|687|689)0[6|7]\d{8}\z/)
"#{prefix}#{thin_number[4..]}"
elsif thin_number.match?(/\A\+(33|262|594|596|687|689)[6|7]\d{8}\z/)
Expand Down Expand Up @@ -57,4 +56,4 @@ def clean_phone
self.phone = nil if phone == '+33'
end
end
end
end
12 changes: 10 additions & 2 deletions app/views/dashboard/internship_offers/_sidemenu.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@

- else
h1#fr-sidemenu-title.h3.text-dark Tableau de bord
= render SideMenuComponent.new(candidatures_notice: applications_notice,
- side_menu_parameters = {current_page_offers: true,
candidatures_notice: nil,
agreements_notice: nil,
agreements_authorization: false,
current_page_candidatures: false,
current_page_agreements: false }
- unless employers_only?
- side_menu_parameters.merge!(current_page_offers: current_page?(dashboard_internship_offers_path),
candidatures_notice: applications_notice,
agreements_notice: agreements_notice,
agreements_authorization: can?(:index, InternshipAgreement),
current_page_offers: current_page?(dashboard_internship_offers_path),
current_page_candidatures: current_page?(dashboard_candidatures_path),
current_page_agreements: current_page?(dashboard_internship_agreements_path))
= render SideMenuComponent.new(**side_menu_parameters)
23 changes: 15 additions & 8 deletions app/views/layouts/_footer.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ footer#footer.fr-footer role="contentinfo" data-controller='footer'
.fr-footer__top.fr-px-2w
.fr-container
.row
- klass = employers_only? ? 'disabled_tab' : ''
.col-12.col-md-3
.fr-footer__top-column
.title.fr-text--sm.fr-mb-1w = "Élèves"
.fr-py-1w = link_to "Trouver un stage", eleves_path, class: 'fr-raw-link fr-text--sm link'
.fr-py-1w = link_to "Découvrir le dispositif", eleves_path(anchor: 'discover'), class: 'fr-raw-link fr-text--sm link'
.fr-py-1w = link_to "Ressources utiles", eleves_path(anchor: 'resources'), class: 'fr-raw-link fr-text--sm link'
div class="title fr-text--sm fr-mb-1w #{klass}"
= "Élèves"
- path = employers_only? ? '#' : eleves_path
- path_anchor = employers_only? ? '#' : eleves_path(anchor: 'discover')
- path_resources = employers_only? ? '#' : eleves_path(anchor: 'resources')
.fr-py-1w = link_to "Trouver un stage", path, class: "fr-raw-link fr-text--sm link #{klass}"
.fr-py-1w = link_to "Découvrir le dispositif", path_anchor, class: "fr-raw-link fr-text--sm link #{klass}"
.fr-py-1w = link_to "Ressources utiles", path_resources, class: "fr-raw-link fr-text--sm link #{klass}"
.col-12.col-md-3
.fr-footer__top-column
.title.fr-text--sm.fr-mb-1w = "Professionnels"
Expand All @@ -16,10 +21,12 @@ footer#footer.fr-footer role="contentinfo" data-controller='footer'
.fr-py-1w = link_to "Ressources utiles", professionnels_path(anchor: 'resources'), class: 'fr-raw-link fr-text--sm link'
.col-12.col-md-3
.fr-footer__top-column
.title.fr-text--sm.fr-mb-1w = "Établissements scolaires"
.fr-py-1w = link_to "Suivez vos élèves", equipe_pedagogique_path, class: 'fr-raw-link fr-text--sm link'
.fr-py-1w = link_to "Découvrir le dispositif", equipe_pedagogique_path, class: 'fr-raw-link fr-text--sm link'
.fr-py-1w = link_to "Ressources utiles", equipe_pedagogique_path, class: 'fr-raw-link fr-text--sm link'
- path = employers_only? ? '#' : equipe_pedagogique_path
div class="title fr-text--sm fr-mb-1w #{klass}"
= "Établissements scolaires"
.fr-py-1w = link_to "Suivez vos élèves", path, class: "fr-raw-link fr-text--sm link #{klass}"
.fr-py-1w = link_to "Découvrir le dispositif", path, class: "fr-raw-link fr-text--sm link #{klass}"
.fr-py-1w = link_to "Ressources utiles", path, class: "fr-raw-link fr-text--sm link #{klass}"
.col-12.col-md-3
.fr-footer__top-column
.title.fr-text--sm.fr-mb-1w = "Référents"
Expand Down
5 changes: 3 additions & 2 deletions app/views/layouts/navbar/_nav.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- disabled_class = employers_only? ? 'disabled' : ''
.fr-header__tools
.fr-header__tools-links
ul.fr-links-group.custom-navbar
Expand All @@ -9,8 +10,8 @@
- active = current_page?(root_path) ? 'active' : ''
= link_to 'Accueil',
root_path,
class: "fr-link text-decoration-none mr-4 #{active}"
- if current_user.is_a?(Users::Student)
class: "fr-link text-decoration-none mr-4 #{active}"
- if current_user.is_a?(Users::Student) && !employers_only?
li
- active = current_page?(internship_offers_path) && !request.url.include?('origine=dashboard') ? 'active' : ''
= link_to 'Recherche',
Expand Down
21 changes: 14 additions & 7 deletions app/views/pages/home/_top_nav.html.slim
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
- disabled_class = employers_only? ? 'disabled_tab' : ''

.d-none.d-md-block.fr-px-2w
nav.fr-nav id="header-navigation" role="navigation" aria-label="Menu principal"
ul.fr-nav__list
li.fr-nav__item
- path = employers_only? ? '#' : root_path
= link_to 'Accueil',
root_path,
class: 'fr-nav__link',
class: "fr-nav__link #{disabled_class}",
aria: { current: (current_page?(root_path) ? 'page' : nil) }
li.fr-nav__item
- path = employers_only? ? '#' : eleves_path
= link_to 'Élèves',
eleves_path,
class: 'fr-nav__link',
path,
class: "fr-nav__link #{disabled_class}",
disabled: employers_only? ,
aria: { current: (current_page?(eleves_path) || current_page?(companies_path) || current_page?(recherche_entreprises_path) ? 'page' : nil) }
li.fr-nav__item
= link_to 'Professionnels',
professionnels_path,
class: 'fr-nav__link',
class: "fr-nav__link ",
aria: { current: (current_page?(professionnels_path) ? 'page' : nil) }
li.fr-nav__item
- path = employers_only? ? '#' : equipe_pedagogique_path
= link_to 'Équipes pédagogiques',
equipe_pedagogique_path,
class: 'fr-nav__link',
path,
class: "fr-nav__link #{disabled_class}",
disabled: employers_only? ,
aria: { current: (current_page?(equipe_pedagogique_path) ? 'page' : nil) }
li.fr-nav__item
= link_to 'Référents',
referents_path,
class: 'fr-nav__link',
class: "fr-nav__link",
aria: { current: (current_page?(referents_path) ? 'page' : nil) }
14 changes: 13 additions & 1 deletion app/views/pages/home/pros/_hero_pro.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ header.container-xl.px-0
= image_tag asset_pack_path('media/images/homepage/1eleve1stage_tag.png'),
alt: 'Illustration élèves',
class: 'img-fluid'
.row.fr-my-3w
.row.fr-my-1w
.col-12
= link_to 'Déposer une offre de stage', new_user_registration_path(as: 'Employer'), class: 'fr-btn'
- if employers_only?
.row.fr-mb-3w
.col-12
.fr-mt-1w.fr-mb-4w.header-cartel.fr-px-6v.fr-py-1w
p.blue-france
strong
= link_to "Vous êtes en 4ème, 3e ou 2nde générale ou technologique ?",
"https://forms.sbc36.com/62553f47462f0e1887f81bfe/xtszW7joSFu4cBSfyOLMdw/form.html",
target: '_blank',
class: 'fr-raw-link'
p.default-grey
= "L'ouverture du service est prévue le #{ENV.fetch 'STUDENTS_OPENING_DAY','3 février 2024'} ."
7 changes: 5 additions & 2 deletions app/views/users/registrations/cards/_education.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.fr-card
div class="fr-card #{employers_only? ? 'disabled_tab' : ''}"
.fr-card__body
.fr-card__content
h3.fr-h4
Expand All @@ -12,7 +12,10 @@
.fr-card__footer
ul.fr-btns-group
li
= link_to "Inscription", new_user_registration_path(as: 'SchoolManagement'), class: 'fr-btn fr-btn--secondary'
- path = employers_only? ? '#' : new_user_registration_path(as: 'SchoolManagement')
- label = employers_only? ? 'Inscription à venir' : 'Inscription'
- klass = employers_only? ? 'fr-btn--tertiary' : 'fr-btn--secondary'
= link_to label, path, class: "fr-btn #{klass}", disabled: employers_only?
.fr-card__header
.fr-ml-4w.fr-mt-5w
.fr-badge.fr-badge--info.fr-badge--no-icon éducation
7 changes: 5 additions & 2 deletions app/views/users/registrations/cards/_student.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.fr-card
div class="fr-card #{employers_only? ? 'disabled_tab' : ''}"
.fr-card__body
.fr-card__content
h3.fr-h4
Expand All @@ -12,7 +12,10 @@
.fr-card__footer
ul.fr-btns-group
li
= link_to "Inscription", new_identity_path(as: 'Student'), class: 'fr-btn fr-btn--secondary'
- path = employers_only? ? '#' : new_identity_path(as: 'Student')
- label = employers_only? ? 'Inscription à venir' : 'Inscription'
- klass = employers_only? ? 'fr-btn--tertiary' : 'fr-btn--secondary'
= link_to label, path, class: "fr-btn #{klass}", disabled: employers_only?
.fr-card__header
.fr-ml-4w.fr-mt-5w
.fr-badge.fr-badge--purple-glycine.fr-badge--no-icon élève
Loading
Loading