Module: BarcodeLabelsHelper
- Defined in:
- app/helpers/barcode_labels_helper.rb
Overview
rubocop:todo Style/Documentation
Instance Method Summary collapse
- #barcode_printing_form(labels:, redirection_url:, default_printer_name: @presenter.default_printer) ⇒ Object
- #printers_of_type(printer_types) ⇒ Object
- #useful_barcode(barcode) ⇒ Object
Instance Method Details
#barcode_printing_form(labels:, redirection_url:, default_printer_name: @presenter.default_printer) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/barcode_labels_helper.rb', line 4 def ( labels:, redirection_url:, default_printer_name: @presenter.default_printer # rubocop:todo Rails/HelperInstanceVariable ) # labels are Labels::PlateLabel or Labels::TubeLabel so you can get the # default layout based on the class printer_types = labels.map(&:printer_type) printers = printers_of_type(printer_types) print_job = PrintJob.new( number_of_copies: Settings.printers['default_count'], printer_name: default_printer_name, label_templates_by_service: JSON.generate(labels.first.label_templates_by_service) ) # Is redirection_url needed? locals = { print_job: print_job, printers: printers, labels: labels, redirection_url: redirection_url } render(partial: 'labware/barcode_printing_form', locals: locals) end |
#printers_of_type(printer_types) ⇒ Object
26 27 28 |
# File 'app/helpers/barcode_labels_helper.rb', line 26 def printers_of_type(printer_types) @printers.select { |printer| printer_types.include?(printer.type.name) } # rubocop:todo Rails/HelperInstanceVariable end |
#useful_barcode(barcode) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/barcode_labels_helper.rb', line 30 def () return 'Unknown' if .nil? # Support for old API human_readable = .try(:human) || "#{.prefix}#{.number}" if human_readable == .machine human_readable else "#{human_readable} <em>#{.machine}</em>".html_safe # rubocop:todo Rails/OutputSafety end end |