Merge pull request #2688 from betagouv/wip/refactor-dropdowns
dropdown: refactor to make the button an actual button
This commit is contained in:
commit
8c5c70b783
16 changed files with 92 additions and 86 deletions
|
@ -6,6 +6,7 @@
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
border-radius: 30px;
|
border-radius: 30px;
|
||||||
border: 1px solid $border-grey;
|
border: 1px solid $border-grey;
|
||||||
|
font-family: "Muli";
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
background-color: #FFFFFF;
|
background-color: #FFFFFF;
|
||||||
|
@ -113,9 +114,20 @@
|
||||||
margin-right: $default-spacer;
|
margin-right: $default-spacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.dropdown {
|
&.icon-only {
|
||||||
position: relative;
|
padding: 9px 16px;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.dropdown-button {
|
||||||
&::after {
|
&::after {
|
||||||
content: "▾";
|
content: "▾";
|
||||||
margin-left: $default-spacer;
|
margin-left: $default-spacer;
|
||||||
|
@ -128,24 +140,14 @@
|
||||||
color: $blue;
|
color: $blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-content {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.open {
|
|
||||||
.dropdown-content {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.icon-only {
|
.dropdown-content {
|
||||||
padding: 9px 16px;
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.icon {
|
&.open .dropdown-content {
|
||||||
margin-right: 0;
|
display: block;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,19 @@ $landing-breakpoint: 1040px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-menu-button {
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.header-menu {
|
.header-menu {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -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');
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -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');
|
|
||||||
}
|
|
19
app/javascript/new_design/dropdown.js
Normal file
19
app/javascript/new_design/dropdown.js
Normal file
|
@ -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');
|
||||||
|
}
|
||||||
|
});
|
|
@ -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');
|
|
||||||
}
|
|
|
@ -13,7 +13,7 @@ import '../shared/autocomplete';
|
||||||
import '../shared/remote-input';
|
import '../shared/remote-input';
|
||||||
|
|
||||||
import '../new_design/spinner';
|
import '../new_design/spinner';
|
||||||
import '../new_design/buttons';
|
import '../new_design/dropdown';
|
||||||
import '../new_design/form-validation';
|
import '../new_design/form-validation';
|
||||||
import '../new_design/carto';
|
import '../new_design/carto';
|
||||||
import '../new_design/select2';
|
import '../new_design/select2';
|
||||||
|
@ -21,8 +21,6 @@ import '../new_design/select2';
|
||||||
import '../new_design/champs/linked-drop-down-list';
|
import '../new_design/champs/linked-drop-down-list';
|
||||||
|
|
||||||
import { toggleCondidentielExplanation } from '../new_design/avis';
|
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 { scrollMessagerie } from '../new_design/messagerie';
|
||||||
import { showMotivation, motivationCancel } from '../new_design/state-button';
|
import { showMotivation, motivationCancel } from '../new_design/state-button';
|
||||||
import { toggleChart } from '../new_design/toggle-chart';
|
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
|
// This is the global application namespace where we expose helpers used from rails views
|
||||||
const DS = {
|
const DS = {
|
||||||
toggleCondidentielExplanation,
|
toggleCondidentielExplanation,
|
||||||
togglePrintMenu,
|
|
||||||
toggleHeaderMenu,
|
|
||||||
scrollMessagerie,
|
scrollMessagerie,
|
||||||
showMotivation,
|
showMotivation,
|
||||||
motivationCancel,
|
motivationCancel,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
%span.button.dropdown.invite-user-action
|
%span.dropdown.invite-user-action
|
||||||
%span.icon.person
|
%button.button.dropdown-button
|
||||||
- if dossier.invites.count > 0
|
%span.icon.person
|
||||||
Voir les personnes invitées
|
- if dossier.invites.count > 0
|
||||||
%span.badge= dossier.invites.count
|
Voir les personnes invitées
|
||||||
- else
|
%span.badge= dossier.invites.count
|
||||||
Inviter une personne à modifier ce dossier
|
- else
|
||||||
|
Inviter une personne à modifier ce dossier
|
||||||
|
|
||||||
.dropdown-content.fade-in-down
|
.dropdown-content.fade-in-down
|
||||||
= render partial: "invites/form", locals: { dossier: dossier }
|
= render partial: "invites/form", locals: { dossier: dossier }
|
||||||
|
|
|
@ -57,9 +57,10 @@
|
||||||
|
|
||||||
- if gestionnaire_signed_in? || user_signed_in?
|
- if gestionnaire_signed_in? || user_signed_in?
|
||||||
%li
|
%li
|
||||||
.header-menu-opener
|
%span.dropdown.header-menu-opener
|
||||||
= image_tag "icons/account-circle.svg", onclick: "javascript:DS.toggleHeaderMenu(event);", title: "Mon compte"
|
%button.button.dropdown-button.header-menu-button
|
||||||
%ul.header-menu
|
= image_tag "icons/account-circle.svg", title: "Mon compte"
|
||||||
|
%ul.header-menu.dropdown-content
|
||||||
%li
|
%li
|
||||||
.menu-item{ title: current_email }
|
.menu-item{ title: current_email }
|
||||||
= current_email
|
= current_email
|
||||||
|
|
|
@ -7,13 +7,14 @@
|
||||||
%li
|
%li
|
||||||
= "Dossier nº #{dossier.id}"
|
= "Dossier nº #{dossier.id}"
|
||||||
.mixed-buttons-bar
|
.mixed-buttons-bar
|
||||||
.button.dropdown.icon-only.print-menu-opener{ onclick: "javascript:DS.togglePrintMenu(event);" }
|
%span.dropdown.print-menu-opener
|
||||||
%span.icon.printer
|
%button.button.dropdown-button.icon-only
|
||||||
%ul.print-menu
|
%span.icon.printer
|
||||||
|
%ul.print-menu.dropdown-content
|
||||||
%li
|
%li
|
||||||
= link_to "Tout le dossier", print_gestionnaire_dossier_path(dossier.procedure, dossier), target: "_blank", class: "menu-item menu-link"
|
= link_to "Tout le dossier", print_gestionnaire_dossier_path(dossier.procedure, dossier), target: "_blank", class: "menu-item menu-link"
|
||||||
%li
|
%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: "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 }
|
= render partial: "state_button", locals: { dossier: dossier }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
- if dossier.en_construction? || dossier.en_instruction?
|
- if dossier.en_construction? || dossier.en_instruction?
|
||||||
%span.button.primary.dropdown
|
%span.dropdown
|
||||||
= dossier.decorate.display_state
|
%button.button.primary.dropdown-button
|
||||||
|
= dossier.decorate.display_state
|
||||||
.dropdown-content.fade-in-down
|
.dropdown-content.fade-in-down
|
||||||
%ul.dropdown-items
|
%ul.dropdown-items
|
||||||
- if dossier.en_construction?
|
- if dossier.en_construction?
|
||||||
|
@ -49,8 +50,9 @@
|
||||||
|
|
||||||
- else
|
- else
|
||||||
- if dossier.motivation.present? || dossier.attestation.present?
|
- if dossier.motivation.present? || dossier.attestation.present?
|
||||||
%span.button.dropdown{ class: button_or_label_class(dossier) }
|
%span.dropdown
|
||||||
= dossier.statut
|
%button.button.dropdown-button{ class: button_or_label_class(dossier) }
|
||||||
|
= dossier.statut
|
||||||
.dropdown-content.fade-in-down.terminated
|
.dropdown-content.fade-in-down.terminated
|
||||||
- if dossier.motivation.present?
|
- if dossier.motivation.present?
|
||||||
%h4 Motivation
|
%h4 Motivation
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
- if procedure.dossiers.state_not_brouillon.any?
|
- if procedure.dossiers.state_not_brouillon.any?
|
||||||
%span.button.dropdown
|
%span.dropdown
|
||||||
Télécharger tous les dossiers
|
%button.button.dropdown-button
|
||||||
|
Télécharger tous les dossiers
|
||||||
.dropdown-content.fade-in-down
|
.dropdown-content.fade-in-down
|
||||||
%ul.dropdown-items
|
%ul.dropdown-items
|
||||||
%li
|
%li
|
||||||
|
|
|
@ -43,8 +43,9 @@
|
||||||
|
|
||||||
.container
|
.container
|
||||||
- if @dossiers.present? || @current_filters.count > 0
|
- if @dossiers.present? || @current_filters.count > 0
|
||||||
%span.button.dropdown
|
%span.dropdown
|
||||||
Filtrer
|
%button.button.dropdown-button
|
||||||
|
Filtrer
|
||||||
.dropdown-content.left-aligned.fade-in-down
|
.dropdown-content.left-aligned.fade-in-down
|
||||||
= form_tag add_filter_gestionnaire_procedure_path(@procedure), method: :post, class: 'dropdown-form large' do
|
= form_tag add_filter_gestionnaire_procedure_path(@procedure), method: :post, class: 'dropdown-form large' do
|
||||||
= label_tag :field, "Colonne"
|
= label_tag :field, "Colonne"
|
||||||
|
@ -78,8 +79,9 @@
|
||||||
= render partial: "header_field", locals: { field: { "label" => "Statut", "table" => "self", "column" => "state" }, classname: "status-col" }
|
= render partial: "header_field", locals: { field: { "label" => "Statut", "table" => "self", "column" => "state" }, classname: "status-col" }
|
||||||
|
|
||||||
%th.follow-col
|
%th.follow-col
|
||||||
%span.button.dropdown
|
%span.dropdown
|
||||||
Personnaliser
|
%button.button.dropdown-button
|
||||||
|
Personnaliser
|
||||||
.dropdown-content.fade-in-down
|
.dropdown-content.fade-in-down
|
||||||
= form_tag update_displayed_fields_gestionnaire_procedure_path(@procedure), method: :patch, class: 'dropdown-form columns-form' do
|
= form_tag update_displayed_fields_gestionnaire_procedure_path(@procedure), method: :patch, class: 'dropdown-form columns-form' do
|
||||||
= select_tag :values,
|
= select_tag :values,
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
= link_to "Télécharger", pj.content_url, class: "link", target: :blank
|
= link_to "Télécharger", pj.content_url, class: "link", target: :blank
|
||||||
- if pjs.present?
|
- if pjs.present?
|
||||||
%br
|
%br
|
||||||
%span.button.dropdown
|
%span.dropdown
|
||||||
anciennes versions
|
%button.button.dropdown-button
|
||||||
|
anciennes versions
|
||||||
.dropdown-content.fade-in-down
|
.dropdown-content.fade-in-down
|
||||||
%ul.dropdown-items
|
%ul.dropdown-items
|
||||||
- pjs.each do |pj|
|
- pjs.each do |pj|
|
||||||
|
|
|
@ -82,23 +82,23 @@ feature "procedure filters" do
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_filter(column_name, filter_value)
|
def add_filter(column_name, filter_value)
|
||||||
find(:xpath, "//span[contains(text(), 'Filtrer')]").click
|
click_on 'Filtrer'
|
||||||
select column_name, from: "Colonne"
|
select column_name, from: "Colonne"
|
||||||
fill_in "Valeur", with: filter_value
|
fill_in "Valeur", with: filter_value
|
||||||
click_button "Ajouter le filtre"
|
click_button "Ajouter le filtre"
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_column(column_name)
|
def add_column(column_name)
|
||||||
find(:xpath, "//span[contains(text(), 'Personnaliser')]").click
|
click_on 'Personnaliser'
|
||||||
find("span.select2-container").click
|
find("span.select2-container").click
|
||||||
find(:xpath, "//li[text()='#{column_name}']").click
|
find(:xpath, "//li[text()='#{column_name}']").click
|
||||||
click_button "Enregistrer"
|
click_button "Enregistrer"
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_column(column_name)
|
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, "//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"
|
click_button "Enregistrer"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -178,7 +178,7 @@ feature 'Invitations' do
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_invite_to(invited_email)
|
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)
|
expect(page).to have_button("Envoyer une invitation", visible: true)
|
||||||
|
|
||||||
fill_in 'invite_email', with: invited_email
|
fill_in 'invite_email', with: invited_email
|
||||||
|
|
Loading…
Reference in a new issue