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. NB. Not all combinations will be valid.

Constant Summary

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods inherited from ApplicationController

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

Methods included from FlashTruncation

#max_flash_size, #truncate_flash, #truncate_flash_array

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/tag_layout_templates_controller.rb', line 34

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 = TagLayout::DIRECTION_ALGORITHMS
      @walking_algorithms = TagLayout::WALKING_ALGORITHMS
      format.html { render action: 'new' }
    end
  end
end

#indexObject



11
12
13
14
15
# File 'app/controllers/tag_layout_templates_controller.rb', line 11

def index
  @tag_layout_templates = TagLayoutTemplate.all

  respond_to { |format| format.html }
end

#newObject

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



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

def new
  @tag_layout_template =
    TagLayoutTemplate.new(tag_group_id: params[:tag_group_id], tag2_group_id: params[:tag2_group_id])
  @direction_algorithms = TagLayout::DIRECTION_ALGORITHMS
  @walking_algorithms = TagLayout::WALKING_ALGORITHMS

  respond_to { |format| format.html }
end

#showObject



17
18
19
20
21
# File 'app/controllers/tag_layout_templates_controller.rb', line 17

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

  respond_to { |format| format.html }
end

#tag_layout_template_paramsObject



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

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