Class: KonoUtils::Object::Cell::Forms::Fields::DateTimeField
- Inherits:
-
Base
- Object
- Trailblazer::Cell
- Base
- KonoUtils::Object::Cell::Forms::Fields::DateTimeField
show all
- Defined in:
- app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb
Overview
La cella base dei componenti della form contiene sempre la form come model
Instance Method Summary
collapse
Methods inherited from Base
#_prefixes, #base_class, #concept, #content_for_layout, #content_for_layout?, #destroy_custom_polymorphic_path, #edit_custom_polymorphic_path, #index_custom_polymorphic_path, #kono_user, #legacy_concept, logger, #model_gender, #new_custom_polymorphic_path, #show_custom_polymorphic_path, #title_del, #title_del_g, #title_edit_g, #title_mod, #title_new, #title_new_g, #title_newa, #title_show_g
#fa_icon, #icon
Instance Method Details
#base_field_options ⇒ Object
42
43
44
|
# File 'app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb', line 42
def base_field_options
super.merge(as: :tempus_dominus, date_time_picker_identifier: datetime_picker_identifier)
end
|
#datetime_picker_identifier ⇒ Object
46
47
48
|
# File 'app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb', line 46
def datetime_picker_identifier
@_unique ||= SecureRandom.uuid
end
|
38
39
40
|
# File 'app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb', line 38
def input_picker_format
"L LT"
end
|
Carica il valore nel js per poterlo avere precaricato nel campo
33
34
35
36
|
# File 'app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb', line 33
def input_value
value = form.object.send(attribute_name)
value.respond_to?(:rfc2822) ? "date: moment('#{value.rfc2822}')," : ''
end
|
#show(&block) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb', line 9
def show(&block)
bf = ActiveSupport::SafeBuffer.new
bf << form.input(attribute_name, field_options)
bf << content_tag(:script, :type => "text/javascript") do
raw "(function(){
$('##{datetime_picker_identifier}').datetimepicker({
#{ input_value }
locale: '#{I18n.locale}',
keepOpen: false,
debug: false,
format: '#{input_picker_format}'
});
})();
"
end
bf
end
|