Class: Sdb::SampleManifestsController
- Inherits:
-
BaseController
- Object
- BaseController
- Sdb::SampleManifestsController
- Defined in:
- app/controllers/sdb/sample_manifests_controller.rb
Constant Summary collapse
- LIMIT_ERROR_LENGTH =
10_000
Instance Method Summary collapse
-
#create ⇒ Object
rubocop:todo Metrics/AbcSize.
- #export ⇒ Object
- #index ⇒ Object
-
#new ⇒ Object
rubocop:todo Metrics/AbcSize.
-
#print_labels ⇒ Object
rubocop:todo Metrics/MethodLength.
-
#show ⇒ Object
Show the manifest.
- #uploaded_spreadsheet ⇒ Object
Instance Method Details
#create ⇒ Object
rubocop:todo Metrics/AbcSize
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/sdb/sample_manifests_controller.rb', line 53 def create # rubocop:todo Metrics/AbcSize @sample_manifest_generator = SampleManifest::Generator.new(params[:sample_manifest], current_user, SampleManifestExcel.configuration) if @sample_manifest_generator.execute flash.update(@sample_manifest_generator.) redirect_to sample_manifest_path(@sample_manifest_generator.sample_manifest) else flash[:error] = @sample_manifest_generator.errors..join(', ') redirect_to new_sample_manifest_path end end |
#export ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'app/controllers/sdb/sample_manifests_controller.rb', line 8 def export @manifest = SampleManifest.find(params[:id]) send_data( @manifest.generated_document.current_data, filename: "#{@manifest.default_filename}.xlsx", type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ) end |
#index ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/controllers/sdb/sample_manifests_controller.rb', line 26 def index pending_sample_manifests = SampleManifest.pending_manifests.includes(:study, :supplier, :user).paginate(page: params[:page]) completed_sample_manifests = SampleManifest.completed_manifests.includes(:study, :supplier, :user).paginate(page: params[:page]) @display_manifests = pending_sample_manifests | completed_sample_manifests @sample_manifests = SampleManifest.paginate(page: params[:page]) end |
#new ⇒ Object
rubocop:todo Metrics/AbcSize
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/sdb/sample_manifests_controller.rb', line 41 def new # rubocop:todo Metrics/AbcSize params[:only_first_label] ||= false @sample_manifest = SampleManifest.new(new_manifest_params) @study_id = params[:study_id] || '' @studies = Study.alphabetical.pluck(:name, :id) @suppliers = Supplier.alphabetical.pluck(:name, :id) @purposes = @sample_manifest.acceptable_purposes.pluck(:name, :id) @rack_purposes = @sample_manifest.acceptable_rack_purposes.pluck(:name, :id) if params[:asset_type] == 'tube_rack' @barcode_printers = @sample_manifest..pluck(:name) @templates = SampleManifestExcel.configuration.manifest_types.by_asset_type(params[:asset_type]).to_a end |
#print_labels ⇒ Object
rubocop:todo Metrics/MethodLength
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/sdb/sample_manifests_controller.rb', line 66 def print_labels # rubocop:todo Metrics/MethodLength print_job = LabelPrinter::PrintJob.new( params[:printer], LabelPrinter::Label::SampleManifestRedirect, sample_manifest: @sample_manifest ) if print_job.execute flash[:notice] = print_job.success else flash[:error] = print_job.errors..join('; ') end redirect_back fallback_location: root_path end |
#show ⇒ Object
Show the manifest
36 37 38 39 |
# File 'app/controllers/sdb/sample_manifests_controller.rb', line 36 def show @study_id = @sample_manifest.study_id @samples = @sample_manifest.samples.paginate(page: params[:page]) end |
#uploaded_spreadsheet ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/controllers/sdb/sample_manifests_controller.rb', line 17 def uploaded_spreadsheet @manifest = SampleManifest.find(params[:id]) send_data( @manifest.uploaded_document.current_data, filename: @manifest.uploaded_document.filename, type: @manifest.uploaded_document.content_type || 'application/vnd.ms-excel' ) end |