Class: IntegerField
- Inherits:
-
Field
- Object
- Field
- IntegerField
show all
- Defined in:
- lib/generators/hot_glue/fields/integer_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_natural_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_blank ⇒ Object
50
51
52
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 50
def code_to_reset_match_if_search_is_blank
" @q['0'][:#{name}_match] = '' if @q['0'][:#{name}_search] == ''"
end
|
27
28
29
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 27
def form_field_output
" <%= f.text_field :#{name}, value: #{singular}.#{name}, autocomplete: 'off', size: 4, class: 'form-control', type: 'number'" + (form_placeholder_labels ? ", placeholder: '#{name.to_s.humanize}'" : "") + " %>\n " + "\n"
end
|
#load_all_query_statement ⇒ Object
46
47
48
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 46
def load_all_query_statement
"#{name}_query = integer_query_constructor(@q['0'][:#{name}_match], @q['0'][:#{name}_search])"
end
|
#search_field_output ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 31
def search_field_output
" <div>" +
"\n <%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['=', '='], " +
"\n ['≥', '≥'], ['>', '>'], " +
"\n ['≤', '≤'], ['<', '<']], @q[\'0\']['#{name}_match'] ), {} ," +
"\n { class: 'form-control match' } %>"+
"\n <%= f.text_field 'q[0][#{name}_search]', {value: @q[\'0\'][:#{name}_search], autocomplete: 'off', size: 4, class: 'form-control', type: 'number'} %>" +
"\n </div>"
end
|
#spec_list_view_assertion ⇒ Object
23
24
25
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 23
def spec_list_view_assertion
"expect(page).to have_content(#{singular}#{1}.#{name})"
end
|
#spec_make_assertion ⇒ Object
15
16
17
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 15
def spec_make_assertion
"expect(page).to have_content(new_#{name})"
end
|
#spec_random_data ⇒ Object
2
3
4
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 2
def spec_random_data
rand(1...1000)
end
|
#spec_setup_and_change_act(which_partial = nil) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 6
def spec_setup_and_change_act(which_partial = nil)
if name.to_s.ends_with?("_id")
capybara_block_for_association(name_name: name, which_partial: which_partial)
else
" new_#{name} = rand(10) \n" +
" find(\"[name='#{testing_name}[#{ name.to_s }]']\").fill_in(with: new_#{name.to_s})"
end
end
|
#spec_setup_let_arg ⇒ Object
19
20
21
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 19
def spec_setup_let_arg
"#{name}: rand(100)"
end
|
#where_query_statement ⇒ Object
42
43
44
|
# File 'lib/generators/hot_glue/fields/integer_field.rb', line 42
def where_query_statement
".where(\"#{name} \#{#{name}_query }\")"
end
|