Module: LabelsHelper
- Defined in:
- app/helpers/labels_helper.rb
Instance Method Summary collapse
- #label_code_128_tag(label) ⇒ Object
- #label_link(label) ⇒ Object
- #label_svg_tag(label) ⇒ Object
-
#taxonworks_label_tag(label) ⇒ Object
!! Note that `label_tag` is a Rails reserved word, so we have to append and make exceptions.
Instance Method Details
#label_code_128_tag(label) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/helpers/labels_helper.rb', line 56 def label_code_128_tag(label) c = Barby::Code128.new(label.text) content_tag( :span, content_tag( :span, c.to_svg(xmargin: 0, ymargin: 0).html_safe, class: :code128_barcode ) + content_tag(:span, label.text, class: 'code128_text'), class: :code128 ) end |
#label_link(label) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/helpers/labels_helper.rb', line 22 def label_link(label) return nil if label.nil? if label.label_object_id.blank? taxonworks_label_tag(label) else link_to(content_tag(:span, label.text), print_labels_task_path(label_id: label.to_param)) end end |
#label_svg_tag(label) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/labels_helper.rb', line 31 def label_svg_tag(label) c = ::RQRCode::QRCode.new(label.text) content_tag( :span, content_tag(:span, label.text, class: 'qrcode_text') + content_tag( :span, c.as_svg( offset: 0, color: '000', shape_rendering: 'crispEdges', module_size: 1, standalone: true, viewbox: true, svg_attributes: { class: :qrcode_svg } ).to_s.html_safe, class: :qrcode_barcode ), class: :qrcode ) end |
#taxonworks_label_tag(label) ⇒ Object
!! Note that `label_tag` is a Rails reserved word, so we have to append and make exceptions
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/labels_helper.rb', line 10 def taxonworks_label_tag(label) return nil if label.nil? case label.type when 'Label::QrCode' label_svg_tag(label) when 'Label::Code128' label_code_128_tag(label) else content_tag(:span, label.text, style: label.style) # TODO: properly reference style end end |