From f02cb19fd4c042c49a332b1466b539caa21ff8a2 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Mon, 8 Apr 2024 10:23:07 +0200 Subject: [PATCH] feat(gallery): display pieces jointes in a gallery --- app/assets/images/apercu-indisponible.png | Bin 0 -> 9794 bytes app/assets/images/pdf-placeholder.png | Bin 0 -> 6912 bytes app/assets/stylesheets/gallery.scss | 66 ++++++++++++++++++ app/assets/stylesheets/icons.scss | 8 +++ .../instructeurs/dossiers_controller.rb | 7 ++ .../controllers/lightbox_controller.ts | 36 ++++++++++ .../dossiers/_header_bottom.html.haml | 4 ++ .../dossiers/pieces_jointes.html.haml | 29 ++++++++ config/locales/en.yml | 1 + config/locales/fr.yml | 1 + config/routes.rb | 1 + package.json | 1 + .../instructeurs/dossiers_controller_spec.rb | 25 +++++++ 13 files changed, 179 insertions(+) create mode 100644 app/assets/images/apercu-indisponible.png create mode 100644 app/assets/images/pdf-placeholder.png create mode 100644 app/assets/stylesheets/gallery.scss create mode 100644 app/javascript/controllers/lightbox_controller.ts create mode 100644 app/views/instructeurs/dossiers/pieces_jointes.html.haml diff --git a/app/assets/images/apercu-indisponible.png b/app/assets/images/apercu-indisponible.png new file mode 100644 index 0000000000000000000000000000000000000000..11d399fdac14eb080e60113a948d5bf90e99f17a GIT binary patch literal 9794 zcmeHsXIPU>w>2OF0tzZ3HcF&O2?-(eUPS2#NRt*)AV4Sy9RU#m>Agu)0qG#1ROwB6 z6A?lY5do2^(#v;)KJ7c_&wH+O{ykiGLNc@Wn%QgC?AdcANK50^Y3j?=BqSuKm2WF* z1OK~$R|gdZ@NT~{AxA<&qvxS(;G~UkWp%*YW3aYpRws7{G%MN-iyvP6mwv2(wiqa z()y2Qmgov4=ZaT2J@{iMp0{*(XuL~1Kl@{gO`2;y0%tOoS3BACA!6qHLEx1wx`UE- zq4b!E;?1d$=~|A07@aY(FCl#?=@h6#2%D=$=RP-W=%}dXW?b|V_SBi}ZcPYe?`n9m zk@U466mbbv8F@i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?>crtZy5FR<0PFolVh+FKU`jG>ebYOjd5!6>Z>pv6= zLB%nQfdvS~P;gi%8i%4o$tVO0iZNlJQCJj;L1rL-MCWlB{19>weKQlt6vze;&_Xug z^$S!Q{OBFxM;G%1N1~x{;KGm)#&{$ek3nvPBk^!J1oppA5siRjO;8jpl!2m%MFa=* zh@#S<##j^J2-3>~4q(XLyQYBL?Z z^4)%6-Wft3=fyUqgun2XWI9o(uwf7n@*pd(c8N!#dnu)HP{#JU%|Y zv%mjybN^X~b%Fc#&DIt8B&}`n$6kEAr>3@+@Vh5eCA+>zOG~Tz@#E7qGnX>gLmn2Z zD@X?(Jg9xg8y1(T=Fw=}x;@|6n2;M~*NTQ3-rN5?^jBkJW7R>msi~=Sa^(f>FSWUXUO`e;&~~ZS z_t!~{(l}nHx*2}kHkqEae=A(%5#wE;=8^0X6ZiJ$Lz8qb>BxvtNNP=*!#exfKA==@ zg<2lTHfh<2b56TGL>|}5%T3Ezfzjg1f))zBsD|%k@bBhjBe@j&ob~hJZv;tem+hOd zxl`dgQ@EBmFBq8rv!hh+;;ELenv%`7j>~lKTmxtDyh3BQgbpuHmAeN6GHV+}PnxO4 z`(E8hO#1C$#ULg*>`s6y`@vO>`lr4XAIBdNE|OgxQ{!N}@>Ji4_3G?~H>4SrcutJa z-qM&}NJhFxTxN_}QwpQ_cExWUsY(s4yHX$Cm`XckluI3pl>4gl{r8b` zs@J_nL>^%UpNEAlJyM^-!&^5Ux0x$4d$>VUMZ9|cOWwlEk>OG#mWWm2nO_)ZFm#s% zw9%SCn}t0qI+IdTQj+zNK&;62E~u-okMn&&7YHz=rKP)AtBP*k)Bq%swXZ+xg|1? 'dossiers#print' get 'telecharger_pjs' => 'dossiers#telecharger_pjs' get 'reaffectation' + get 'pieces_jointes' post 'reaffecter' end end diff --git a/package.json b/package.json index 0a2b30333..4186d3462 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "highcharts": "^10.3.3", "intersection-observer": "^0.12.2", "is-hotkey": "^0.2.0", + "lightgallery": "^2.7.2", "maplibre-gl": "^1.15.2", "match-sorter": "^6.3.4", "patch-package": "^7.0.0", diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb index f72f52003..108c675ba 100644 --- a/spec/controllers/instructeurs/dossiers_controller_spec.rb +++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb @@ -1372,4 +1372,29 @@ describe Instructeurs::DossiersController, type: :controller do it { expect(subject).to have_http_status(:ok) } end + + describe '#pieces_jointes' do + let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :piece_justificative }], instructeurs:) } + let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure: procedure) } + + before do + dossier.champs.first.piece_justificative_file.attach( + io: StringIO.new("image file"), + filename: "image.jpeg", + content_type: "image/jpeg", + # we don't want to run virus scanner on this file + metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE } + ) + get :pieces_jointes, params: { + procedure_id: procedure.id, + dossier_id: dossier.id + } + end + + it do + expect(response.body).to include('Télécharger le fichier toto.txt') + expect(response.body).to include('Télécharger le fichier image.jpeg') + expect(response.body).to include('Visualiser') + end + end end