Class: TagLayoutTemplatesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tag_layout_templates_controller.rb

Overview

This class handles creating and viewing Tag Layout Templates, which describe how the Tags in a Tag Group are to be laid out in their labware container. For example that they should be laid out column by column across a plate. Initially the direction algorithm choices have been restricted to a small subset, and the walking direction is fixed to wells of plate.

Constant Summary collapse

DIRECTIONS =
{
  'InColumns (A1,B1,C1...)': 'TagLayout::InColumns',
  'InRows (A1,A2,A3...)': 'TagLayout::InRows',
  'InInverseColumns (H12,G12,F12...)': 'TagLayout::InInverseColumns',
  'InInverseRows (H12,H11,H10...)': 'TagLayout::InInverseRows'
}.freeze

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #clean_params_from_check, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Instance Method Details

#createObject


46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/tag_layout_templates_controller.rb', line 46

def create
  @tag_layout_template = TagLayoutTemplate.new(tag_layout_template_params)

  respond_to do |format|
    if @tag_layout_template.save
      flash[:notice] = I18n.t('tag_groups.success')
      format.html { redirect_to(@tag_layout_template) }
    else
      @direction_algorithms = DIRECTIONS
      format.html { render action: 'new' }
    end
  end
end

#indexObject


19
20
21
22
23
24
25
# File 'app/controllers/tag_layout_templates_controller.rb', line 19

def index
  @tag_layout_templates = TagLayoutTemplate.all

  respond_to do |format|
    format.html
  end
end

#newObject

Allows for the passing in of tag group id using a link from the tag group show page.


37
38
39
40
41
42
43
44
# File 'app/controllers/tag_layout_templates_controller.rb', line 37

def new
  @tag_layout_template = TagLayoutTemplate.new(tag_group_id: params[:tag_group_id])
  @direction_algorithms = DIRECTIONS

  respond_to do |format|
    format.html
  end
end

#showObject


27
28
29
30
31
32
33
# File 'app/controllers/tag_layout_templates_controller.rb', line 27

def show
  @tag_layout_template = TagLayoutTemplate.find(params[:id])

  respond_to do |format|
    format.html
  end
end

#tag_layout_template_paramsObject


60
61
62
# File 'app/controllers/tag_layout_templates_controller.rb', line 60

def tag_layout_template_params
  params.require(:tag_layout_template).permit(:name, :tag_group_id, :tag2_group_id, :direction_algorithm, :walking_algorithm)
end