Module: AlternateValuesHelper

Defined in:
app/helpers/alternate_values_helper.rb

Instance Method Summary (collapse)

Instance Method Details



34
35
36
37
38
39
# File 'app/helpers/alternate_values_helper.rb', line 34

def add_alternate_value_link(object: nil, attribute: nil)
  link_to('Add alternate value', new_alternate_value_path(
                                 alternate_value: {alternate_value_object_type:      object.class.base_class.name,
                                                   alternate_value_object_id:        object.id,
                                                   alternate_value_object_attribute: attribute})) if object.has_alternate_values?
end


50
51
52
53
# File 'app/helpers/alternate_values_helper.rb', line 50

def alternate_value_link(alternate_value)
  return nil if alternate_value.nil?
  link_to(alternate_value_tag(alternate_value).html_safe, alternate_value.annotated_object.metamorphosize)
end

- (Object) alternate_value_tag(alternate_value)



3
4
5
6
# File 'app/helpers/alternate_values_helper.rb', line 3

def alternate_value_tag(alternate_value)
  return nil if alternate_value.nil?
  ["#{alternate_value.value},", alternate_value.klass_name, "of \"#{alternate_value.original_value}\"", "(on '#{alternate_value.alternate_value_object_attribute}')('#{alternate_value.project_id.nil? ? "public" : "project only"}')"].join(' ')
end

- (True) alternate_values_recent_objects_partial

Returns indicates a custom partial should be used, see list_helper.rb

Returns:

  • (True)

    indicates a custom partial should be used, see list_helper.rb



61
62
63
# File 'app/helpers/alternate_values_helper.rb', line 61

def alternate_values_recent_objects_partial
  true 
end

- (Object) alternate_values_search_form



55
56
57
# File 'app/helpers/alternate_values_helper.rb', line 55

def alternate_values_search_form
  render('/alternate_values/quick_search_form')
end


46
47
48
# File 'app/helpers/alternate_values_helper.rb', line 46

def destroy_alternate_value_link(alternate_value)
  destroy_object_link(alternate_value)
end


41
42
43
44
# File 'app/helpers/alternate_values_helper.rb', line 41

def edit_alternate_value_link(alternate_value)
  edit_object_link(alternate_value)
  # link_to('Edit', edit_alternate_value_path(alternate_value))
end


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/alternate_values_helper.rb', line 16

def link_to_add_alternate_value(link_text, f)
  new_object =
    f.object.class.reflect_on_association(:alternate_values).
      klass.new({
                  alternate_value_object_type:      f.object.class.base_class.name,
                  alternate_value_object_id:        f.object.id,
                  alternate_value_object_attribute: 'name'})
  if f.object.alternate_values.any?
    fields = f.fields_for(:alternate_values, new_object,
                          :child_index => 'new_alternate_values') do |builder|
      render('alternate_values/alternate_value_fields', :avf => builder)
    end
  else
    fields = nil
  end
  link_to(link_text, '', class: 'alternate-value-add', association: 'alternate_values', content: "#{fields}")
end


8
9
10
# File 'app/helpers/alternate_values_helper.rb', line 8

def link_to_destroy_alternate_value(link_text, alternate_value)
  link_to(link_text, '', class: 'alternate-value-destroy', alternate_value_id: alternate_value.id)
end


12
13
14
# File 'app/helpers/alternate_values_helper.rb', line 12

def link_to_edit_alternate_value(link_text, alternate_value)
  link_to(link_text, '', class: 'alternate-value-edit', alternate_value_id: alternate_value.id)
end