Skip to content

Commit

Permalink
Render vcard qrcode inline
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-illi committed Feb 26, 2024
1 parent d6c6663 commit be31cab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 1 addition & 5 deletions app/assets/stylesheets/_employees.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@

.master-data-vcard-qrcode {
display: block;
width: 100px;
width: 200px;
padding-bottom: 1em;

@media (min-width: $screen-md-min) {
padding-top: 20px;
}
}

.employee-positions {
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/employee_master_data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def show

respond_to do |format|
format.html
format.vcf { render plain: vcard }
format.vcf { send_data vcard, filename: vcard_filename }
format.svg { render plain: qr_code.as_svg(fill: 'fff') }
format.png { render plain: qr_code.as_png(fill: 'fff') }
end
Expand Down Expand Up @@ -107,6 +107,10 @@ def vcard(include: nil)
Employees::Vcard.new(@employee, include: include).render
end

def vcard_filename
ActiveStorage::Filename.new("#{@employee.to_s}.vcf").sanitized
end

def qr_code
vcf = vcard(include: %i[firstname lastname fullname phone_office phone_private email])
RQRCode::QRCode.new(vcf)
Expand Down
2 changes: 1 addition & 1 deletion app/views/employee_master_data/_attrs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
= link_to @employee.email, "mailto:#{@employee.email}"
.col-md-6
= link_to({format: :png}, target: :_blank) do
= image_tag('qr-code-scan-icon.svg', class: 'qr-code master-data-vcard-qrcode')
%img.qr-code.master-data-vcard-qrcode{src: employee_master_datum_url(id: @employee.id, format: :svg) }
= link_to format: :vcf do
vCard herunterladen

Expand Down

0 comments on commit be31cab

Please sign in to comment.