Class: TimeField
- Inherits:
-
Field
show all
- Defined in:
- lib/generators/hot_glue/fields/time_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_natural_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
7
8
9
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 7
def form_field_output
"<%= time_field_localized(f, :#{name}, formatted_time_field(#{singular}, :#{name}, current_user), label: \"#{ name.to_s.humanize } \#{ current_user.timezone }\") %>"
end
|
#line_field_output ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 11
def line_field_output
"\n <% unless #{singular}.#{name}.nil? %>
<%= formatted_time_display(#{singular}, :#{name}, current_user) %>
<% else %>
<span class=''>MISSING</span>
<% end %>\n"
end
|
#load_all_query_statement ⇒ Object
47
48
49
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 47
def load_all_query_statement
"#{name}_query = time_query_constructor(:#{name}, @q['0'][:#{name}_match], @q['0'][:#{name}_search_start], @q['0'][:#{name}_search_end])"
end
|
#search_field_output ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 33
def search_field_output
" <div data-controller='time-range-picker' >"+
"\n <%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['is at exactly', 'is_at_exactly']], @q[\'0\']['#{name}_match']), {} ," +
"\n { class: 'form-control match', 'data-action': 'change->time-range-picker#matchSelection' } %>"+
"\n <%= time_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-time-range-picker-target': 'start' %>" +
"\n <%= time_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-time-range-picker-target': 'end' %>" +
"\n </div>"
end
|
#spec_list_view_assertion ⇒ Object
29
30
31
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 29
def spec_list_view_assertion
end
|
#spec_make_assertion ⇒ Object
25
26
27
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 25
def spec_make_assertion
"expect(page).to have_content(new_#{name}.strftime('%l:%M %p').strip)"
end
|
#spec_setup_and_change_act(which_partial = nil) ⇒ Object
19
20
21
22
23
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 19
def spec_setup_and_change_act(which_partial = nil)
" new_#{name} = Time.current + 5.seconds \n" +
' ' + "find(\"[name='#{testing_name}[#{ name.to_s }]']\").fill_in(with: new_#{name.to_s})"
end
|
#spec_setup_let_arg ⇒ Object
3
4
5
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 3
def spec_setup_let_arg
"#{name}: Time.current + rand(5000).seconds"
end
|
#where_query_statement ⇒ Object
43
44
45
|
# File 'lib/generators/hot_glue/fields/time_field.rb', line 43
def where_query_statement
".where(*#{name}_query)"
end
|