kono_utils_bootstrap_view4 0.1.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +21 -0
- data/Rakefile +32 -0
- data/app/assets/config/kono_utils_bootstrap_view4_manifest.js +0 -0
- data/app/assets/javascripts/kono_utils_bootstrap_view4/application.js.erb +12 -0
- data/app/assets/javascripts/kono_utils_bootstrap_view4/kono_utils_bootstrap_view4.js +36 -0
- data/app/assets/stylesheets/kono_utils_bootstrap_view4/application.css.scss.erb +12 -0
- data/app/concepts/kono_utils/object/cell/base.rb +123 -0
- data/app/concepts/kono_utils/object/cell/buttons/base.rb +57 -0
- data/app/concepts/kono_utils/object/cell/buttons/collapse_search.rb +31 -0
- data/app/concepts/kono_utils/object/cell/buttons/create.rb +22 -0
- data/app/concepts/kono_utils/object/cell/buttons/delete.rb +32 -0
- data/app/concepts/kono_utils/object/cell/buttons/download.rb +23 -0
- data/app/concepts/kono_utils/object/cell/buttons/edit.rb +18 -0
- data/app/concepts/kono_utils/object/cell/buttons/list.rb +17 -0
- data/app/concepts/kono_utils/object/cell/buttons/reset_search.rb +21 -0
- data/app/concepts/kono_utils/object/cell/create/base.rb +8 -0
- data/app/concepts/kono_utils/object/cell/create/page_title.rb +10 -0
- data/app/concepts/kono_utils/object/cell/create/side_title.rb +5 -0
- data/app/concepts/kono_utils/object/cell/edits/base.rb +8 -0
- data/app/concepts/kono_utils/object/cell/edits/page_title.rb +10 -0
- data/app/concepts/kono_utils/object/cell/edits/side_title.rb +5 -0
- data/app/concepts/kono_utils/object/cell/form.rb +51 -0
- data/app/concepts/kono_utils/object/cell/forms/base.rb +13 -0
- data/app/concepts/kono_utils/object/cell/forms/container.rb +25 -0
- data/app/concepts/kono_utils/object/cell/forms/containers/layout.rb +16 -0
- data/app/concepts/kono_utils/object/cell/forms/containers/modal_layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/containers/search_layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/containers/table_layout.rb +8 -0
- data/app/concepts/kono_utils/object/cell/forms/field_selector.rb +77 -0
- data/app/concepts/kono_utils/object/cell/forms/field_selectors/layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/field_selectors/modal_layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/field_selectors/table_layout.rb +8 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/association.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/base.rb +25 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/bases/layout.rb +24 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/bases/modal_layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/bases/table_layout.rb +11 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/check_box.rb +10 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/collection.rb +17 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/date_field.rb +15 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/date_time_field.rb +51 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/enum.rb +20 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/file_field.rb +31 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrapper.rb +6 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrappers/forms_container.rb +9 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_modal_wrappers/show.rb +14 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrapper.rb +63 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/form.rb +38 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/layout.rb +13 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/modal_layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms/table_layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_container.rb +45 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/layout.rb +15 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/modal_layout.rb +9 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/forms_containers/table_layout.rb +16 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/header.rb +31 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_button.rb +44 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/layout.rb +10 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/modal_layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/nested_wrappers/remove_buttons/table_layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/read_only.rb +15 -0
- data/app/concepts/kono_utils/object/cell/forms/fields/time_field.rb +11 -0
- data/app/concepts/kono_utils/object/cell/forms/layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/forms/submit.rb +22 -0
- data/app/concepts/kono_utils/object/cell/index/base.rb +12 -0
- data/app/concepts/kono_utils/object/cell/index/page_title.rb +10 -0
- data/app/concepts/kono_utils/object/cell/index/row.rb +40 -0
- data/app/concepts/kono_utils/object/cell/index/row_buttons.rb +7 -0
- data/app/concepts/kono_utils/object/cell/index/row_footer.rb +6 -0
- data/app/concepts/kono_utils/object/cell/index/row_header.rb +11 -0
- data/app/concepts/kono_utils/object/cell/index/side_title.rb +5 -0
- data/app/concepts/kono_utils/object/cell/index/table.rb +15 -0
- data/app/concepts/kono_utils/object/cell/inject.rb +122 -0
- data/app/concepts/kono_utils/object/cell/modals/base.rb +6 -0
- data/app/concepts/kono_utils/object/cell/modals/bodies/layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/modals/body.rb +6 -0
- data/app/concepts/kono_utils/object/cell/modals/container.rb +24 -0
- data/app/concepts/kono_utils/object/cell/modals/containers/layout.rb +10 -0
- data/app/concepts/kono_utils/object/cell/modals/footer.rb +6 -0
- data/app/concepts/kono_utils/object/cell/modals/footers/layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/modals/header.rb +6 -0
- data/app/concepts/kono_utils/object/cell/modals/headers/layout.rb +7 -0
- data/app/concepts/kono_utils/object/cell/search.rb +27 -0
- data/app/concepts/kono_utils/object/cell/searches/form.rb +14 -0
- data/app/concepts/kono_utils/object/cell/show.rb +26 -0
- data/app/concepts/kono_utils/object/cell/shows/base.rb +8 -0
- data/app/concepts/kono_utils/object/cell/shows/page_title.rb +10 -0
- data/app/concepts/kono_utils/object/cell/shows/side_title.rb +5 -0
- data/app/concepts/kono_utils/object/view/create/side_title.erb +1 -0
- data/app/concepts/kono_utils/object/view/edits/side_title.erb +1 -0
- data/app/concepts/kono_utils/object/view/form.erb +9 -0
- data/app/concepts/kono_utils/object/view/forms/container.erb +5 -0
- data/app/concepts/kono_utils/object/view/forms/containers/layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/forms/containers/modal_layout.erb +5 -0
- data/app/concepts/kono_utils/object/view/forms/containers/search_layout.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/containers/table_layout.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/field_selector.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/field_selectors/layout.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/field_selectors/modal_layout.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/field_selectors/table_layout.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/fields/association.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/fields/base.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/fields/bases/layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/forms/fields/bases/layout.scss +25 -0
- data/app/concepts/kono_utils/object/view/forms/fields/bases/modal_layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/forms/fields/bases/table_layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/forms/fields/check_box.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/fields/collection.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_modal_wrapper.erb +23 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_modal_wrappers/forms_container.erb +12 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_modal_wrappers/show.erb +28 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrapper.erb +18 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/form.erb +17 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms/layout.erb +18 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms/modal_layout.erb +4 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms/table_layout.erb +4 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms_container.erb +11 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms_containers/layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms_containers/modal_layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/forms_containers/table_layout.erb +14 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/header.erb +27 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/remove_button.erb +28 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/remove_buttons/layout.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/remove_buttons/modal_layout.erb +1 -0
- data/app/concepts/kono_utils/object/view/forms/fields/nested_wrappers/remove_buttons/table_layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/forms/layout.erb +1 -0
- data/app/concepts/kono_utils/object/view/index/row.erb +10 -0
- data/app/concepts/kono_utils/object/view/index/row_buttons.erb +2 -0
- data/app/concepts/kono_utils/object/view/index/row_footer.erb +0 -0
- data/app/concepts/kono_utils/object/view/index/row_header.erb +8 -0
- data/app/concepts/kono_utils/object/view/index/side_title.erb +1 -0
- data/app/concepts/kono_utils/object/view/index/table.erb +9 -0
- data/app/concepts/kono_utils/object/view/inject.erb +8 -0
- data/app/concepts/kono_utils/object/view/modals/bodies/layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/modals/body.erb +1 -0
- data/app/concepts/kono_utils/object/view/modals/container.erb +13 -0
- data/app/concepts/kono_utils/object/view/modals/containers/layout.erb +7 -0
- data/app/concepts/kono_utils/object/view/modals/footer.erb +1 -0
- data/app/concepts/kono_utils/object/view/modals/footers/layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/modals/header.erb +1 -0
- data/app/concepts/kono_utils/object/view/modals/headers/layout.erb +3 -0
- data/app/concepts/kono_utils/object/view/search.erb +40 -0
- data/app/concepts/kono_utils/object/view/searches/form.erb +16 -0
- data/app/concepts/kono_utils/object/view/show.erb +6 -0
- data/app/concepts/kono_utils/object/view/shows/side_title.erb +1 -0
- data/app/inputs/file_input_download_input.rb +22 -0
- data/app/inputs/tempus_dominus_input.rb +38 -0
- data/app/views/kaminari/_first_page.html.erb +3 -0
- data/app/views/kaminari/_gap.html.erb +3 -0
- data/app/views/kaminari/_last_page.html.erb +3 -0
- data/app/views/kaminari/_next_page.html.erb +3 -0
- data/app/views/kaminari/_page.html.erb +9 -0
- data/app/views/kaminari/_paginator.html.erb +17 -0
- data/app/views/kaminari/_prev_page.html.erb +3 -0
- data/app/views/kono_utils/base_editing/edit.html.erb +8 -0
- data/app/views/kono_utils/base_editing/edit.inject.erb +2 -0
- data/app/views/kono_utils/base_editing/index.html.erb +10 -0
- data/app/views/kono_utils/base_editing/new.html.erb +9 -0
- data/app/views/kono_utils/base_editing/new.inject.erb +2 -0
- data/app/views/kono_utils/base_editing/show.html.erb +8 -0
- data/app/views/kono_utils/base_editing/success_create_show.inject.erb +6 -0
- data/app/views/kono_utils/base_editing/success_update_show.inject.erb +6 -0
- data/config/initializers/kaminari_config.rb +30 -0
- data/config/initializers/simple_form.rb +179 -0
- data/config/initializers/simple_form_bootstrap.rb +439 -0
- data/config/locales/kono_utils_bootstrap4.en.yml +15 -0
- data/config/locales/kono_utils_bootstrap4.it.yml +15 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +2 -0
- data/lib/generators/kono_utils_bootstrap_view4/concept/concept_generator.rb +79 -0
- data/lib/generators/kono_utils_bootstrap_view4/concept/templates/form.template +8 -0
- data/lib/generators/kono_utils_bootstrap_view4/concept/templates/forms/field_selector.template +13 -0
- data/lib/generators/kono_utils_bootstrap_view4/install/install_generator.rb +76 -0
- data/lib/generators/kono_utils_bootstrap_view4/install/templates/kono_utils_bootstrap_view4.js.erb.template +20 -0
- data/lib/generators/kono_utils_bootstrap_view4/install/templates/kono_utils_bootstrap_view4.template +5 -0
- data/lib/kono_utils_bootstrap_view4.rb +26 -0
- data/lib/kono_utils_bootstrap_view4/application_icon_helper.rb +31 -0
- data/lib/kono_utils_bootstrap_view4/base_class_concept_ns.rb +47 -0
- data/lib/kono_utils_bootstrap_view4/base_search.rb +5 -0
- data/lib/kono_utils_bootstrap_view4/configuration.rb +20 -0
- data/lib/kono_utils_bootstrap_view4/editable_field.rb +63 -0
- data/lib/kono_utils_bootstrap_view4/engine.rb +59 -0
- data/lib/kono_utils_bootstrap_view4/paginate_proxer.rb +11 -0
- data/lib/kono_utils_bootstrap_view4/search_form_builder.rb +14 -0
- data/lib/kono_utils_bootstrap_view4/version.rb +3 -0
- data/lib/tasks/kono_utils_bootstrap_view4_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +15 -0
- metadata +391 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Buttons # namespace
|
2
|
+
class Edit < Base
|
3
|
+
|
4
|
+
def url_to
|
5
|
+
options[:url_to] || edit_custom_polymorphic_path(model)
|
6
|
+
end
|
7
|
+
|
8
|
+
def specific_button_class
|
9
|
+
'btn-primary'
|
10
|
+
end
|
11
|
+
|
12
|
+
def button_content
|
13
|
+
options.fetch(:content, fa_icon("edit"))
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Buttons # namespace
|
2
|
+
class List < Base
|
3
|
+
|
4
|
+
def url_to
|
5
|
+
options[:url_to] || index_custom_polymorphic_path(model)
|
6
|
+
end
|
7
|
+
|
8
|
+
def specific_button_class
|
9
|
+
'btn-link'
|
10
|
+
end
|
11
|
+
|
12
|
+
def button_content
|
13
|
+
options.fetch(:content, fa_icon("list"))
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Buttons # namespace
|
2
|
+
##
|
3
|
+
# Bottone per la struttura del collapse search
|
4
|
+
# *Options*
|
5
|
+
# - collapsed_target -> identificativo del contenitore che devo espandere
|
6
|
+
class ResetSearch < Base
|
7
|
+
|
8
|
+
def url_to
|
9
|
+
options[:url_to] || index_custom_polymorphic_path(model)
|
10
|
+
end
|
11
|
+
|
12
|
+
def specific_button_class
|
13
|
+
"btn-secondary"
|
14
|
+
end
|
15
|
+
|
16
|
+
def button_content
|
17
|
+
options.fetch(:content, fa_icon("times"))
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module KonoUtils::Object::Cell # namespace
|
2
|
+
class Form < Base
|
3
|
+
|
4
|
+
load('action_view/helpers/form_helper.rb')
|
5
|
+
include ActionView::Helpers::FormHelper
|
6
|
+
include SimpleForm::ActionViewExtensions::FormHelper
|
7
|
+
include ActionView::Helpers::DateHelper
|
8
|
+
include ActionView::Helpers::FormOptionsHelper
|
9
|
+
|
10
|
+
|
11
|
+
layout("forms/layout")
|
12
|
+
|
13
|
+
##
|
14
|
+
# Metodo che mi ritorna la lista degli argomenti da passare a simple form.
|
15
|
+
# @return [Array]
|
16
|
+
#
|
17
|
+
# ES:
|
18
|
+
# [model] -> model deve essere l'ActiveRecord da utilizzare come oggetto della form
|
19
|
+
#
|
20
|
+
# [model,{ url:helper_path_custom }] -> come secondo parametro abbiamo l'hash delle opzioni da poter passare al form builder
|
21
|
+
# se al concept passiamo form_options come opzione, queste vengono mergiate nelle opzioni standard
|
22
|
+
def forms_options
|
23
|
+
[model, _form_options]
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
def form_id
|
28
|
+
dom_id(model, SecureRandom.uuid)
|
29
|
+
end
|
30
|
+
|
31
|
+
def container_layout
|
32
|
+
layout = context[:nested_layout].blank? ? "layout" : context[:nested_layout]
|
33
|
+
layout_ns("cell/forms/containers/#{layout}")
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
##
|
39
|
+
# Opzioni aggiuntive per la form
|
40
|
+
def _form_options
|
41
|
+
opts = options[:form_options] || {}
|
42
|
+
html = opts.fetch(:html, {multipart: true})
|
43
|
+
html[:id] = form_id
|
44
|
+
|
45
|
+
opts.merge({html: html})
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Forms # namespace
|
2
|
+
# Classe che si occupa di generare il container della form
|
3
|
+
class Container < Base
|
4
|
+
|
5
|
+
def show(&block)
|
6
|
+
logger.tagged(dom_id(form.object)) do
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
##
|
12
|
+
# Gli attributi da stampare sono un elenco delle options oppure estrapolati tramite la policy
|
13
|
+
def form_attributes
|
14
|
+
options[:form_attributes] || KonoUtilsBootstrapView4::EditableField.editable_fields_to_field_array(policy(model).editable_attributes)
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def field_selector_layout
|
19
|
+
layout = context[:overriden_layout].blank? ? "layout" : context[:overriden_layout]
|
20
|
+
layout_ns("cell/forms/field_selectors/#{layout}")
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Forms # namespace
|
2
|
+
# Layout Standard del contenitore della Form
|
3
|
+
class Containers::Layout < Base
|
4
|
+
|
5
|
+
|
6
|
+
def container_dom_id
|
7
|
+
options[:container_dom_id] || dom_id(form.object)
|
8
|
+
end
|
9
|
+
|
10
|
+
def container_classes
|
11
|
+
[:row] + (options[:container_classes] || [dom_class(form.object)])
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Forms # namespace
|
2
|
+
# Classe che si occupa di selezionare il campo corretto nella form
|
3
|
+
#
|
4
|
+
# il model sarà un [KonoUtilsBootstrapView4::EditableField]
|
5
|
+
class FieldSelector < Base
|
6
|
+
|
7
|
+
##
|
8
|
+
# Questa funzione serve per essere sovrascritta dal field generico nella cella specifica del modello
|
9
|
+
# e quindi stampare un determinato campo in modo differente
|
10
|
+
# Viene normalizzato il campo in model contenente il KonoUtilsBootstrapView4::EditableField
|
11
|
+
def get_field
|
12
|
+
logger.debug { "SELECT_FIELD:#{form.object.class.name}->#{model.name}" }
|
13
|
+
if model.is_nested?
|
14
|
+
#devo nestarlo
|
15
|
+
concept("cell/forms/fields/nested_wrapper", model, layout: get_layout('nested_wrappers'))
|
16
|
+
else
|
17
|
+
# decidiamo se renderizzare un'associazione o meno
|
18
|
+
if form.object.class.reflect_on_association(model.name)
|
19
|
+
concept("cell/forms/fields/association", model, layout: get_layout('associations'))
|
20
|
+
else
|
21
|
+
|
22
|
+
# riconosciamo la tipologia di campo per renderizzare quello corretto
|
23
|
+
case attribute_type
|
24
|
+
when :date
|
25
|
+
concept("cell/forms/fields/date_field", model, layout: get_layout('bases'))
|
26
|
+
when :time
|
27
|
+
concept("cell/forms/fields/time_field", model, layout: get_layout('bases'))
|
28
|
+
when :datetime
|
29
|
+
concept("cell/forms/fields/date_time_field", model, layout: get_layout('bases'))
|
30
|
+
when :file
|
31
|
+
concept("cell/forms/fields/file_field", model, layout: get_layout('bases'))
|
32
|
+
when :enum
|
33
|
+
concept("cell/forms/fields/enum", model, layout: get_layout('bases'))
|
34
|
+
else
|
35
|
+
logger.debug { "TIPO non riconosciuto: #{form.object.class.type_for_attribute(model.name).type} -> #{form.object.class.type_for_attribute(model.name).inspect}" }
|
36
|
+
concept("cell/forms/fields/base", model, layout: get_layout('bases'))
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_layout(field_ns)
|
45
|
+
layout = context[:overriden_layout].blank? ? "layout" : context[:overriden_layout]
|
46
|
+
layout_ns("cell/forms/fields/bases/#{layout}")
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
##
|
52
|
+
# Deve ritornare il tipo di attributo per estrapolare i campi standard a disposizione:
|
53
|
+
# * :date
|
54
|
+
# * :time
|
55
|
+
# * :datetime
|
56
|
+
# * :file
|
57
|
+
# * :enum
|
58
|
+
# @return [Symbol]
|
59
|
+
def attribute_type
|
60
|
+
attribute_type = form.object.class.type_for_attribute(model.name).type
|
61
|
+
|
62
|
+
#riconosciamo se sono file allegati
|
63
|
+
file = form.object.send(model.name) if form.object.respond_to?(model.name)
|
64
|
+
if file && SimpleForm.file_methods.any? { |m| file.respond_to?(m) }
|
65
|
+
attribute_type = :file
|
66
|
+
end
|
67
|
+
|
68
|
+
# Riconoscimento degli enum
|
69
|
+
if form.object.class.type_for_attribute(model.name).is_a? ActiveRecord::Enum::EnumType
|
70
|
+
attribute_type = :enum
|
71
|
+
end
|
72
|
+
attribute_type
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Forms # namespace
|
2
|
+
# La cella base dei componenti della form contiene sempre la form come model
|
3
|
+
class Fields::Base < Base
|
4
|
+
|
5
|
+
##
|
6
|
+
# Campo del record da visualizzare nella form
|
7
|
+
def attribute_name
|
8
|
+
model.name
|
9
|
+
end
|
10
|
+
|
11
|
+
def field_options
|
12
|
+
base_field_options.merge(options[:field_options] || {})
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def base_field_options
|
17
|
+
out = {}
|
18
|
+
|
19
|
+
out[:as] = :hidden if model.is_hidden?
|
20
|
+
|
21
|
+
out
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Forms::Fields # namespace
|
2
|
+
# Classe contenitore del campo, serve per deviare nelle situazioni in cui non serve stampare un contenitore(id,_destroy) o campi hidden
|
3
|
+
# il model qua avremo un KonoUtilsBootstrapView4::EditableField
|
4
|
+
class Bases::Layout < Base
|
5
|
+
|
6
|
+
def cell_column_classes
|
7
|
+
["col-md-12"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def show(&block)
|
11
|
+
logger.debug { "LAYOUT => #{self.class.name}" }
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
#ritorna la classe hidden da aggiungere nelle classi di layout nel caso il campo da renderizzare non sia da renderizzare
|
18
|
+
def hidden_class
|
19
|
+
model.is_hidden? ? ["kono_utils-hidden"] : []
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Forms::Fields::Bases # namespace
|
2
|
+
# Classe contenitore del campo, serve per deviare nelle situazioni in cui non serve stampare un contenitore(id,_destroy) o campi hidden
|
3
|
+
# il model qua avremo un KonoUtilsBootstrapView4::EditableField
|
4
|
+
class ModalLayout < Layout
|
5
|
+
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module KonoUtils::Object::Cell::Forms::Fields::Bases # namespace
|
2
|
+
# Classe contenitore del campo, serve per deviare nelle situazioni in cui non serve stampare un contenitore(id,_destroy) o campi hidden
|
3
|
+
# il model qua avremo un KonoUtilsBootstrapView4::EditableField
|
4
|
+
class TableLayout < Layout
|
5
|
+
|
6
|
+
def cell_column_classes
|
7
|
+
[]
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|