diff --git a/Gemfile b/Gemfile index b7f5020bd4..80a1f1f86d 100644 --- a/Gemfile +++ b/Gemfile @@ -111,6 +111,9 @@ gem("fastimage") # for detecting file type of uploaded images gem("mimemagic") +# QR code support for field slips +gem("rqrcode") + # for creating zip files # RubyZip 3.0 is coming! # ********************** diff --git a/Gemfile.lock b/Gemfile.lock index 4b4e156ec4..4bff184993 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,6 +98,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + chunky_png (1.4.0) concurrent-ruby (1.2.3) connection_pool (2.4.1) crack (1.0.0) @@ -247,6 +248,10 @@ GEM requestjs-rails (0.0.11) railties (>= 6.1.0) rexml (3.2.6) + rqrcode (2.2.0) + chunky_png (~> 1.0) + rqrcode_core (~> 1.0) + rqrcode_core (1.2.0) rtf (0.3.3) rubocop (1.62.1) json (~> 2.3) @@ -391,6 +396,7 @@ DEPENDENCIES railties (~> 7.1.3) redis (~> 4.0) requestjs-rails + rqrcode rtf rubocop rubocop-performance diff --git a/app/models/field_slip.rb b/app/models/field_slip.rb index 85e56a96c9..2b97bfe897 100644 --- a/app/models/field_slip.rb +++ b/app/models/field_slip.rb @@ -39,4 +39,16 @@ def find_projects result.unshift([project.title, project.id]) end + + def qr_code(path) + qr = RQRCode::QRCode.new(path, level: :m) + qr.as_svg( + color: "000", + shape_rendering: "crispEdges", + module_size: 3, + standalone: true, + use_path: true, + fill: :white + ) + end end diff --git a/app/views/controllers/field_slips/show.html.erb b/app/views/controllers/field_slips/show.html.erb index 217f358a5e..b124ee1a1b 100644 --- a/app/views/controllers/field_slips/show.html.erb +++ b/app/views/controllers/field_slips/show.html.erb @@ -6,6 +6,10 @@