diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index 130dc98d8..fd4bd9803 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -6,6 +6,7 @@ padding: 8px 16px; border-radius: 30px; border: 1px solid $border-grey; + font-family: "Muli"; font-size: 14px; line-height: 20px; background-color: #FFFFFF; @@ -113,9 +114,20 @@ margin-right: $default-spacer; } - &.dropdown { - position: relative; + &.icon-only { + padding: 9px 16px; + .icon { + margin-right: 0; + } + } +} + +.dropdown { + display: inline-block; + position: relative; + + .dropdown-button { &::after { content: "▾"; margin-left: $default-spacer; @@ -128,24 +140,14 @@ color: $blue; } } - - .dropdown-content { - display: none; - } - - &.open { - .dropdown-content { - display: block; - } - } } - &.icon-only { - padding: 9px 16px; + .dropdown-content { + display: none; + } - .icon { - margin-right: 0; - } + &.open .dropdown-content { + display: block; } } diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 8a07ab6cb..48926e98d 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -159,6 +159,19 @@ $landing-breakpoint: 1040px; } } +.header-menu-button { + border: none; + padding: 0; + + &:hover { + background: none; + } + + &::after { + display: none; + } +} + .header-menu { display: none; position: absolute; diff --git a/app/controllers/admin/instructeurs_controller.rb b/app/controllers/admin/instructeurs_controller.rb index a79dea1fd..85e3a91e1 100644 --- a/app/controllers/admin/instructeurs_controller.rb +++ b/app/controllers/admin/instructeurs_controller.rb @@ -16,7 +16,10 @@ class Admin::InstructeursController < AdminController array: true not_assign_scope = current_administrateur.gestionnaires.where.not(id: assign_scope.ids) - not_assign_scope = not_assign_scope.where("email LIKE ?", "%#{params[:filter]}%") if params[:filter] + + if params[:filter] + not_assign_scope = not_assign_scope.where("email LIKE ?", "%#{params[:filter]}%") + end @instructeurs_not_assign = smart_listing_create :instructeurs_not_assign, not_assign_scope, diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index cd6671683..f8f283c79 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -55,7 +55,9 @@ class Admin::ProceduresController < AdminController def destroy procedure = current_administrateur.procedures.find(params[:id]) - return render json: {}, status: 401 if procedure.publiee_ou_archivee? + if procedure.publiee_ou_archivee? + return render json: {}, status: 401 + end procedure.destroy @@ -72,7 +74,11 @@ class Admin::ProceduresController < AdminController def create @procedure = Procedure.new(procedure_params) - @procedure.module_api_carto = ModuleAPICarto.new(create_module_api_carto_params) if @procedure.valid? + + if @procedure.valid? + @procedure.module_api_carto = ModuleAPICarto.new(create_module_api_carto_params) + end + @path = params.require(:procedure).permit(:path)[:path] @available = !ProcedurePath.exists?(path: @path) @mine = ProcedurePath.mine?(current_administrateur, @path) diff --git a/app/controllers/administrations/sessions_controller.rb b/app/controllers/administrations/sessions_controller.rb index 5c1c66000..78de713c8 100644 --- a/app/controllers/administrations/sessions_controller.rb +++ b/app/controllers/administrations/sessions_controller.rb @@ -5,7 +5,10 @@ class Administrations::SessionsController < ApplicationController end def destroy - sign_out :administration if administration_signed_in? + if administration_signed_in? + sign_out :administration + end + redirect_to root_path end end diff --git a/app/controllers/commentaires_controller.rb b/app/controllers/commentaires_controller.rb index af77f59d0..d54a0e0d0 100644 --- a/app/controllers/commentaires_controller.rb +++ b/app/controllers/commentaires_controller.rb @@ -1,7 +1,10 @@ class CommentairesController < ApplicationController def create @commentaire = Commentaire.new - @commentaire.champ = @commentaire.dossier.champs.find(params[:champ_id]) if params[:champ_id] + + if params[:champ_id] + @commentaire.champ = @commentaire.dossier.champs.find(params[:champ_id]) + end dossier_id = params['dossier_id'] @commentaire.email = current_user.email diff --git a/app/controllers/france_connect/particulier_controller.rb b/app/controllers/france_connect/particulier_controller.rb index 33e9d6fd9..8535493d6 100644 --- a/app/controllers/france_connect/particulier_controller.rb +++ b/app/controllers/france_connect/particulier_controller.rb @@ -36,9 +36,17 @@ class FranceConnect::ParticulierController < ApplicationController end def connect_france_connect_particulier(user) - sign_out :user if user_signed_in? - sign_out :gestionnaire if gestionnaire_signed_in? - sign_out :administrateur if administrateur_signed_in? + if user_signed_in? + sign_out :user + end + + if gestionnaire_signed_in? + sign_out :gestionnaire + end + + if administrateur_signed_in? + sign_out :administrateur + end sign_in user diff --git a/app/controllers/gestionnaires/passwords_controller.rb b/app/controllers/gestionnaires/passwords_controller.rb index 87373d162..df49d7a13 100644 --- a/app/controllers/gestionnaires/passwords_controller.rb +++ b/app/controllers/gestionnaires/passwords_controller.rb @@ -36,14 +36,20 @@ class Gestionnaires::PasswordsController < Devise::PasswordsController def try_to_authenticate_user if gestionnaire_signed_in? user = User.find_by(email: current_gestionnaire.email) - sign_in user if user + + if user + sign_in user + end end end def try_to_authenticate_administrateur if gestionnaire_signed_in? administrateur = Administrateur.find_by(email: current_gestionnaire.email) - sign_in administrateur if administrateur + + if administrateur + sign_in administrateur + end end end end diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 76950e5a4..44d6d0789 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -131,7 +131,10 @@ module NewGestionnaire def position etablissement = dossier.etablissement - point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) if etablissement.present? + + if etablissement.present? + point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) + end lon = "2.428462" lat = "46.538192" diff --git a/app/controllers/sessions/sessions_controller.rb b/app/controllers/sessions/sessions_controller.rb index e30c51fc8..ed30ce252 100644 --- a/app/controllers/sessions/sessions_controller.rb +++ b/app/controllers/sessions/sessions_controller.rb @@ -2,9 +2,20 @@ class Sessions::SessionsController < Devise::SessionsController before_action :before_sign_in, only: [:create] def before_sign_in - sign_out :user if user_signed_in? - sign_out :gestionnaire if gestionnaire_signed_in? - sign_out :administrateur if administrateur_signed_in? - sign_out :administration if administration_signed_in? + if user_signed_in? + sign_out :user + end + + if gestionnaire_signed_in? + sign_out :gestionnaire + end + + if administrateur_signed_in? + sign_out :administrateur + end + + if administration_signed_in? + sign_out :administration + end end end diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb index 131f2b5fa..0b073a96f 100644 --- a/app/controllers/support_controller.rb +++ b/app/controllers/support_controller.rb @@ -9,7 +9,7 @@ class SupportController < ApplicationController if direct_message? && create_commentaire flash.notice = "Votre message a été envoyé sur la messagerie de votre dossier." - redirect_to helpers.url_for_dossier(dossier) + redirect_to messagerie_dossier_path(dossier) elsif create_conversation flash.notice = "Votre message a été envoyé." diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index e8ce6d116..1e277dd06 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -35,7 +35,9 @@ class Users::CarteController < UsersController etablissement = nil end - point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) if etablissement.present? + if etablissement.present? + point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) + end lon = '2.428462' lat = '46.538192' diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index e70091633..9e382270e 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -2,7 +2,10 @@ class Users::DescriptionController < UsersController def pieces_justificatives invite = current_user.invite? params[:dossier_id] - @dossier ||= Dossier.find(params[:dossier_id]) if invite + if invite + @dossier ||= Dossier.find(params[:dossier_id]) + end + @dossier ||= current_user_dossier if (errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).present? @@ -13,10 +16,14 @@ class Users::DescriptionController < UsersController end else - flash.notice = 'Nouveaux fichiers envoyés' if flash.alert.nil? + if flash.alert.nil? + flash.notice = 'Nouveaux fichiers envoyés' + end end - return redirect_to users_dossiers_invite_path(id: current_user.invites.find_by(dossier_id: @dossier.id).id) if invite + if invite + return redirect_to users_dossiers_invite_path(id: current_user.invites.find_by(dossier_id: @dossier.id).id) + end redirect_to users_dossier_recapitulatif_path end diff --git a/app/controllers/users/dossiers/add_siret_controller.rb b/app/controllers/users/dossiers/add_siret_controller.rb index 35251ed3f..9b39f38c8 100644 --- a/app/controllers/users/dossiers/add_siret_controller.rb +++ b/app/controllers/users/dossiers/add_siret_controller.rb @@ -2,10 +2,13 @@ class Users::Dossiers::AddSiretController < ApplicationController def show @facade = DossierFacades.new params[:dossier_id], current_user.email - raise ActiveRecord::RecordNotFound if !@facade.procedure.individual_with_siret? - - @siret = current_user.siret if current_user.siret.present? + if !@facade.procedure.individual_with_siret? + raise ActiveRecord::RecordNotFound + end + if current_user.siret.present? + @siret = current_user.siret + end rescue ActiveRecord::RecordNotFound flash.alert = t('errors.messages.dossier_not_found') redirect_to url_for dossiers_path diff --git a/app/controllers/users/dossiers/invites_controller.rb b/app/controllers/users/dossiers/invites_controller.rb index 078e3d74c..880fed4c5 100644 --- a/app/controllers/users/dossiers/invites_controller.rb +++ b/app/controllers/users/dossiers/invites_controller.rb @@ -12,12 +12,10 @@ class Users::Dossiers::InvitesController < UsersController def show @facade = InviteDossierFacades.new params[:id].to_i, current_user.email - if Flipflop.new_dossier_details? - return redirect_to dossier_path(@facade.dossier) - end - if @facade.dossier.brouillon? redirect_to brouillon_dossier_path(@facade.dossier) + elsif Flipflop.new_dossier_details? + return redirect_to dossier_path(@facade.dossier) else render 'users/recapitulatif/show' end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 9349d72d5..9ff440f37 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -54,7 +54,9 @@ class Users::DossiersController < UsersController dossier = Dossier.create!(procedure: procedure, user: current_user, state: Dossier.states.fetch(:brouillon)) siret = params[:siret] || current_user.siret - update_current_user_siret! siret if siret.present? + if siret.present? + update_current_user_siret! siret + end if dossier.procedure.for_individual redirect_to identite_dossier_path(dossier) @@ -67,7 +69,9 @@ class Users::DossiersController < UsersController def show @facade = facade - @siret = current_user.siret if current_user.siret.present? + if current_user.siret.present? + @siret = current_user.siret + end if @facade.procedure.for_individual? && current_user.loged_in_with_france_connect? individual = @facade.dossier.individual @@ -165,7 +169,9 @@ class Users::DossiersController < UsersController private def check_siret - errors_valid_siret if !Siret.new(siret: siret).valid? + if !Siret.new(siret: siret).valid? + errors_valid_siret + end end def errors_valid_siret diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index 0c199841d..92ffda801 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -36,14 +36,20 @@ class Users::PasswordsController < Devise::PasswordsController def try_to_authenticate_gestionnaire if user_signed_in? gestionnaire = Gestionnaire.find_by(email: current_user.email) - sign_in gestionnaire if gestionnaire + + if gestionnaire + sign_in gestionnaire + end end end def try_to_authenticate_administrateur if user_signed_in? administrateur = Administrateur.find_by(email: current_user.email) - sign_in administrateur if administrateur + + if administrateur + sign_in administrateur + end end end end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 89af9412d..85964b628 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -13,7 +13,10 @@ class Users::RegistrationsController < Devise::RegistrationsController # Allow pre-filling the user email from a query parameter build_resource({ email: sign_up_params[:email] }) - yield resource if block_given? + if block_given? + yield resource + end + respond_with resource end diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 14b93bab5..5d43d18e6 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -39,8 +39,13 @@ class Users::SessionsController < Sessions::SessionsController # DELETE /resource/sign_out def destroy - sign_out :gestionnaire if gestionnaire_signed_in? - sign_out :administrateur if administrateur_signed_in? + if gestionnaire_signed_in? + sign_out :gestionnaire + end + + if administrateur_signed_in? + sign_out :administrateur + end if user_signed_in? connected_with_france_connect = current_user.loged_in_with_france_connect @@ -72,7 +77,9 @@ class Users::SessionsController < Sessions::SessionsController end def user_return_to_procedure_id - return nil if session["user_return_to"].nil? + if session["user_return_to"].nil? + return nil + end NumberService.to_number session["user_return_to"].split("?procedure_id=").second end diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb index b3621337b..9722cfb66 100644 --- a/app/decorators/champ_decorator.rb +++ b/app/decorators/champ_decorator.rb @@ -30,6 +30,8 @@ class ChampDecorator < Draper::Decorator end def description_with_links - description.gsub(URI.regexp, '\0') if description + if description + description.gsub(URI.regexp, '\0') + end end end diff --git a/app/decorators/type_de_piece_justificative_decorator.rb b/app/decorators/type_de_piece_justificative_decorator.rb index eb2bb6200..3f6e6b382 100644 --- a/app/decorators/type_de_piece_justificative_decorator.rb +++ b/app/decorators/type_de_piece_justificative_decorator.rb @@ -1,11 +1,15 @@ class TypeDePieceJustificativeDecorator < Draper::Decorator delegate_all def button_up(params) - h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post if display_up_button?(params[:index]) + if display_up_button?(params[:index]) + h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post + end end def button_down(params) - h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post if display_down_button?(params[:index]) + if display_down_button?(params[:index]) + h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post + end end private diff --git a/app/javascript/new_design/buttons.js b/app/javascript/new_design/buttons.js deleted file mode 100644 index 321ea62fe..000000000 --- a/app/javascript/new_design/buttons.js +++ /dev/null @@ -1,13 +0,0 @@ -import $ from 'jquery'; - -$(document).on('click', 'body', () => { - $('.button.dropdown').removeClass('open'); -}); - -$(document).on('click', '.button.dropdown', event => { - event.stopPropagation(); - const $target = $(event.target); - if ($target.hasClass('button', 'dropdown')) { - $target.toggleClass('open'); - } -}); diff --git a/app/javascript/new_design/dossier.js b/app/javascript/new_design/dossier.js deleted file mode 100644 index e7bbf68b9..000000000 --- a/app/javascript/new_design/dossier.js +++ /dev/null @@ -1,10 +0,0 @@ -import $ from 'jquery'; - -$(document).on('click', 'body', () => { - $('.print-menu').removeClass('open fade-in-down'); -}); - -export function togglePrintMenu(event) { - event.stopPropagation(); - $('.print-menu').toggleClass('open fade-in-down'); -} diff --git a/app/javascript/new_design/dropdown.js b/app/javascript/new_design/dropdown.js new file mode 100644 index 000000000..2829b98d8 --- /dev/null +++ b/app/javascript/new_design/dropdown.js @@ -0,0 +1,19 @@ +import Rails from 'rails-ujs'; + +const { delegate } = Rails; + +delegate(document, 'body', 'click', event => { + if (!event.target.closest('.dropdown')) { + [...document.querySelectorAll('.dropdown')].forEach(element => + element.classList.remove('open', 'fade-in-down') + ); + } +}); + +delegate(document, '.dropdown-button', 'click', event => { + event.stopPropagation(); + const parent = event.target.closest('.dropdown-button').parentElement; + if (parent.classList.contains('dropdown')) { + parent.classList.toggle('open'); + } +}); diff --git a/app/javascript/new_design/header.js b/app/javascript/new_design/header.js deleted file mode 100644 index b7f048ec7..000000000 --- a/app/javascript/new_design/header.js +++ /dev/null @@ -1,10 +0,0 @@ -import $ from 'jquery'; - -$(document).on('click', 'body', () => { - $('.header-menu').removeClass('open fade-in-down'); -}); - -export function toggleHeaderMenu(event) { - event.stopPropagation(); - $('.header-menu').toggleClass('open fade-in-down'); -} diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index f953f6100..f504d2876 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -13,7 +13,7 @@ import '../shared/autocomplete'; import '../shared/remote-input'; import '../new_design/spinner'; -import '../new_design/buttons'; +import '../new_design/dropdown'; import '../new_design/form-validation'; import '../new_design/carto'; import '../new_design/select2'; @@ -21,8 +21,6 @@ import '../new_design/select2'; import '../new_design/champs/linked-drop-down-list'; import { toggleCondidentielExplanation } from '../new_design/avis'; -import { togglePrintMenu } from '../new_design/dossier'; -import { toggleHeaderMenu } from '../new_design/header'; import { scrollMessagerie } from '../new_design/messagerie'; import { showMotivation, motivationCancel } from '../new_design/state-button'; import { toggleChart } from '../new_design/toggle-chart'; @@ -30,8 +28,6 @@ import { toggleChart } from '../new_design/toggle-chart'; // This is the global application namespace where we expose helpers used from rails views const DS = { toggleCondidentielExplanation, - togglePrintMenu, - toggleHeaderMenu, scrollMessagerie, showMotivation, motivationCancel, diff --git a/app/lib/file_size_validator.rb b/app/lib/file_size_validator.rb index 43f1cbcd4..8537ce414 100644 --- a/app/lib/file_size_validator.rb +++ b/app/lib/file_size_validator.rb @@ -10,9 +10,15 @@ class FileSizeValidator < ActiveModel::EachValidator range = options.delete(:in) || options.delete(:within) if range.present? - raise ArgumentError, ":in and :within must be a Range" if !range.is_a?(Range) + if !range.is_a?(Range) + raise ArgumentError, ":in and :within must be a Range" + end + options[:minimum], options[:maximum] = range.begin, range.end - options[:maximum] -= 1 if range.exclude_end? + + if range.exclude_end? + options[:maximum] -= 1 + end end super @@ -35,12 +41,18 @@ class FileSizeValidator < ActiveModel::EachValidator end def validate_each(record, attribute, value) - raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") if !value.kind_of? CarrierWave::Uploader::Base + if !value.kind_of? CarrierWave::Uploader::Base + raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") + end - value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String) + if value.kind_of?(String) + value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) + end CHECKS.each do |key, validity_check| - next if !check_value = options[key] + if !check_value = options[key] + next + end check_value = case check_value @@ -50,16 +62,22 @@ class FileSizeValidator < ActiveModel::EachValidator record.send(check_value) end - value ||= [] if key == :maximum + if key == :maximum + value ||= [] + end value_size = value.size - next if value_size.send(validity_check, check_value) + if value_size.send(validity_check, check_value) + next + end errors_options = options.except(*RESERVED_OPTIONS) errors_options[:file_size] = help.number_to_human_size check_value default_message = options[MESSAGES[key]] - errors_options[:message] ||= default_message if default_message + if default_message + errors_options[:message] ||= default_message + end record.errors.add(attribute, MESSAGES[key], errors_options) end diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb index b4e194186..b861fd026 100644 --- a/app/models/concerns/tags_substitution_concern.rb +++ b/app/models/concerns/tags_substitution_concern.rb @@ -47,7 +47,7 @@ module TagsSubstitutionConcern { libelle: 'lien dossier', description: '', - lambda: -> (d) { external_link(users_dossier_recapitulatif_url(d)) }, + lambda: -> (d) { external_link(dossier_url(d)) }, available_for_states: Dossier::SOUMIS }, { diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 97dc3c65f..b06068620 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -31,7 +31,9 @@ class Gestionnaire < ApplicationRecord end def follow(dossier) - return if follow?(dossier) + if follow?(dossier) + return + end followed_dossiers << dossier end diff --git a/app/models/module_api_carto.rb b/app/models/module_api_carto.rb index 94d7a34c5..179d89ef2 100644 --- a/app/models/module_api_carto.rb +++ b/app/models/module_api_carto.rb @@ -6,10 +6,15 @@ class ModuleAPICarto < ApplicationRecord validates :cadastre, presence: true, allow_blank: true, allow_nil: false def classes - modules = '' + modules = '' - modules += 'qp ' if quartiers_prioritaires? - modules += 'cadastre ' if cadastre? + if quartiers_prioritaires? + modules += 'qp ' + end + + if cadastre? + modules += 'cadastre ' + end modules end diff --git a/app/models/siret.rb b/app/models/siret.rb index f1b9cda8a..6aff5363c 100644 --- a/app/models/siret.rb +++ b/app/models/siret.rb @@ -10,6 +10,8 @@ class Siret before_validation :remove_whitespace def remove_whitespace - siret.delete!(' ') if siret.present? + if siret.present? + siret.delete!(' ') + end end end diff --git a/app/services/clamav_service.rb b/app/services/clamav_service.rb index e8e04a021..3ebf065af 100644 --- a/app/services/clamav_service.rb +++ b/app/services/clamav_service.rb @@ -1,7 +1,9 @@ class ClamavService def self.safe_file?(file_path) if Rails.env == 'development' - return CLAMAV[:response] if CLAMAV[:mock?] + if CLAMAV[:mock?] + return CLAMAV[:response] + end end FileUtils.chmod 0666, file_path @@ -9,7 +11,10 @@ class ClamavService client = ClamAV::Client.new response = client.execute(ClamAV::Commands::ScanCommand.new(file_path)) - return false if response.first.class == ClamAV::VirusResponse + if response.first.class == ClamAV::VirusResponse + return false + end + true end end diff --git a/app/services/number_service.rb b/app/services/number_service.rb index bc399d5ef..981f47d9c 100644 --- a/app/services/number_service.rb +++ b/app/services/number_service.rb @@ -1,5 +1,5 @@ class NumberService def self.to_number(string) - string.to_s if Float(string) rescue nil + string.to_s end end diff --git a/app/uploaders/piece_justificative_uploader.rb b/app/uploaders/piece_justificative_uploader.rb index 3168a9804..c9bf93278 100644 --- a/app/uploaders/piece_justificative_uploader.rb +++ b/app/uploaders/piece_justificative_uploader.rb @@ -48,6 +48,8 @@ class PieceJustificativeUploader < BaseUploader end def set_original_filename(file) - model.original_filename ||= file.original_filename if file.respond_to?(:original_filename) + if file.respond_to?(:original_filename) + model.original_filename ||= file.original_filename + end end end diff --git a/app/validators/procedure_path_format_validator.rb b/app/validators/procedure_path_format_validator.rb index 19951bc67..7c5e1f5b9 100644 --- a/app/validators/procedure_path_format_validator.rb +++ b/app/validators/procedure_path_format_validator.rb @@ -4,7 +4,12 @@ class ProcedurePathFormatValidator < ActiveModel::Validator end def validate(record) - return false if record.path.blank? - record.errors[:path] << "Path invalide" if !path_regex.match(record.path) + if record.path.blank? + return false + end + + if !path_regex.match(record.path) + record.errors[:path] << "Path invalide" + end end end diff --git a/app/views/invites/_dropdown.html.haml b/app/views/invites/_dropdown.html.haml index 19fddeb52..368c359ef 100644 --- a/app/views/invites/_dropdown.html.haml +++ b/app/views/invites/_dropdown.html.haml @@ -1,10 +1,11 @@ -%span.button.dropdown.invite-user-action - %span.icon.person - - if dossier.invites.count > 0 - Voir les personnes invitées - %span.badge= dossier.invites.count - - else - Inviter une personne à modifier ce dossier +%span.dropdown.invite-user-action + %button.button.dropdown-button + %span.icon.person + - if dossier.invites.count > 0 + Voir les personnes invitées + %span.badge= dossier.invites.count + - else + Inviter une personne à modifier ce dossier .dropdown-content.fade-in-down = render partial: "invites/form", locals: { dossier: dossier } diff --git a/app/views/layouts/_modifications_terminees.html.haml b/app/views/layouts/_modifications_terminees.html.haml index 085d66947..075d78d0f 100644 --- a/app/views/layouts/_modifications_terminees.html.haml +++ b/app/views/layouts/_modifications_terminees.html.haml @@ -1,3 +1,3 @@ %div{ style: 'float: right;' } - %a.btn{ href: "/users/dossiers/#{@dossier.id}/recapitulatif" } Retour + %a.btn{ href: dossier_path(@dossier) } Retour = submit_tag 'Modification terminée', class: %w(btn btn btn-info), id: 'modification_terminee', data: { disable: true, submit: true } diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 333e46015..0a951df0f 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -57,9 +57,10 @@ - if gestionnaire_signed_in? || user_signed_in? %li - .header-menu-opener - = image_tag "icons/account-circle.svg", onclick: "javascript:DS.toggleHeaderMenu(event);", title: "Mon compte" - %ul.header-menu + %span.dropdown.header-menu-opener + %button.button.dropdown-button.header-menu-button + = image_tag "icons/account-circle.svg", title: "Mon compte" + %ul.header-menu.dropdown-content %li .menu-item{ title: current_email } = current_email diff --git a/app/views/layouts/mailers/notification.html.haml b/app/views/layouts/mailers/notification.html.haml index 343b88da2..673197f8d 100644 --- a/app/views/layouts/mailers/notification.html.haml +++ b/app/views/layouts/mailers/notification.html.haml @@ -6,4 +6,4 @@ %strong Merci de ne pas répondre à cet email. Pour vous adresser à votre administration, passez directement par votre = succeed '.' do - = link_to 'messagerie', users_dossier_recapitulatif_url(@dossier), target: '_blank' + = link_to 'messagerie', messagerie_dossier_url(@dossier), target: '_blank' diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 8526eda4d..90e187395 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -7,13 +7,14 @@ %li = "Dossier nº #{dossier.id}" .mixed-buttons-bar - .button.dropdown.icon-only.print-menu-opener{ onclick: "javascript:DS.togglePrintMenu(event);" } - %span.icon.printer - %ul.print-menu + %span.dropdown.print-menu-opener + %button.button.dropdown-button.icon-only + %span.icon.printer + %ul.print-menu.dropdown-content %li = link_to "Tout le dossier", print_gestionnaire_dossier_path(dossier.procedure, dossier), target: "_blank", class: "menu-item menu-link" %li - = link_to "Uniquement cet onglet", "#", onclick: "DS.togglePrintMenu; window.print()", class: "menu-item menu-link" + = link_to "Uniquement cet onglet", "#", onclick: "window.print()", class: "menu-item menu-link" = render partial: "new_gestionnaire/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_gestionnaire&.follow?(dossier) } = render partial: "state_button", locals: { dossier: dossier } diff --git a/app/views/new_gestionnaire/dossiers/_state_button.html.haml b/app/views/new_gestionnaire/dossiers/_state_button.html.haml index 5769317c5..02fed9f81 100644 --- a/app/views/new_gestionnaire/dossiers/_state_button.html.haml +++ b/app/views/new_gestionnaire/dossiers/_state_button.html.haml @@ -1,6 +1,7 @@ - if dossier.en_construction? || dossier.en_instruction? - %span.button.primary.dropdown - = dossier.decorate.display_state + %span.dropdown + %button.button.primary.dropdown-button + = dossier.decorate.display_state .dropdown-content.fade-in-down %ul.dropdown-items - if dossier.en_construction? @@ -49,8 +50,9 @@ - else - if dossier.motivation.present? || dossier.attestation.present? - %span.button.dropdown{ class: button_or_label_class(dossier) } - = dossier.statut + %span.dropdown + %button.button.dropdown-button{ class: button_or_label_class(dossier) } + = dossier.statut .dropdown-content.fade-in-down.terminated - if dossier.motivation.present? %h4 Motivation diff --git a/app/views/new_gestionnaire/procedures/_download_dossiers.html.haml b/app/views/new_gestionnaire/procedures/_download_dossiers.html.haml index 2bd2137d5..2dd53c586 100644 --- a/app/views/new_gestionnaire/procedures/_download_dossiers.html.haml +++ b/app/views/new_gestionnaire/procedures/_download_dossiers.html.haml @@ -1,6 +1,7 @@ - if procedure.dossiers.state_not_brouillon.any? - %span.button.dropdown - Télécharger tous les dossiers + %span.dropdown + %button.button.dropdown-button + Télécharger tous les dossiers .dropdown-content.fade-in-down %ul.dropdown-items %li diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 2626e3cdb..ebcf41b7f 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -43,8 +43,9 @@ .container - if @dossiers.present? || @current_filters.count > 0 - %span.button.dropdown - Filtrer + %span.dropdown + %button.button.dropdown-button + Filtrer .dropdown-content.left-aligned.fade-in-down = form_tag add_filter_gestionnaire_procedure_path(@procedure), method: :post, class: 'dropdown-form large' do = label_tag :field, "Colonne" @@ -78,8 +79,9 @@ = render partial: "header_field", locals: { field: { "label" => "Statut", "table" => "self", "column" => "state" }, classname: "status-col" } %th.follow-col - %span.button.dropdown - Personnaliser + %span.dropdown + %button.button.dropdown-button + Personnaliser .dropdown-content.fade-in-down = form_tag update_displayed_fields_gestionnaire_procedure_path(@procedure), method: :patch, class: 'dropdown-form columns-form' do = select_tag :values, diff --git a/app/views/notification_mailer/new_answer.html.haml b/app/views/notification_mailer/new_answer.html.haml index b1356e35c..0fa7b860e 100644 --- a/app/views/notification_mailer/new_answer.html.haml +++ b/app/views/notification_mailer/new_answer.html.haml @@ -6,7 +6,7 @@ %p Pour le consulter, merci de vous rendre sur - = users_dossier_recapitulatif_url(dossier_id: @dossier.id) + = messagerie_dossier_url(@dossier) %p Bonne journée, diff --git a/app/views/shared/dossiers/_pieces_jointes.html.haml b/app/views/shared/dossiers/_pieces_jointes.html.haml index 15a37ab20..78dafa823 100644 --- a/app/views/shared/dossiers/_pieces_jointes.html.haml +++ b/app/views/shared/dossiers/_pieces_jointes.html.haml @@ -13,8 +13,9 @@ = link_to "Télécharger", pj.content_url, class: "link", target: :blank - if pjs.present? %br - %span.button.dropdown - anciennes versions + %span.dropdown + %button.button.dropdown-button + anciennes versions .dropdown-content.fade-in-down %ul.dropdown-items - pjs.each do |pj| diff --git a/app/views/tour_de_france/index.html.haml b/app/views/tour_de_france/index.html.haml index 0e17ce13e..bd654e5dd 100644 --- a/app/views/tour_de_france/index.html.haml +++ b/app/views/tour_de_france/index.html.haml @@ -58,7 +58,7 @@ %li = link_to("Étape Occitanie, le 15 octobre à Toulouse", "https://www.demarches-simplifiees.fr/commencer/tour-de-france-demarches-simplifiees-fr-occitanie", target: "_blank") %li - = link_to("Étape Nouvelle-Aquitaine, le 17 octobre à Bordeaux", "https://www.demarches-simplifiees.fr/commencer/tour-de-france-demarches-simplifiees-fr-aquitaine", target: "_blank") + = link_to("Étape Nouvelle-Aquitaine, le 18 octobre à Bordeaux", "https://www.demarches-simplifiees.fr/commencer/tour-de-france-demarches-simplifiees-fr-aquitaine", target: "_blank") %li = link_to("Étape Martinique, le 24 octobre à Fort-de-France", "https://www.demarches-simplifiees.fr/commencer/tour-de-france-demarches-simplifiees-fr-martinique", target: "_blank") %li diff --git a/db/migrate/20160120094750_create_france_connect_information.rb b/db/migrate/20160120094750_create_france_connect_information.rb index 3363092c0..97dde9ccd 100644 --- a/db/migrate/20160120094750_create_france_connect_information.rb +++ b/db/migrate/20160120094750_create_france_connect_information.rb @@ -18,15 +18,17 @@ class CreateFranceConnectInformation < ActiveRecord::Migration add_reference :france_connect_informations, :user, references: :users User.all.each do |user| - FranceConnectInformation.create({ - gender: user.gender, - given_name: user.given_name, - family_name: user.family_name, - birthdate: user.birthdate, - birthplace: user.birthplace, - france_connect_particulier_id: user.france_connect_particulier_id, - user_id: user.id - }) if user.france_connect_particulier_id.present? + if user.france_connect_particulier_id.present? + FranceConnectInformation.create({ + gender: user.gender, + given_name: user.given_name, + family_name: user.family_name, + birthdate: user.birthdate, + birthplace: user.birthplace, + france_connect_particulier_id: user.france_connect_particulier_id, + user_id: user.id + }) + end end remove_column :users, :gender diff --git a/spec/controllers/support_controller_spec.rb b/spec/controllers/support_controller_spec.rb index f35a3e51c..a075e1b19 100644 --- a/spec/controllers/support_controller_spec.rb +++ b/spec/controllers/support_controller_spec.rb @@ -98,7 +98,7 @@ describe SupportController, type: :controller do } expect(flash[:notice]).to match('Votre message a été envoyé sur la messagerie de votre dossier.') - expect(response).to redirect_to users_dossier_recapitulatif_path(dossier) + expect(response).to redirect_to messagerie_dossier_path(dossier) end end end diff --git a/spec/features/new_gestionnaire/procedure_filters_spec.rb b/spec/features/new_gestionnaire/procedure_filters_spec.rb index 58f0d1f55..61236213a 100644 --- a/spec/features/new_gestionnaire/procedure_filters_spec.rb +++ b/spec/features/new_gestionnaire/procedure_filters_spec.rb @@ -82,23 +82,23 @@ feature "procedure filters" do end def add_filter(column_name, filter_value) - find(:xpath, "//span[contains(text(), 'Filtrer')]").click + click_on 'Filtrer' select column_name, from: "Colonne" fill_in "Valeur", with: filter_value click_button "Ajouter le filtre" end def add_column(column_name) - find(:xpath, "//span[contains(text(), 'Personnaliser')]").click + click_on 'Personnaliser' find("span.select2-container").click find(:xpath, "//li[text()='#{column_name}']").click click_button "Enregistrer" end def remove_column(column_name) - find(:xpath, "//span[contains(text(), 'Personnaliser')]").click + click_on 'Personnaliser' find(:xpath, "//li[contains(@title, '#{column_name}')]/span[contains(text(), '×')]").click - find(:xpath, "//span[contains(text(), 'Personnaliser')]//span[contains(@class, 'select2-container')]").click + find(:xpath, "//form[contains(@class, 'columns-form')]//span[contains(@class, 'select2-container')]").click click_button "Enregistrer" end end diff --git a/spec/features/new_user/dossier_spec.rb b/spec/features/new_user/brouillon_spec.rb similarity index 100% rename from spec/features/new_user/dossier_spec.rb rename to spec/features/new_user/brouillon_spec.rb diff --git a/spec/features/new_user/invite_spec.rb b/spec/features/new_user/invite_spec.rb index 5eb7143b7..cdbb5d14c 100644 --- a/spec/features/new_user/invite_spec.rb +++ b/spec/features/new_user/invite_spec.rb @@ -178,7 +178,7 @@ feature 'Invitations' do end def send_invite_to(invited_email) - find('.button.invite-user-action').click() + click_on "Inviter une personne à modifier ce dossier" expect(page).to have_button("Envoyer une invitation", visible: true) fill_in 'invite_email', with: invited_email diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index c134835ad..54af8f987 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -60,7 +60,7 @@ RSpec.describe NotificationMailer, type: :mailer do subject(:subject) { described_class.new_answer(dossier) } it { expect(subject.body).to match('Un nouveau message est disponible dans votre espace demarches-simplifiees.fr.') } - it { expect(subject.body).to include(users_dossier_recapitulatif_url(dossier_id: dossier.id)) } + it { expect(subject.body).to include(messagerie_dossier_url(dossier)) } it { expect(subject.subject).to eq("Nouveau message pour votre dossier nº #{dossier.id}") } end end diff --git a/spec/models/concern/mail_template_concern_spec.rb b/spec/models/concern/mail_template_concern_spec.rb index cae0c8c87..04e4e428c 100644 --- a/spec/models/concern/mail_template_concern_spec.rb +++ b/spec/models/concern/mail_template_concern_spec.rb @@ -26,7 +26,7 @@ describe MailTemplateConcern do it do expected = "[demarches-simplifiees.fr] #{dossier.id} #{dossier.procedure.libelle} " + - "http://localhost:3000/users/dossiers/#{dossier.id}/recapitulatif" + "http://localhost:3000/dossiers/#{dossier.id}" is_expected.to eq(expected) end diff --git a/spec/views/users/carte/show.html.haml_spec.rb b/spec/views/users/carte/show.html.haml_spec.rb index 1ed8e87cb..d30f8c13c 100644 --- a/spec/views/users/carte/show.html.haml_spec.rb +++ b/spec/views/users/carte/show.html.haml_spec.rb @@ -27,7 +27,7 @@ describe 'users/carte/show.html.haml', type: :view do end end - context 'si la page précédente n\'est pas recapitulatif' do + context 'si la page précédente n\'est pas la page du dossier' do it 'le bouton "Etape suivante" est présent' do expect(rendered).to have_selector('#etape_suivante') end @@ -37,7 +37,7 @@ describe 'users/carte/show.html.haml', type: :view do # end end - context 'si la page précédente est recapitularif' do + context 'si la page précédente est la page du dossier' do let(:state) { Dossier.states.fetch(:en_construction) } it 'le bouton "Etape suivante" n\'est pas présent' do @@ -52,8 +52,8 @@ describe 'users/carte/show.html.haml', type: :view do # expect(rendered).to have_selector('input[type=submit][id=modification_terminee][onclick=\'submit_check_draw(event)\']') # end - it 'le lien de retour au récapitulatif est présent' do - expect(rendered).to have_selector("a[href='/users/dossiers/#{dossier_id}/recapitulatif']") + it 'le lien de retour à la page du dossier est présent' do + expect(rendered).to have_selector("a[href='/dossiers/#{dossier_id}']") end end end