style(admin): fix archives table

This commit is contained in:
Colin Darie 2024-11-13 18:40:09 +01:00
parent 9bec007dfa
commit 77f88bbbbe
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
13 changed files with 98 additions and 104 deletions

View file

@ -1,19 +0,0 @@
@import 'constants';
table.archive-table {
.text-right {
text-align: right;
}
.center {
text-align: center;
}
td {
padding: 3 * $default-spacer $default-spacer;
}
a.button {
background-image: none; // remove DSFR underline
}
}

View file

@ -10,10 +10,6 @@
white-space: nowrap; white-space: nowrap;
} }
.number-col {
font-variant-numeric: tabular-nums;
}
.follow-col { .follow-col {
.fr-btn { .fr-btn {
margin-bottom: 0; margin-bottom: 0;

View file

@ -248,3 +248,7 @@ input[type='radio'] {
.fr-tags-group > li { .fr-tags-group > li {
line-height: inherit; line-height: inherit;
} }
.fr-cell--numeric {
font-variant-numeric: tabular-nums;
}

View file

@ -16,31 +16,38 @@
%li %li
= t(".deleted_explanation_second_#{role}") = t(".deleted_explanation_second_#{role}")
.fr-table.fr-table--layout-fixed.fr-mt-3w .fr-table
%table .fr-table__wrapper
%thead .fr-table__container
%tr .fr-table__content
%th N° dossier %table
%th Libellé de la démarche %thead
%th Raison de suppression %tr
%th Date de suppression %th N° dossier
%tbody %th Libellé de la démarche
- @deleted_dossiers.each do |deleted_dossier| %th Raison de suppression
%tr %th Date de suppression
%td.number-col %tbody
= deleted_dossier.dossier_id - @deleted_dossiers.each do |deleted_dossier|
%tr
%td.fr-cell--numeric
= deleted_dossier.dossier_id
%td.number-col %td.fr-cell--numeric
= deleted_dossier.procedure.libelle.truncate_words(10) = deleted_dossier.procedure.libelle.truncate_words(10)
%td %td
= deletion_reason_badge(deleted_dossier.reason) = deletion_reason_badge(deleted_dossier.reason)
-# .fr-badge -# .fr-badge
-# = t("activerecord.attributes.deleted_dossier.reason.#{deleted_dossier.reason}") -# = t("activerecord.attributes.deleted_dossier.reason.#{deleted_dossier.reason}")
%td.deleted-cell %td.deleted-cell
= l(deleted_dossier.deleted_at, format: '%d/%m/%y') = l(deleted_dossier.deleted_at, format: '%d/%m/%y')
= paginate @deleted_dossiers, views_prefix: 'shared' .fr-table__footer
.fr-table__footer--start
.fr-table__footer--middle
= paginate @deleted_dossiers, views_prefix: 'shared'
.fr-table__footer--end.flex-no-grow
- else - else
%p %p

View file

@ -4,12 +4,14 @@
['Export et Archives']] } ['Export et Archives']] }
.container.flex .fr-container.flex
%h1.mb-2.mr-2 %h1
Archives Archives
-# index not renderable as administrateur flagged as manager, so render it anyway -# index not renderable as administrateur flagged as manager, so render it anyway
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_url: method(:download_admin_procedure_exports_path), show_export_template_tab: false) .fr-ml-2w.fr-my-1w
.container = render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_url: method(:download_admin_procedure_exports_path), show_export_template_tab: false)
.fr-container
= render Dossiers::ExportLinkComponent.new(procedure: @procedure, exports: @exports, export_url: method(:download_admin_procedure_exports_path)) = render Dossiers::ExportLinkComponent.new(procedure: @procedure, exports: @exports, export_url: method(:download_admin_procedure_exports_path))
= render partial: "shared/archives/notice" = render partial: "shared/archives/notice"

View file

@ -42,7 +42,7 @@
%tbody %tbody
- @avis.each do |avis| - @avis.each do |avis|
%tr %tr
%td.number-col %td.fr-cell--numeric
= link_to(expert_avis_path(avis.procedure, avis), class: 'cell-link') do = link_to(expert_avis_path(avis.procedure, avis), class: 'cell-link') do
= avis.dossier.id = avis.dossier.id
%td= link_to(avis.dossier.user_email_for(:display), expert_avis_path(avis.procedure, avis), class: 'cell-link') %td= link_to(avis.dossier.user_email_for(:display), expert_avis_path(avis.procedure, avis), class: 'cell-link')

View file

@ -127,7 +127,7 @@
aria: { label: t('views.instructeurs.dossiers.batch_operation.enabled', dossier_id: p.dossier_id) } aria: { label: t('views.instructeurs.dossiers.batch_operation.enabled', dossier_id: p.dossier_id) }
= label_tag dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}"), "Sélectionner le dossier #{p.dossier_id}", class: 'fr-label' = label_tag dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}"), "Sélectionner le dossier #{p.dossier_id}", class: 'fr-label'
%td.number-col %td.fr-cell--numeric
- if p.hidden_by_administration_at.present? - if p.hidden_by_administration_at.present?
%span.cell-link= p.dossier_id %span.cell-link= p.dossier_id
- else - else

View file

@ -1,4 +1,4 @@
%td.number-col %td.fr-cell--numeric
%p.cell-link= p.dossier_id %p.cell-link= p.dossier_id
%td %td

View file

@ -36,7 +36,7 @@
%tr{ class: [p.hidden_by_administration_at.present? && "file-hidden-by-user"] } %tr{ class: [p.hidden_by_administration_at.present? && "file-hidden-by-user"] }
- if instructeur_and_expert_dossier - if instructeur_and_expert_dossier
%td.number-col %td.fr-cell--numeric
.cell-link.relative .cell-link.relative
= p.dossier_id = p.dossier_id
- if @notifications_dossier_ids.include?(p.dossier_id) - if @notifications_dossier_ids.include?(p.dossier_id)
@ -52,7 +52,7 @@
= render partial: "recherche/hidden_dossier", locals: {p: p, procedure_libelle: procedure_libelle, user_email: user_email} = render partial: "recherche/hidden_dossier", locals: {p: p, procedure_libelle: procedure_libelle, user_email: user_email}
- else - else
%td.number-col %td.fr-cell--numeric
%a.cell-link.relative{ href: path } %a.cell-link.relative{ href: path }
= p.dossier_id = p.dossier_id
- if @notifications_dossier_ids.include?(p.dossier_id) - if @notifications_dossier_ids.include?(p.dossier_id)

View file

@ -1,32 +1,36 @@
%table.archive-table .fr-table.fr-table--bordered.fr-my-4w
%thead .fr-table__wrapper
%tr .fr-table__container
%th   .fr-table__content
%th.text-right Nombre de dossiers terminés %table
%th.text-right Poids estimé %thead
%th.center Télécharger %tr
%th{ scope: 'col' }
%th.fr-cell---right{ scope: 'col' } Nombre de dossiers terminés
%th.fr-cell---right{ scope: 'col' } Poids estimé
%th{ scope: 'col' } Télécharger
%tbody %tbody
- count_dossiers_termines_by_month.each do |date, count| - count_dossiers_termines_by_month.each do |date, count|
- matching_archive = archives.find { |archive| archive.time_span_type == 'monthly' && archive.month == date } - matching_archive = archives.find { |archive| archive.time_span_type == 'monthly' && archive.month == date }
- weight = estimate_weight(matching_archive, count, average_dossier_weight) - weight = estimate_weight(matching_archive, count, average_dossier_weight)
%tr %tr
%td %td
= I18n.l(date, format: "%B %Y").capitalize = I18n.l(date, format: "%B %Y").capitalize
%td.text-right %td.fr-cell--right.fr-cell--numeric
= count = count
%td.text-right %td.fr-cell--right
= number_to_human_size(weight) = number_to_human_size(weight)
%td.center %td
- if matching_archive.present? - if matching_archive.present?
- if matching_archive.available? - if matching_archive.available?
= link_to url_for(matching_archive.file), class: 'fr-btn fr-btn--secondary fr-icon-download-line fr-btn--icon-left fr-btn--sm' do = link_to url_for(matching_archive.file), class: 'fr-btn fr-btn--secondary fr-icon-download-line fr-btn--icon-left fr-btn--sm' do
= t(:archive_ready_html, scope: [:instructeurs, :procedure], generated_period: time_ago_in_words(matching_archive.updated_at)) = t(:archive_ready_html, scope: [:instructeurs, :procedure], generated_period: time_ago_in_words(matching_archive.updated_at))
- else - else
= dsfr_icon("fr-icon-flashlight-line", :sm) = dsfr_icon("fr-icon-flashlight-line", :sm)
= t(:archive_pending_html, scope: [:instructeurs, :procedure], created_period: time_ago_in_words(matching_archive.created_at)) = t(:archive_pending_html, scope: [:instructeurs, :procedure], created_period: time_ago_in_words(matching_archive.created_at))
- elsif weight.nil? || weight < Archive::MAX_SIZE - elsif weight.nil? || weight < Archive::MAX_SIZE
= link_to "Demander la création", create_archive_url(procedure, date), method: :post, class: "fr-btn fr-btn--secondary fr-icon-download-line fr-btn--icon-left fr-btn--sm" = link_to "Demander la création", create_archive_url(procedure, date), method: :post, class: "fr-btn fr-btn--secondary fr-icon-download-line fr-btn--icon-left fr-btn--sm"
- else - else
Archive trop volumineuse Archive trop volumineuse

View file

@ -32,7 +32,7 @@ describe 'Creating a new procedure', js: true do
# check archive # check archive
expect { expect {
page.first(".archive-table .fr-btn").click page.first(".fr-table .fr-btn").click
}.to have_enqueued_job(ArchiveCreationJob).with(procedure, an_instance_of(Archive), administrateur) }.to have_enqueued_job(ArchiveCreationJob).with(procedure, an_instance_of(Archive), administrateur)
expect(page).to have_content("Votre demande a été prise en compte. Selon le nombre de dossiers, cela peut prendre de quelques minutes à plusieurs heures. Vous recevrez un courriel lorsque le fichier sera disponible.") expect(page).to have_content("Votre demande a été prise en compte. Selon le nombre de dossiers, cela peut prendre de quelques minutes à plusieurs heures. Vous recevrez un courriel lorsque le fichier sera disponible.")
expect(Archive.first.month).not_to be_nil expect(Archive.first.month).not_to be_nil

View file

@ -208,7 +208,7 @@ describe 'Instructing a dossier:', js: true do
end end
scenario 'download' do scenario 'download' do
expect { expect {
page.first(".archive-table .fr-btn").click page.first(".fr-table .fr-btn").click
}.to have_enqueued_job(ArchiveCreationJob).with(procedure, an_instance_of(Archive), instructeur) }.to have_enqueued_job(ArchiveCreationJob).with(procedure, an_instance_of(Archive), instructeur)
expect(Archive.first.month).not_to be_nil expect(Archive.first.month).not_to be_nil
end end

View file

@ -19,18 +19,18 @@ describe "procedure sort", js: true do
scenario "should be able to sort with header" do scenario "should be able to sort with header" do
# sorted by notifications (updated_at desc) by default, filtered by followed # sorted by notifications (updated_at desc) by default, filtered by followed
expect(all(".dossiers-table tbody tr").count).to eq(3) expect(all(".dossiers-table tbody tr").count).to eq(3)
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
click_on " dossier" # sort by id asc click_on " dossier" # sort by id asc
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
click_on " dossier" # reverse order - sort by id desc click_on " dossier" # reverse order - sort by id desc
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
end end
scenario "should be able to sort with header with sva date" do scenario "should be able to sort with header with sva date" do
@ -41,20 +41,20 @@ describe "procedure sort", js: true do
visit instructeur_procedure_path(procedure, statut: "suivis") visit instructeur_procedure_path(procedure, statut: "suivis")
# sorted by notifications (updated_at desc) by default, filtered by followed # sorted by notifications (updated_at desc) by default, filtered by followed
expect(all(".dossiers-table tbody tr").count).to eq(3) expect(all(".dossiers-table tbody tr").count).to eq(3)
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
click_on "Date décision SVA", exact: true # sort by sva date asc click_on "Date décision SVA", exact: true # sort by sva date asc
# find("thead .sva-col a").click # sort by sva date asc # find("thead .sva-col a").click # sort by sva date asc
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
click_on "Date décision SVA ", exact: true # reverse order - sort by sva date desc click_on "Date décision SVA ", exact: true # reverse order - sort by sva date desc
# find("thead .sva-col a").click # reverse order - sort by sva date desc # find("thead .sva-col a").click # reverse order - sort by sva date desc
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
end end
scenario "should be able to sort with direct link to notification sort" do scenario "should be able to sort with direct link to notification sort" do
@ -65,14 +65,14 @@ describe "procedure sort", js: true do
find("label", text: "Remonter les dossiers avec une notification").click # reverse order - sort by updated_at asc find("label", text: "Remonter les dossiers avec une notification").click # reverse order - sort by updated_at asc
expect(page).not_to have_checked_field("Remonter les dossiers avec une notification") expect(page).not_to have_checked_field("Remonter les dossiers avec une notification")
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
find("label", text: "Remonter les dossiers avec une notification").click # set order back - sort by updated_at desc find("label", text: "Remonter les dossiers avec une notification").click # set order back - sort by updated_at desc
expect(page).to have_checked_field("Remonter les dossiers avec une notification") expect(page).to have_checked_field("Remonter les dossiers avec une notification")
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
end end
scenario "should be able to sort back by notification filter after any other sort" do scenario "should be able to sort back by notification filter after any other sort" do
@ -83,7 +83,7 @@ describe "procedure sort", js: true do
find("label", text: "Remonter les dossiers avec une notification").click # sort by updated_at desc find("label", text: "Remonter les dossiers avec une notification").click # sort by updated_at desc
expect(page).to have_checked_field("Remonter les dossiers avec une notification") expect(page).to have_checked_field("Remonter les dossiers avec une notification")
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(2) .fr-cell--numeric a").text).to eq(followed_dossier.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier_2.id.to_s) expect(find(".dossiers-table tbody tr:nth-child(3) .fr-cell--numeric a").text).to eq(followed_dossier_2.id.to_s)
end end
end end