Class: DateField
- Inherits:
-
Field
show all
- Defined in:
- lib/generators/hot_glue/fields/date_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
#code_to_reset_match_if_search_is_blank, #display_boolean_as, #field_error_name, #field_output, #field_view_output, #form_show_only_output, #getName, #hidden_output, #initialize, #label_class, #label_for, #modified_display_output, #modify_binary?, #newline_after_field?, #prelookup_syntax, #spec_list_view_assertion, #spec_list_view_natural_assertion, #spec_make_assertion, #spec_random_data, #spec_related_column_lets, #testing_name, #text_area_output, #viewable_output
Constructor Details
This class inherits a constructor from Field
Instance Method Details
12
13
14
15
16
|
# File 'lib/generators/hot_glue/fields/date_field.rb', line 12
def form_field_output
parts = name.to_s.split('_')
camelcase_name = parts.map(&:capitalize).join
"<%= date_field_localized(f, :#{name}, #{singular}.#{name}, label: '#{ name.to_s.humanize }'" + (stimmify ? ", html: {'data-#{@stimmify}-target': '#{camelcase_name}'}" : "") + ") %>"
end
|
#line_field_output ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/generators/hot_glue/fields/date_field.rb', line 18
def line_field_output
"<% unless #{singular}.#{name}.nil? %>
<%= #{singular}.#{name} %>
<% else %>
<span class=''>MISSING</span>
<% end %>"
end
|
#load_all_query_statement ⇒ Object
42
43
44
|
# File 'lib/generators/hot_glue/fields/date_field.rb', line 42
def load_all_query_statement
"#{name}_query = date_query_constructor(:#{name}, @q['0'][:#{name}_match], @q['0'][:#{name}_search_start], @q['0'][:#{name}_search_end])"
end
|
#search_field_output ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/generators/hot_glue/fields/date_field.rb', line 26
def search_field_output
" <div data-controller='date-range-picker' >"+
"\n <%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['is on', 'is_on'], " +
"\n ['is between', 'is_between'], ['is on or after', 'is_on_or_after'], " +
"\n ['is before or on', 'is_before_or_on'], ['not on', 'not_on']], @q[\'0\']['#{name}_match'] ), {} ," +
"\n { class: 'form-control match', 'data-action': 'change->date-range-picker#matchSelection' } %>"+
"\n <%= date_field_localized f, 'q[0][#{name}_search_start]', @q[\'0\'][:#{name}_search_start], autocomplete: 'off', size: 40, class: 'form-control', type: 'text', placeholder: 'start', 'data-date-range-picker-target': 'start' %>" +
"\n <%= date_field_localized f, 'q[0][#{name}_search_end]', @q[\'0\'][:#{name}_search_end], autocomplete: 'off', size: 40, class: 'form-control', type: 'text', placeholder: 'end' , 'data-date-range-picker-target': 'end'%>" +
"\n </div>"
end
|
#spec_setup_and_change_act(which_partial = nil) ⇒ Object
2
3
4
5
|
# File 'lib/generators/hot_glue/fields/date_field.rb', line 2
def spec_setup_and_change_act(which_partial = nil)
" " + "new_#{name} = Date.current + (rand(100).days) \n" +
' ' + "find(\"[name='#{testing_name}[#{ name.to_s }]']\").fill_in(with: new_#{name.to_s})"
end
|
#spec_setup_let_arg ⇒ Object
7
8
9
|
# File 'lib/generators/hot_glue/fields/date_field.rb', line 7
def spec_setup_let_arg
"#{name}: Date.current + rand(50).days"
end
|
#where_query_statement ⇒ Object
38
39
40
|
# File 'lib/generators/hot_glue/fields/date_field.rb', line 38
def where_query_statement
".where(*#{name}_query)"
end
|