Class: TextField

Inherits:
Field show all
Defined in:
lib/generators/hot_glue/fields/text_field.rb

Instance Attribute Summary

Attributes inherited from Field

#alt_lookup, #assoc_class, #assoc_label, #assoc_model, #assoc_name, #associations, #attachment_data, #auth, #class_name, #default_boolean_display, #display_as, #form_labels_position, #form_placeholder_labels, #god, #hawk_keys, #hidden_create, #hidden_update, #layout_strategy, #limit, #modify_as, #name, #namespace, #object, #ownership_field, #plural, #polymorphic_parents, #pundit, #sample_file_path, #self_auth, #singular, #singular_class, #sql_type, #stimmify, #update_show_only

Instance Method Summary collapse

Methods inherited from Field

#display_boolean_as, #field_error_name, #field_output, #field_view_output, #form_show_only_output, #getName, #hidden_output, #initialize, #label_class, #label_for, #line_field_output, #modified_display_output, #modify_binary?, #newline_after_field?, #prelookup_syntax, #spec_list_view_assertion, #spec_list_view_natural_assertion, #spec_make_assertion, #spec_related_column_lets, #testing_name, #text_area_output, #viewable_output

Constructor Details

This class inherits a constructor from Field

Instance Method Details

#code_to_reset_match_if_search_is_blankObject



47
48
49
# File 'lib/generators/hot_glue/fields/text_field.rb', line 47

def code_to_reset_match_if_search_is_blank
  # "    @q['0'][:#{name}_match] = '' if @q['0'][:#{name}_search] == ''"
end

#form_field_outputObject



15
16
17
18
19
20
21
# File 'lib/generators/hot_glue/fields/text_field.rb', line 15

def form_field_output
  if sql_type == "varchar" || sql_type == "character varying"
    field_output( nil, limit || 40)
  else
    text_area_output( 65536, extra_classes: (modify_as == {tinymce: 1} ? " tinymce" : "" ))
  end
end

#load_all_query_statementObject



43
44
45
# File 'lib/generators/hot_glue/fields/text_field.rb', line 43

def load_all_query_statement
  "#{name}_query = string_query_constructor(@q['0'][:#{name}_match], @q['0'][:#{name}_search])"
end

#search_field_outputObject



33
34
35
36
# File 'lib/generators/hot_glue/fields/text_field.rb', line 33

def search_field_output
  "<%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['contains', 'contains'], ['is exactly', 'is_exactly'], ['starts with', 'starts_with'], ['ends with', 'ends_with']], @q[\'0\']['#{name}_match'] ), {} , { class: 'form-control match', 'data-search-form-target': \"textMatch\" } %>"+
    "<%= f.text_field 'q[0][#{name}_search]', value: @q[\'0\'][:#{name}_search], autocomplete: 'off', size: 40, class: 'form-control', type: 'text', 'data-search-form-target': \"textSearch\" %>"
end

#spec_random_dataObject



2
3
4
# File 'lib/generators/hot_glue/fields/text_field.rb', line 2

def spec_random_data
  FFaker::AnimalUS.common_name
end

#spec_setup_and_change_act(which_partial = nil) ⇒ Object



6
7
8
9
# File 'lib/generators/hot_glue/fields/text_field.rb', line 6

def spec_setup_and_change_act(which_partial = nil)
  "      " + "new_#{name} = FFaker::Lorem.paragraphs(1).join("") \n" +
  "      find(\"[name='#{testing_name}[#{ name.to_s }]']\").fill_in(with: new_#{name.to_s})"
end

#spec_setup_let_argObject



11
12
13
# File 'lib/generators/hot_glue/fields/text_field.rb', line 11

def spec_setup_let_arg
  "#{name}:  FFaker::Lorem.paragraphs(10).join("  ")"
end

#text_result(sql_type, limit) ⇒ Object

TODO: dry with string_field.rb



24
25
26
27
28
29
30
# File 'lib/generators/hot_glue/fields/text_field.rb', line 24

def text_result( sql_type, limit)
  if sql_type == "varchar"
    field_output( nil, limit)
  else
    text_area_output( 65536)
  end
end

#where_query_statementObject



39
40
41
# File 'lib/generators/hot_glue/fields/text_field.rb', line 39

def where_query_statement
  ".where('#{name} ILIKE ?', #{name}_query)"
end