Class: PlatesController

Inherits:
LabwareController show all
Defined in:
app/controllers/plates_controller.rb

Overview

show => Looks up the presenter for the given purpose and renders the appropriate show page update => Used to update the state of a plate/tube fail_wells => Updates the state of individual wells when failing Note: Finds plates via the v2 api

Instance Method Summary collapse

Instance Method Details

#fail_wellsObject

rubocop:todo Metrics/AbcSize



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/plates_controller.rb', line 10

def fail_wells # rubocop:todo Metrics/AbcSize
  if wells_to_fail.empty?
    redirect_to(
      limber_plate_path(params[:id]),
      notice: 'No wells were selected to fail' # rubocop:todo Rails/I18nLocaleTexts
    )
  else
    api.state_change.create!(
      user: current_user_uuid,
      target: params[:id],
      contents: wells_to_fail,
      target_state: 'failed',
      reason: 'Individual Well Failure',
      customer_accepts_responsibility: params[:customer_accepts_responsibility]
    )
    redirect_to(
      limber_plate_path(params[:id]),
      notice: 'Selected wells have been failed' # rubocop:todo Rails/I18nLocaleTexts
    )
  end
end

#wells_to_failObject



32
33
34
# File 'app/controllers/plates_controller.rb', line 32

def wells_to_fail
  params.fetch(:plate, {}).fetch(:wells, {}).select { |_, v| v == '1' }.keys
end