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/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/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/_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/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/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/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/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