From c6a2cb02407a213d5d4240107d1bacbac79d2d4d Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Fri, 26 Apr 2024 16:47:19 +0200 Subject: [PATCH 1/4] style(gallery): update gallery demande UI --- app/assets/images/apercu-indisponible.png | Bin 5870 -> 5467 bytes app/assets/stylesheets/gallery.scss | 35 +++++++++--------- .../piece_justificative/_show.html.haml | 35 ++++++++++-------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/app/assets/images/apercu-indisponible.png b/app/assets/images/apercu-indisponible.png index 83ed22706fb540ec63bd502381ffd732d2a51b09..6bebd9f59de194d5d5eab6847ac31e31c5d5a4d4 100644 GIT binary patch delta 4290 zcmXw6c|6nqAE)F>k;pL#B`HU~vIv`$4nno$wxrB`Eu+{zu5`Idk%UsnHFDe7ikKso zyKU}?!Yt?5Z2PT0e((R@kN5ledcThM`}umlmvm{z(;Nci{$4(R_C};IW6V5hbhuIU z7F)w%@PhBJVQWzRHQjnt%#Bb`L3m8Vbs2}fw@!z?uL*r+8C2lnn**Ld@Yt{5l`Fg{ zDm1$Ia9H9t3V||ypnA*G2H&bq_914PL1&^A6cnIRLY4h|DWR)s)#}1$h0}i=5KB)J zb^)MDlb1Y*81ts+t+2@T`Jumh_$by=2xo&KTxS;(B4?j#rj%8R9#_gU z-QC=_PkxEro;^);UPCrElbWMgiO6)Tmku|}kn^Km3F&E3=Oofj*Phs?-csEEaF^DV zhyz7e1jhDjyge?w1EhA|*lLFe*z$3RpNM$CW0|R!;xa!K1$$-GD$iObz|<^m0Ur{? zPus?PNtD)B?GT9(_-pY*Nci11!@jAQy~}S|3i=*W6&}sXlZ688J27chsS(C9oz%KI zM;2@F#Z?L&+ovWZa7D;kL_FPAcv`K~Ues9lA0ihDKq}!>NxN8~sUuC1%hM~nf9`d6 zO8+Xn-+Sua(s;9Jh+&QSqkkzD6lu?>R3Q1igv{RKR#((b38@hFB|I|Z|7kP7zcRD( ztQ8l&FdV|?ai`MlAxe`!M8q$yvey@;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QctLoNd%w=9osZk`{%FkuqNmHm?CsL`C;v+arqXj%TwQ{h*)wsz4OG5 z09*N=PZdfl$nLWZU=c#Oh8O|-EqdYQYoo1Y0B@m|U&?G}5bv$#Dy*YD2)ypb4f^YW zr$ZYW)P&tn+7U`bN}5=(#9x+&162zC{QIf%=*OF>6d(j?U-<|fG&H_%xt>-Ee;TUO z8l*FqVD9#@Oum^rki1nByi-v)p``hFbZQ0WyHD+W+4A7-pN4xFmW{x4K>NFr3aV>2 zCaE)&1J5BH&Tr)srqMtRJx?&-?^7bvEnj0#bC$nLC#!Md zXofp513O`9yL{kMN*^pu+DwM-WwBV`kQ@ydC7?ZsELF4K4EQm&j*#vUf_B7;y!rd# zs%!7BtFT^b9BSkVIgOf_wxPCTy@;M<^XPg!K0vJb+56X#`L-hp?1b|i%`0YHtwDuZ zy^W}?+3bhRperwfvk65-Zv543X4*_AyA^F@&2{52-97`KPKeJ9~~)Gv_#CG>8h!m&grX^Sd+4JGrY7U&DwhBf-J}mYKga z+Sz5EyPs_`b?l5$4-$_Ig8?q~atAO;th`GL$R4gO&$TAxN8hs_3ma4Lxui9&DLv}D zi*Q1RN6iT7BIeMtJ%>@MOVY+EPrtm2g9NWxS6Hcm)$oy4rd(MGHi?Q8$bbhsQcKVo zg zcpQE}ENGX_p7%Yu4)%DF`MlCzIqacoZKGALLjQ2Z*jbTvW^IxJ|NdkK@zH?ZGk6}G znqJf7c~C=tD11V!UrxJSDuk~4;`rd{e(s%0L{FeZKia%sy*ZIL1IDHg+@h{h{W5zI%gb+ z9xvdp(BHjTH}8%i{_UPI;ApjxFa@u*Yb%(S{Ol0a5WVDbETg|MIZR5tcJO~aXLos= z!UEp|t>LBd)6ez}1-v9sr diff --git a/app/assets/stylesheets/gallery.scss b/app/assets/stylesheets/gallery.scss index 55580c607..eb2bec9ee 100644 --- a/app/assets/stylesheets/gallery.scss +++ b/app/assets/stylesheets/gallery.scss @@ -33,16 +33,18 @@ color: var(--text-active-blue-france); border: 1px solid var(--border-active-blue-france); padding: 0.25rem 0.75rem; - - &:hover { - background-color: var(--hover-tint); - } - - &:active { - background-color: var(--active-tint); - } + display: none; } } + + a.gallery-link:hover .fr-btn, + a.gallery-link:active .fr-btn { + display: flex; + } + + a.gallery-link:active .fr-btn { + background-color: var(--hover-tint); + } } .gallery-pieces-jointes { @@ -52,17 +54,16 @@ .gallery-item { margin: 0 2rem 1.5rem 0; } - - img { - height: 200px; - width: 200px; - } } .gallery-demande { - img { - height: 150px; - width: 150px; + .gallery-items-list { + display: flex; + flex-wrap: wrap; + } + + .gallery-item { + margin: 0.5rem 2rem 1rem 0; } .fr-download { @@ -71,7 +72,7 @@ .thumbnail { width: fit-content; - margin-bottom: 1rem; + margin-bottom: 0.5rem; } } diff --git a/app/views/shared/champs/piece_justificative/_show.html.haml b/app/views/shared/champs/piece_justificative/_show.html.haml index 525546d8f..50218e54b 100644 --- a/app/views/shared/champs/piece_justificative/_show.html.haml +++ b/app/views/shared/champs/piece_justificative/_show.html.haml @@ -4,21 +4,24 @@ - champ.piece_justificative_file.attachments.each do |attachment| %li= render Attachment::ShowComponent.new(attachment:, new_tab: true) - else - - champ.piece_justificative_file.attachments.each do |attachment| - %ul - %li= render Attachment::ShowComponent.new(attachment:, new_tab: true, truncate: true) - .gallery-item - - blob = attachment.blob - - if blob.content_type.in?(AUTHORIZED_PDF_TYPES) - = link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do - .thumbnail - = image_tag("pdf-placeholder.png") - .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button } - = 'Visualiser' + .gallery-items-list + - champ.piece_justificative_file.attachments.each do |attachment| + .gallery-item + - blob = attachment.blob + - if blob.content_type.in?(AUTHORIZED_PDF_TYPES) + = link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do + .thumbnail + = image_tag("pdf-placeholder.png") + .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button } + = 'Visualiser' - - elsif blob.content_type.in?(AUTHORIZED_IMAGE_TYPES) - = link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do + - elsif blob.content_type.in?(AUTHORIZED_IMAGE_TYPES) + = link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do + .thumbnail + = image_tag(attachment.variant(:medium), loading: :lazy) + .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button } + = 'Visualiser' + - else .thumbnail - = image_tag(attachment.variant(:small), loading: :lazy) - .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button } - = 'Visualiser' + = image_tag('apercu-indisponible.png') + = render Attachment::ShowComponent.new(attachment:, new_tab: true, truncate: true) From 479fdb9dbee1a952775e7d569e9e13dea690f90d Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Tue, 30 Apr 2024 17:22:29 +0200 Subject: [PATCH 2/4] feat(gallery): can close gallery when clicking on browser back button --- app/javascript/controllers/lightbox_controller.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/javascript/controllers/lightbox_controller.ts b/app/javascript/controllers/lightbox_controller.ts index 8d4660d70..49e53ecd0 100644 --- a/app/javascript/controllers/lightbox_controller.ts +++ b/app/javascript/controllers/lightbox_controller.ts @@ -4,6 +4,7 @@ import { LightGallery } from 'lightgallery/lightgallery'; import lgThumbnail from 'lightgallery/plugins/thumbnail'; import lgZoom from 'lightgallery/plugins/zoom'; import lgRotate from 'lightgallery/plugins/rotate'; +import lgHash from 'lightgallery/plugins/hash'; import 'lightgallery/css/lightgallery-bundle.css'; export default class extends Controller { @@ -11,7 +12,7 @@ export default class extends Controller { connect(): void { const options = { - plugins: [lgZoom, lgThumbnail, lgRotate], + plugins: [lgZoom, lgThumbnail, lgRotate, lgHash], flipVertical: false, flipHorizontal: false, animateThumb: false, @@ -21,6 +22,14 @@ export default class extends Controller { selector: '.gallery-link' }; + const gallery = document.querySelector('.gallery'); + + if (gallery != null) { + gallery.addEventListener('lgBeforeOpen', () => { + window.history.pushState({}, 'Gallery opened'); + }); + } + this.lightGallery = lightGallery(this.element as HTMLElement, options); const downloadIcon = document.querySelector('.lg-download'); From db8de9e657541bf397024f4fa7c17fb846af0952 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Fri, 3 May 2024 14:41:17 +0200 Subject: [PATCH 3/4] fix(gallery): display attachments tab only if attachments in dossier --- .../dossiers/_header_bottom.html.haml | 2 +- .../dossiers/pieces_jointes.html.haml | 64 +++++++++---------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/app/views/instructeurs/dossiers/_header_bottom.html.haml b/app/views/instructeurs/dossiers/_header_bottom.html.haml index ce922e524..0358c4aa0 100644 --- a/app/views/instructeurs/dossiers/_header_bottom.html.haml +++ b/app/views/instructeurs/dossiers/_header_bottom.html.haml @@ -7,7 +7,7 @@ instructeur_dossier_path(dossier.procedure, dossier), notification: notifications_summary[:demande]) - - if dossier.revision.types_de_champ.any?(&:piece_justificative?) + - if dossier.champs.map(&:piece_justificative_file).flatten.any? = dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.attachments'), pieces_jointes_instructeur_dossier_path(dossier.procedure, dossier)) diff --git a/app/views/instructeurs/dossiers/pieces_jointes.html.haml b/app/views/instructeurs/dossiers/pieces_jointes.html.haml index 386a31852..a0b1816a1 100644 --- a/app/views/instructeurs/dossiers/pieces_jointes.html.haml +++ b/app/views/instructeurs/dossiers/pieces_jointes.html.haml @@ -3,38 +3,34 @@ = render partial: "header", locals: { dossier: @dossier } .fr-container - - if @champs_with_pieces_jointes.map(&:piece_justificative_file).flatten.none? - .empty-text - Ce dossier ne contient pas de pièces jointes - - else - .gallery.gallery-pieces-jointes{ "data-controller": "lightbox" } - - @champs_with_pieces_jointes.each do |champ| - - champ.piece_justificative_file.each do |attachment| - .gallery-item - - blob = attachment.blob - - if blob.content_type.in?(AUTHORIZED_PDF_TYPES) - = link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do - .thumbnail - = image_tag("pdf-placeholder.png") - .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button } - Visualiser - .champ-libelle - = champ.libelle.truncate(25) - = render Attachment::ShowComponent.new(attachment: attachment, truncate: true) - - - elsif blob.content_type.in?(AUTHORIZED_IMAGE_TYPES) - = link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do - .thumbnail - = image_tag(attachment.variant(:medium), loading: :lazy) - .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button } - Visualiser - .champ-libelle - = champ.libelle.truncate(25) - = render Attachment::ShowComponent.new(attachment: attachment, truncate: true) - - - else + .gallery.gallery-pieces-jointes{ "data-controller": "lightbox" } + - @champs_with_pieces_jointes.each do |champ| + - champ.piece_justificative_file.each do |attachment| + .gallery-item + - blob = attachment.blob + - if blob.content_type.in?(AUTHORIZED_PDF_TYPES) + = link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do .thumbnail - = image_tag('apercu-indisponible.png') - .champ-libelle - = champ.libelle.truncate(25) - = render Attachment::ShowComponent.new(attachment: attachment, truncate: true) + = image_tag("pdf-placeholder.png") + .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button } + Visualiser + .champ-libelle + = champ.libelle.truncate(25) + = render Attachment::ShowComponent.new(attachment: attachment, truncate: true) + + - elsif blob.content_type.in?(AUTHORIZED_IMAGE_TYPES) + = link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do + .thumbnail + = image_tag(attachment.variant(:medium), loading: :lazy) + .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button } + Visualiser + .champ-libelle + = champ.libelle.truncate(25) + = render Attachment::ShowComponent.new(attachment: attachment, truncate: true) + + - else + .thumbnail + = image_tag('apercu-indisponible.png') + .champ-libelle + = champ.libelle.truncate(25) + = render Attachment::ShowComponent.new(attachment: attachment, truncate: true) From 3d5e0043a6649d5058e2911f2b772574bb98aefd Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Mon, 6 May 2024 15:50:19 +0200 Subject: [PATCH 4/4] refacto: remove unused small variant --- app/models/champs/piece_justificative_champ.rb | 1 - app/models/champs/titre_identite_champ.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/app/models/champs/piece_justificative_champ.rb b/app/models/champs/piece_justificative_champ.rb index 8d9435d17..b6dfb0bef 100644 --- a/app/models/champs/piece_justificative_champ.rb +++ b/app/models/champs/piece_justificative_champ.rb @@ -2,7 +2,6 @@ class Champs::PieceJustificativeChamp < Champ FILE_MAX_SIZE = 200.megabytes has_many_attached :piece_justificative_file do |attachable| - attachable.variant :small, resize: '300x300' attachable.variant :medium, resize: '400x400' end diff --git a/app/models/champs/titre_identite_champ.rb b/app/models/champs/titre_identite_champ.rb index 05b67e802..667feca7e 100644 --- a/app/models/champs/titre_identite_champ.rb +++ b/app/models/champs/titre_identite_champ.rb @@ -3,7 +3,6 @@ class Champs::TitreIdentiteChamp < Champ ACCEPTED_FORMATS = ['image/png', 'image/jpeg'] has_many_attached :piece_justificative_file do |attachable| - attachable.variant :small, resize: '300x300' attachable.variant :medium, resize: '400x400' end