avo 1.4.0.pre.1 → 1.4.4.pre.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +10 -4
- data/README.md +5 -4
- data/app/components/avo/fields/badge_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/badge_field/index_component.rb +4 -0
- data/app/components/avo/fields/badge_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/badge_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/belongs_to_field_component.html.erb → fields/belongs_to_field/edit_component.html.erb} +0 -0
- data/app/components/avo/{edit/fields/belongs_to_field_component.rb → fields/belongs_to_field/edit_component.rb} +1 -1
- data/app/components/avo/{index/fields/belongs_to_field_component.html.erb → fields/belongs_to_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/belongs_to_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/belongs_to_field_component.html.erb → fields/belongs_to_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/belongs_to_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/boolean_field_component.html.erb → fields/boolean_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/boolean_field/edit_component.rb +4 -0
- data/app/components/avo/fields/boolean_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/boolean_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/boolean_field_component.html.erb → fields/boolean_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/boolean_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/boolean_group_field_component.html.erb → fields/boolean_group_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/boolean_group_field/edit_component.rb +4 -0
- data/app/components/avo/fields/boolean_group_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/boolean_group_field/index_component.rb +4 -0
- data/app/components/avo/fields/boolean_group_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/boolean_group_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/code_field_component.html.erb → fields/code_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/code_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/code_field_component.html.erb → fields/code_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/code_field/show_component.rb +4 -0
- data/app/components/avo/{common → fields/common}/badge_viewer_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/badge_viewer_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/boolean_check_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/boolean_check_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/boolean_group_component.html.erb +1 -1
- data/app/components/avo/{common → fields/common}/boolean_group_component.rb +1 -1
- data/app/components/avo/fields/common/files_list_viewer_component.html.erb +5 -0
- data/app/components/avo/{common → fields/common}/files_list_viewer_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/gravatar_viewer_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/gravatar_viewer_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/heading_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/heading_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/key_value_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/key_value_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/multiple_file_viewer_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/multiple_file_viewer_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/single_file_viewer_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/single_file_viewer_component.rb +1 -1
- data/app/components/avo/fields/common/status_viewer_component.html.erb +18 -0
- data/app/components/avo/{common → fields/common}/status_viewer_component.rb +1 -1
- data/app/components/avo/{edit/fields/country_field_component.html.erb → fields/country_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/country_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/country_field_component.html.erb → fields/country_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/country_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/country_field_component.html.erb → fields/country_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/country_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/date_field_component.html.erb → fields/date_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/date_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/date_field_component.html.erb → fields/date_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/date_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/date_field_component.html.erb → fields/date_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/date_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/date_time_field_component.html.erb → fields/date_time_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/date_time_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/date_time_field_component.html.erb → fields/date_time_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/date_time_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/date_time_field_component.html.erb → fields/date_time_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/date_time_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/field_component.rb → fields/edit_component.rb} +1 -1
- data/app/components/avo/{edit/fields/external_image_field_component.html.erb → fields/external_image_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/external_image_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/external_image_field_component.html.erb → fields/external_image_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/external_image_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/external_image_field_component.html.erb → fields/external_image_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/external_image_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/file_field_component.html.erb → fields/file_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/file_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/file_field_component.html.erb → fields/file_field/index_component.html.erb} +1 -1
- data/app/components/avo/fields/file_field/index_component.rb +4 -0
- data/app/components/avo/fields/file_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/file_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/files_field_component.html.erb → fields/files_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/files_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/files_field_component.html.erb → fields/files_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/files_field/index_component.rb +4 -0
- data/app/components/avo/fields/files_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/files_field/show_component.rb +4 -0
- data/app/components/avo/{index/fields/gravatar_field_component.html.erb → fields/gravatar_field/index_component.html.erb} +2 -2
- data/app/components/avo/fields/gravatar_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/gravatar_field_component.html.erb → fields/gravatar_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/gravatar_field/show_component.rb +4 -0
- data/app/components/avo/{show/fields/has_many_field_component.html.erb → fields/has_many_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/has_many_field/show_component.rb +4 -0
- data/app/components/avo/{index/fields/has_one_field_component.html.erb → fields/has_one_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/has_one_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/has_one_field_component.html.erb → fields/has_one_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/has_one_field/show_component.rb +5 -0
- data/app/components/avo/{show/fields/heading_field_component.html.erb → fields/heading_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/heading_field/edit_component.rb +4 -0
- data/app/components/avo/{edit/fields/heading_field_component.html.erb → fields/heading_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/heading_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/hidden_field_component.html.erb → fields/hidden_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/hidden_field/edit_component.rb +4 -0
- data/app/components/avo/{edit/fields/id_field_component.html.erb → fields/id_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/id_field/edit_component.rb +4 -0
- data/app/components/avo/fields/id_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/id_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/id_field_component.html.erb → fields/id_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/id_field/show_component.rb +4 -0
- data/app/components/avo/fields/index_component.rb +20 -0
- data/app/components/avo/{edit/fields/key_value_field_component.html.erb → fields/key_value_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/key_value_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/key_value_field_component.html.erb → fields/key_value_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/key_value_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/markdown_field_component.html.erb → fields/markdown_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/markdown_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/markdown_field_component.html.erb → fields/markdown_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/markdown_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/number_field_component.html.erb → fields/number_field/edit_component.html.erb} +3 -3
- data/app/components/avo/fields/number_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/number_field_component.html.erb → fields/number_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/number_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/number_field_component.html.erb → fields/number_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/number_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/password_field_component.html.erb → fields/password_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/password_field/edit_component.rb +4 -0
- data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +26 -0
- data/app/components/avo/fields/progress_bar_field/edit_component.rb +4 -0
- data/app/components/avo/fields/progress_bar_field/index_component.html.erb +8 -0
- data/app/components/avo/fields/progress_bar_field/index_component.rb +4 -0
- data/app/components/avo/fields/progress_bar_field/show_component.html.erb +8 -0
- data/app/components/avo/fields/progress_bar_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/select_field_component.html.erb → fields/select_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/select_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/select_field_component.html.erb → fields/select_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/select_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/select_field_component.html.erb → fields/select_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/select_field/show_component.rb +4 -0
- data/app/components/avo/{show/fields/field_component.rb → fields/show_component.rb} +1 -1
- data/app/components/avo/{edit/fields/status_field_component.html.erb → fields/status_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/status_field/edit_component.rb +4 -0
- data/app/components/avo/fields/status_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/status_field/index_component.rb +4 -0
- data/app/components/avo/fields/status_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/status_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/text_field_component.html.erb → fields/text_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/text_field/edit_component.rb +4 -0
- data/app/components/avo/fields/text_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/text_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/text_field_component.html.erb → fields/text_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/text_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/textarea_field_component.html.erb → fields/textarea_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/textarea_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/textarea_field_component.html.erb → fields/textarea_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/textarea_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/trix_field_component.html.erb → fields/trix_field/edit_component.html.erb} +1 -2
- data/app/components/avo/fields/trix_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/trix_field_component.html.erb → fields/trix_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/trix_field/show_component.rb +4 -0
- data/app/components/avo/index/resource_controls_component.html.erb +2 -3
- data/app/components/avo/index/table_row_component.html.erb +1 -1
- data/app/components/avo/panel_component.html.erb +1 -1
- data/app/components/avo/panel_component.rb +4 -4
- data/app/components/avo/views/resource_edit_component.html.erb +2 -2
- data/app/components/avo/views/resource_index_component.html.erb +6 -6
- data/app/components/avo/views/resource_new_component.html.erb +2 -2
- data/app/components/avo/views/resource_show_component.html.erb +5 -5
- data/app/controllers/avo/application_controller.rb +14 -7
- data/app/controllers/avo/base_controller.rb +26 -2
- data/app/controllers/avo/home_controller.rb +1 -1
- data/app/controllers/avo/relations_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +50 -35
- data/app/helpers/avo/resources_helper.rb +0 -44
- data/app/packs/entrypoints/application.css +3 -1
- data/app/packs/entrypoints/application.js +3 -0
- data/app/packs/js/controllers/fields/key_value_controller.js +0 -1
- data/app/packs/js/controllers/search_controller.js +120 -0
- data/app/packs/js/helpers/debounce_promise.js +13 -0
- data/app/packs/stylesheets/components/progress.css +13 -0
- data/app/packs/stylesheets/components/status.css +31 -20
- data/app/packs/stylesheets/search.css +79 -0
- data/app/packs/svgs/check-circle-sm.svg +3 -0
- data/app/packs/svgs/x-circle-sm.svg +3 -0
- data/app/views/avo/actions/show.html.erb +1 -1
- data/app/views/avo/partials/_global_search.html.erb +17 -0
- data/app/views/avo/partials/_profile_dropdown.html.erb +19 -0
- data/app/views/avo/partials/_resource_search.html.erb +10 -0
- data/app/views/layouts/avo/application.html.erb +7 -6
- data/avo.gemspec +2 -1
- data/config/routes.rb +2 -6
- data/db/factories.rb +3 -0
- data/db/migrate/20210421064037_add_color_to_teams.rb +5 -0
- data/db/migrate/20210423075924_add_progress_to_projects.rb +5 -0
- data/lib/avo/app.rb +12 -21
- data/lib/avo/base_resource.rb +91 -7
- data/lib/avo/configuration.rb +3 -1
- data/lib/avo/engine.rb +1 -0
- data/lib/avo/fields/badge_field.rb +4 -6
- data/lib/avo/fields/base_field.rb +68 -83
- data/lib/avo/fields/belongs_to_field.rb +11 -11
- data/lib/avo/fields/boolean_field.rb +2 -7
- data/lib/avo/fields/boolean_group_field.rb +2 -7
- data/lib/avo/fields/code_field.rb +3 -7
- data/lib/avo/fields/country_field.rb +3 -6
- data/lib/avo/fields/currency_field.rb +4 -13
- data/lib/avo/fields/date_field.rb +2 -8
- data/lib/avo/fields/date_time_field.rb +2 -3
- data/lib/avo/fields/external_image_field.rb +3 -7
- data/lib/avo/fields/file_field.rb +8 -8
- data/lib/avo/fields/files_field.rb +6 -8
- data/lib/avo/fields/gravatar_field.rb +6 -9
- data/lib/avo/fields/has_and_belongs_to_many_field.rb +6 -7
- data/lib/avo/fields/has_many_field.rb +3 -9
- data/lib/avo/fields/has_one_field.rb +3 -8
- data/lib/avo/fields/heading_field.rb +10 -8
- data/lib/avo/fields/hidden_field.rb +2 -6
- data/lib/avo/fields/id_field.rb +5 -17
- data/lib/avo/fields/key_value_field.rb +4 -6
- data/lib/avo/fields/markdown_field.rb +3 -5
- data/lib/avo/fields/number_field.rb +8 -11
- data/lib/avo/fields/password_field.rb +2 -6
- data/lib/avo/fields/progress_bar_field.rb +19 -0
- data/lib/avo/fields/select_field.rb +13 -12
- data/lib/avo/fields/status_field.rb +2 -6
- data/lib/avo/fields/text_field.rb +3 -6
- data/lib/avo/fields/textarea_field.rb +4 -7
- data/lib/avo/fields/trix_field.rb +5 -9
- data/lib/avo/fields_collector.rb +47 -11
- data/lib/avo/licensing/license.rb +10 -0
- data/lib/avo/licensing/pro_license.rb +4 -1
- data/lib/avo/services/authorization_service.rb +1 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/eject_generator.rb +1 -0
- data/lib/generators/avo/field_generator.rb +17 -0
- data/lib/generators/avo/filter_generator.rb +1 -1
- data/lib/generators/avo/templates/field/%singular_name%_field.rb.tt +5 -0
- data/lib/generators/avo/templates/field/components/edit_component.html.erb.tt +6 -0
- data/lib/generators/avo/templates/field/components/edit_component.rb.tt +4 -0
- data/lib/generators/avo/templates/field/components/index_component.html.erb.tt +3 -0
- data/lib/generators/avo/templates/field/components/index_component.rb.tt +4 -0
- data/lib/generators/avo/templates/field/components/show_component.html.erb.tt +3 -0
- data/lib/generators/avo/templates/field/components/show_component.rb.tt +4 -0
- data/lib/generators/avo/templates/initializer/avo.tt +1 -0
- data/lib/generators/avo/templates/resource/resource.tt +3 -0
- data/lib/generators/avo/templates/tool/view.tt +1 -1
- data/public/avo-packs/css/{application-5bdca030.css → application-d69fe930.css} +303 -50
- data/public/avo-packs/css/application-d69fe930.css.br +0 -0
- data/public/avo-packs/css/application-d69fe930.css.gz +0 -0
- data/public/avo-packs/css/application-d69fe930.css.map +1 -0
- data/public/avo-packs/css/application-d69fe930.css.map.br +0 -0
- data/public/avo-packs/css/application-d69fe930.css.map.gz +0 -0
- data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js +26 -0
- data/public/avo-packs/js/{application-16a456a2b7cb56b01153.js.LICENSE.txt → application-7b3d507875f4bc1f6677.js.LICENSE.txt} +0 -0
- data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.br +0 -0
- data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.gz +0 -0
- data/public/avo-packs/js/{application-16a456a2b7cb56b01153.js.map → application-7b3d507875f4bc1f6677.js.map} +1 -1
- data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.map.br +0 -0
- data/public/avo-packs/js/application-7b3d507875f4bc1f6677.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +15 -15
- metadata +206 -173
- data/app/components/avo/common/files_list_viewer_component.html.erb +0 -5
- data/app/components/avo/common/status_viewer_component.html.erb +0 -10
- data/app/components/avo/edit/fields/boolean_field_component.rb +0 -4
- data/app/components/avo/edit/fields/boolean_group_field_component.rb +0 -4
- data/app/components/avo/edit/fields/code_field_component.rb +0 -4
- data/app/components/avo/edit/fields/country_field_component.rb +0 -4
- data/app/components/avo/edit/fields/date_field_component.rb +0 -4
- data/app/components/avo/edit/fields/date_time_field_component.rb +0 -4
- data/app/components/avo/edit/fields/external_image_field_component.rb +0 -4
- data/app/components/avo/edit/fields/file_field_component.rb +0 -4
- data/app/components/avo/edit/fields/files_field_component.rb +0 -4
- data/app/components/avo/edit/fields/heading_field_component.rb +0 -4
- data/app/components/avo/edit/fields/hidden_field_component.rb +0 -4
- data/app/components/avo/edit/fields/id_field_component.rb +0 -4
- data/app/components/avo/edit/fields/key_value_field_component.rb +0 -4
- data/app/components/avo/edit/fields/markdown_field_component.rb +0 -4
- data/app/components/avo/edit/fields/number_field_component.rb +0 -4
- data/app/components/avo/edit/fields/password_field_component.rb +0 -4
- data/app/components/avo/edit/fields/select_field_component.rb +0 -4
- data/app/components/avo/edit/fields/status_field_component.rb +0 -4
- data/app/components/avo/edit/fields/text_field_component.rb +0 -4
- data/app/components/avo/edit/fields/textarea_field_component.rb +0 -4
- data/app/components/avo/edit/fields/trix_field_component.rb +0 -4
- data/app/components/avo/index/fields/badge_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/badge_field_component.rb +0 -4
- data/app/components/avo/index/fields/belongs_to_field_component.rb +0 -4
- data/app/components/avo/index/fields/boolean_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/boolean_field_component.rb +0 -4
- data/app/components/avo/index/fields/boolean_group_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/boolean_group_field_component.rb +0 -4
- data/app/components/avo/index/fields/country_field_component.rb +0 -4
- data/app/components/avo/index/fields/date_field_component.rb +0 -4
- data/app/components/avo/index/fields/date_time_field_component.rb +0 -4
- data/app/components/avo/index/fields/external_image_field_component.rb +0 -4
- data/app/components/avo/index/fields/field_component.html.erb +0 -1
- data/app/components/avo/index/fields/field_component.rb +0 -11
- data/app/components/avo/index/fields/file_field_component.rb +0 -4
- data/app/components/avo/index/fields/files_field_component.rb +0 -4
- data/app/components/avo/index/fields/gravatar_field_component.rb +0 -4
- data/app/components/avo/index/fields/has_one_field_component.rb +0 -4
- data/app/components/avo/index/fields/id_field_component.html.erb +0 -10
- data/app/components/avo/index/fields/id_field_component.rb +0 -4
- data/app/components/avo/index/fields/number_field_component.rb +0 -4
- data/app/components/avo/index/fields/select_field_component.rb +0 -4
- data/app/components/avo/index/fields/status_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/status_field_component.rb +0 -4
- data/app/components/avo/index/fields/text_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/text_field_component.rb +0 -4
- data/app/components/avo/show/fields/badge_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/badge_field_component.rb +0 -4
- data/app/components/avo/show/fields/belongs_to_field_component.rb +0 -4
- data/app/components/avo/show/fields/boolean_field_component.rb +0 -4
- data/app/components/avo/show/fields/boolean_group_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/boolean_group_field_component.rb +0 -4
- data/app/components/avo/show/fields/code_field_component.rb +0 -4
- data/app/components/avo/show/fields/country_field_component.rb +0 -4
- data/app/components/avo/show/fields/date_field_component.rb +0 -4
- data/app/components/avo/show/fields/date_time_field_component.rb +0 -4
- data/app/components/avo/show/fields/external_image_field_component.rb +0 -4
- data/app/components/avo/show/fields/file_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/file_field_component.rb +0 -4
- data/app/components/avo/show/fields/files_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/files_field_component.rb +0 -4
- data/app/components/avo/show/fields/gravatar_field_component.rb +0 -4
- data/app/components/avo/show/fields/has_many_field_component.rb +0 -4
- data/app/components/avo/show/fields/has_one_field_component.rb +0 -5
- data/app/components/avo/show/fields/heading_field_component.rb +0 -4
- data/app/components/avo/show/fields/id_field_component.rb +0 -4
- data/app/components/avo/show/fields/key_value_field_component.rb +0 -4
- data/app/components/avo/show/fields/markdown_field_component.rb +0 -4
- data/app/components/avo/show/fields/number_field_component.rb +0 -4
- data/app/components/avo/show/fields/select_field_component.rb +0 -4
- data/app/components/avo/show/fields/status_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/status_field_component.rb +0 -4
- data/app/components/avo/show/fields/text_field_component.rb +0 -4
- data/app/components/avo/show/fields/textarea_field_component.rb +0 -4
- data/app/components/avo/show/fields/trix_field_component.rb +0 -4
- data/public/avo-packs/css/application-5bdca030.css.br +0 -0
- data/public/avo-packs/css/application-5bdca030.css.gz +0 -0
- data/public/avo-packs/css/application-5bdca030.css.map +0 -1
- data/public/avo-packs/css/application-5bdca030.css.map.br +0 -0
- data/public/avo-packs/css/application-5bdca030.css.map.gz +0 -0
- data/public/avo-packs/js/application-16a456a2b7cb56b01153.js +0 -26
- data/public/avo-packs/js/application-16a456a2b7cb56b01153.js.br +0 -0
- data/public/avo-packs/js/application-16a456a2b7cb56b01153.js.gz +0 -0
- data/public/avo-packs/js/application-16a456a2b7cb56b01153.js.map.br +0 -0
- data/public/avo-packs/js/application-16a456a2b7cb56b01153.js.map.gz +0 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
<div data-controller="search" class="resource-search flex items-center h-full w-full" data-turbo-remove-before-cache>
|
2
|
+
<div class="w-full"
|
3
|
+
data-search-target="autocomplete"
|
4
|
+
data-search-resource="<%= resource %>"
|
5
|
+
data-translation-keys='{"no_item_found": "<%= I18n.translate 'avo.no_item_found' %>"}'
|
6
|
+
data-debounce-timeout='<%= Avo.configuration.search_debounce %>'
|
7
|
+
>
|
8
|
+
</div>
|
9
|
+
<div class="relative inline-flex text-gray-400 text-sm border border-gray-300 rounded-full cursor-pointer" data-search-target="button"></div>
|
10
|
+
</div>
|
@@ -19,14 +19,15 @@
|
|
19
19
|
<%= render partial: 'avo/sidebar/sidebar' %>
|
20
20
|
|
21
21
|
<div class="flex-1 flex flex-col h-full overflow-auto">
|
22
|
-
<div class="relative bg-white p-2 shadow-md h-16 w-full flex flex-shrink-0 items-center z-50" v-if="layout !== 'blank'">
|
23
|
-
<div
|
22
|
+
<div class="relative bg-white p-2 shadow-md h-16 w-full flex flex-shrink-0 items-center z-50 px-6" v-if="layout !== 'blank'">
|
23
|
+
<div>
|
24
24
|
<%= render partial: "avo/partials/header" %>
|
25
25
|
</div>
|
26
|
-
<div class="flex-1 flex
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
<div class="flex-1 flex ml-4 pl-4">
|
27
|
+
<%= render partial: "avo/partials/global_search" if ::Avo::App.license.has_with_trial(:global_search) %>
|
28
|
+
</div>
|
29
|
+
<div class="align-end">
|
30
|
+
<%= render partial: "avo/partials/profile_dropdown" %>
|
30
31
|
</div>
|
31
32
|
</div>
|
32
33
|
|
data/avo.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.files = Dir["{bin,app,config,db,lib,public}/**/*", "MIT-LICENSE", "Rakefile", "README.md", "avo.gemspec", "Gemfile", "Gemfile.lock"]
|
33
33
|
|
34
34
|
spec.add_dependency "rails", ">= 6.0"
|
35
|
-
spec.add_dependency "pagy"
|
35
|
+
spec.add_dependency "pagy"
|
36
36
|
spec.add_dependency "zeitwerk"
|
37
37
|
spec.add_dependency "countries"
|
38
38
|
spec.add_dependency "pundit"
|
@@ -45,4 +45,5 @@ Gem::Specification.new do |spec|
|
|
45
45
|
spec.add_dependency "meta-tags"
|
46
46
|
spec.add_dependency "breadcrumbs_on_rails"
|
47
47
|
spec.add_dependency "manifester"
|
48
|
+
spec.add_dependency "ransack"
|
48
49
|
end
|
data/config/routes.rb
CHANGED
@@ -4,6 +4,8 @@ Avo::Engine.routes.draw do
|
|
4
4
|
get "resources", to: redirect("/avo")
|
5
5
|
|
6
6
|
scope "avo_api", as: "avo_api" do
|
7
|
+
get "/search", to: "search#index"
|
8
|
+
get "/:resource_name/search", to: "search#show"
|
7
9
|
post "/resources/:resource_name/:id/attachments/", to: "attachments#create"
|
8
10
|
end
|
9
11
|
|
@@ -27,10 +29,4 @@ Avo::Engine.routes.draw do
|
|
27
29
|
post "/:resource_name/:id/:related_name", to: "relations#create"
|
28
30
|
delete "/:resource_name/:id/:related_name/:related_id", to: "relations#destroy"
|
29
31
|
end
|
30
|
-
|
31
|
-
# get '/avo-api/search', to: 'search#index'
|
32
|
-
# get '/avo-api/:resource_name/search', to: 'search#resource'
|
33
|
-
|
34
|
-
# Tools
|
35
|
-
# get '/avo-tools/resource-overview', to: 'resource_overview#index'
|
36
32
|
end
|
data/db/factories.rb
CHANGED
@@ -13,6 +13,7 @@ FactoryBot.define do
|
|
13
13
|
name { Faker::Company.name }
|
14
14
|
description { Faker::Lorem.paragraph(sentence_count: 4) }
|
15
15
|
url { Faker::Internet.url }
|
16
|
+
color { Faker::Color.hex_color }
|
16
17
|
end
|
17
18
|
|
18
19
|
factory :post do
|
@@ -24,6 +25,7 @@ FactoryBot.define do
|
|
24
25
|
Time.now - rand(10...365).days
|
25
26
|
end
|
26
27
|
end
|
28
|
+
status { 0 }
|
27
29
|
end
|
28
30
|
|
29
31
|
factory :project do
|
@@ -36,5 +38,6 @@ FactoryBot.define do
|
|
36
38
|
users_required { Faker::Number.between(from: 10, to: 100) }
|
37
39
|
started_at { Time.now - rand(10...365).days }
|
38
40
|
meta { [{foo: "bar", hey: "hi"}, {bar: "baz"}, {hoho: "hohoho"}].sample }
|
41
|
+
progress { Faker::Number.between(from: 0, to: 100) }
|
39
42
|
end
|
40
43
|
end
|
data/lib/avo/app.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module Avo
|
2
2
|
class App
|
3
|
-
class_attribute :
|
4
|
-
|
5
|
-
cache_store: nil
|
6
|
-
}
|
3
|
+
class_attribute :resources, default: []
|
4
|
+
class_attribute :cache_store, default: nil
|
7
5
|
class_attribute :fields, default: []
|
8
6
|
class_attribute :request, default: nil
|
9
7
|
class_attribute :context, default: nil
|
10
8
|
class_attribute :license, default: nil
|
9
|
+
class_attribute :current_user, default: nil
|
11
10
|
|
12
11
|
class << self
|
13
12
|
def boot
|
@@ -16,15 +15,16 @@ module Avo
|
|
16
15
|
I18n.locale = Avo.configuration.language_code
|
17
16
|
|
18
17
|
if Rails.cache.instance_of?(ActiveSupport::Cache::NullStore)
|
19
|
-
|
18
|
+
self.cache_store ||= ActiveSupport::Cache::MemoryStore.new
|
20
19
|
else
|
21
|
-
|
20
|
+
self.cache_store = Rails.cache
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
|
-
def init(request:, context:)
|
24
|
+
def init(request:, context:, current_user:)
|
26
25
|
self.request = request
|
27
26
|
self.context = context
|
27
|
+
self.current_user = current_user
|
28
28
|
|
29
29
|
self.license = Licensing::LicenseManager.new(Licensing::HQ.new(request).response).license
|
30
30
|
|
@@ -38,10 +38,6 @@ module Avo
|
|
38
38
|
init_resources
|
39
39
|
end
|
40
40
|
|
41
|
-
def cache_store
|
42
|
-
app[:cache_store]
|
43
|
-
end
|
44
|
-
|
45
41
|
# This method will find all fields available in the Avo::Fields namespace and add them to the fields class_variable array
|
46
42
|
# so later we can instantiate them on our resources.
|
47
43
|
#
|
@@ -67,7 +63,7 @@ module Avo
|
|
67
63
|
end
|
68
64
|
|
69
65
|
def init_resources
|
70
|
-
|
66
|
+
self.resources = BaseResource.descendants
|
71
67
|
.select do |resource|
|
72
68
|
resource != BaseResource
|
73
69
|
end
|
@@ -78,15 +74,11 @@ module Avo
|
|
78
74
|
end
|
79
75
|
end
|
80
76
|
|
81
|
-
def get_resources
|
82
|
-
app[:resources]
|
83
|
-
end
|
84
|
-
|
85
77
|
# Returns the Avo resource by camelized name
|
86
78
|
#
|
87
79
|
# get_resource_by_name('User') => UserResource
|
88
80
|
def get_resource(resource)
|
89
|
-
|
81
|
+
resources.find do |available_resource|
|
90
82
|
"#{resource}Resource".safe_constantize == available_resource.class
|
91
83
|
end
|
92
84
|
end
|
@@ -103,7 +95,7 @@ module Avo
|
|
103
95
|
# get_resource_by_name('User') => UserResource
|
104
96
|
# get_resource_by_name(User) => UserResource
|
105
97
|
def get_resource_by_model_name(name)
|
106
|
-
|
98
|
+
resources.find do |resource|
|
107
99
|
resource.model_class.model_name.name == name.to_s
|
108
100
|
end
|
109
101
|
end
|
@@ -113,7 +105,7 @@ module Avo
|
|
113
105
|
# get_resource_by_controller_name('delayed_backend_active_record_jobs') => DelayedJobResource
|
114
106
|
# get_resource_by_controller_name('users') => UserResource
|
115
107
|
def get_resource_by_controller_name(name)
|
116
|
-
|
108
|
+
resources.find do |resource|
|
117
109
|
resource.model_class.to_s.pluralize.underscore.tr("/", "_") == name.to_s
|
118
110
|
end
|
119
111
|
end
|
@@ -126,8 +118,7 @@ module Avo
|
|
126
118
|
end
|
127
119
|
|
128
120
|
def get_available_resources(user = nil)
|
129
|
-
|
130
|
-
.select do |resource|
|
121
|
+
resources.select do |resource|
|
131
122
|
Services::AuthorizationService.authorize user, resource.model, Avo.configuration.authorization_methods.stringify_keys["index"], raise_exception: false
|
132
123
|
end
|
133
124
|
.sort_by { |r| r.name }
|
data/lib/avo/base_resource.rb
CHANGED
@@ -11,7 +11,7 @@ module Avo
|
|
11
11
|
|
12
12
|
class_attribute :id, default: :id
|
13
13
|
class_attribute :title, default: :id
|
14
|
-
class_attribute :
|
14
|
+
class_attribute :search_query, default: nil
|
15
15
|
class_attribute :includes, default: []
|
16
16
|
class_attribute :model_class
|
17
17
|
class_attribute :translation_key
|
@@ -42,6 +42,18 @@ module Avo
|
|
42
42
|
|
43
43
|
self.filters_loader.use filter_class
|
44
44
|
end
|
45
|
+
|
46
|
+
def scope
|
47
|
+
authorization.apply_policy model_class
|
48
|
+
end
|
49
|
+
|
50
|
+
def authorization
|
51
|
+
Avo::Services::AuthorizationService.new Avo::App.current_user
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize
|
56
|
+
self.class.model_class = model_class
|
45
57
|
end
|
46
58
|
|
47
59
|
def hydrate(model: nil, view: nil, user: nil, params: nil)
|
@@ -61,9 +73,17 @@ module Avo
|
|
61
73
|
def get_field_definitions
|
62
74
|
return [] if self.class.fields.blank?
|
63
75
|
|
64
|
-
self.class.fields.map do |field|
|
76
|
+
fields = self.class.fields.map do |field|
|
65
77
|
field.hydrate(resource: self, panel_name: default_panel_name, user: user)
|
66
78
|
end
|
79
|
+
|
80
|
+
if Avo::App.license.has_with_trial(:custom_fields)
|
81
|
+
fields = fields.reject do |field|
|
82
|
+
field.custom?
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
fields
|
67
87
|
end
|
68
88
|
|
69
89
|
def get_fields(panel: nil, reflection: nil)
|
@@ -88,9 +108,9 @@ module Avo
|
|
88
108
|
end
|
89
109
|
end
|
90
110
|
|
91
|
-
|
92
|
-
|
93
|
-
|
111
|
+
hydrate_fields(model: @model, view: @view)
|
112
|
+
|
113
|
+
fields
|
94
114
|
end
|
95
115
|
|
96
116
|
def get_grid_fields
|
@@ -111,8 +131,16 @@ module Avo
|
|
111
131
|
self.class.actions_loader.bag
|
112
132
|
end
|
113
133
|
|
134
|
+
def hydrate_fields(model: nil, view: nil)
|
135
|
+
fields.map do |field|
|
136
|
+
field.hydrate(model: @model, view: @view, resource: self)
|
137
|
+
end
|
138
|
+
|
139
|
+
self
|
140
|
+
end
|
141
|
+
|
114
142
|
def default_panel_name
|
115
|
-
return @params[:related_name].capitalize if @params[:related_name].present?
|
143
|
+
return @params[:related_name].capitalize if @params.present? && @params[:related_name].present?
|
116
144
|
|
117
145
|
case @view
|
118
146
|
when :show
|
@@ -218,7 +246,11 @@ module Avo
|
|
218
246
|
|
219
247
|
def fill_model(model, params)
|
220
248
|
# Map the received params to their actual fields
|
221
|
-
fields_by_database_id = get_field_definitions
|
249
|
+
fields_by_database_id = get_field_definitions
|
250
|
+
.reject do |field|
|
251
|
+
field.computed
|
252
|
+
end
|
253
|
+
.map { |field| [field.database_id(model).to_s, field] }.to_h
|
222
254
|
|
223
255
|
params.each do |key, value|
|
224
256
|
field = fields_by_database_id[key]
|
@@ -293,5 +325,57 @@ module Avo
|
|
293
325
|
end
|
294
326
|
end
|
295
327
|
end
|
328
|
+
|
329
|
+
def avo_path
|
330
|
+
"#{Avo.configuration.root_path}/resources/#{model_class.model_name.route_key}/#{model.id}"
|
331
|
+
end
|
332
|
+
|
333
|
+
def label_field
|
334
|
+
get_field_definitions.find do |field|
|
335
|
+
field.as_label.present?
|
336
|
+
end
|
337
|
+
rescue
|
338
|
+
nil
|
339
|
+
end
|
340
|
+
|
341
|
+
def label
|
342
|
+
label_field.value || model_title
|
343
|
+
rescue
|
344
|
+
model_title
|
345
|
+
end
|
346
|
+
|
347
|
+
def avatar_field
|
348
|
+
get_field_definitions.find do |field|
|
349
|
+
field.as_avatar.present?
|
350
|
+
end
|
351
|
+
rescue
|
352
|
+
nil
|
353
|
+
end
|
354
|
+
|
355
|
+
def avatar
|
356
|
+
avatar_field.to_image
|
357
|
+
rescue
|
358
|
+
nil
|
359
|
+
end
|
360
|
+
|
361
|
+
def avatar_type
|
362
|
+
avatar_field.as_avatar
|
363
|
+
rescue
|
364
|
+
nil
|
365
|
+
end
|
366
|
+
|
367
|
+
def description_field
|
368
|
+
get_field_definitions.find do |field|
|
369
|
+
field.as_description.present?
|
370
|
+
end
|
371
|
+
rescue
|
372
|
+
nil
|
373
|
+
end
|
374
|
+
|
375
|
+
def description
|
376
|
+
description_field.value
|
377
|
+
rescue
|
378
|
+
nil
|
379
|
+
end
|
296
380
|
end
|
297
381
|
end
|
data/lib/avo/configuration.rb
CHANGED
@@ -22,6 +22,7 @@ module Avo
|
|
22
22
|
attr_accessor :display_breadcrumbs
|
23
23
|
attr_accessor :initial_breadcrumbs
|
24
24
|
attr_accessor :home_path
|
25
|
+
attr_accessor :search_debounce
|
25
26
|
|
26
27
|
def initialize
|
27
28
|
@root_path = "/avo"
|
@@ -35,7 +36,7 @@ module Avo
|
|
35
36
|
@default_view_type = :table
|
36
37
|
@license = "community"
|
37
38
|
@license_key = nil
|
38
|
-
@current_user = proc {}
|
39
|
+
@current_user = proc { current_user }
|
39
40
|
@authenticate = proc {}
|
40
41
|
@authorization_methods = {
|
41
42
|
index: "index?",
|
@@ -56,6 +57,7 @@ module Avo
|
|
56
57
|
}
|
57
58
|
@display_breadcrumbs = true
|
58
59
|
@home_path = nil
|
60
|
+
@search_debounce = 300
|
59
61
|
end
|
60
62
|
|
61
63
|
def locale_tag
|
data/lib/avo/engine.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
module Avo
|
2
2
|
module Fields
|
3
3
|
class BadgeField < BaseField
|
4
|
-
|
5
|
-
@defaults = {
|
6
|
-
partial_name: "badge-field"
|
7
|
-
}
|
4
|
+
attr_reader :options
|
8
5
|
|
9
|
-
|
6
|
+
def initialize(id, **args, &block)
|
7
|
+
super(id, **args, &block)
|
10
8
|
|
11
9
|
hide_on [:edit, :new]
|
12
10
|
|
13
11
|
default_options = {info: :info, success: :success, danger: :danger, warning: :warning}
|
14
|
-
@
|
12
|
+
@options = args[:options].present? ? default_options.merge(args[:options]) : default_options
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
@@ -5,91 +5,71 @@ module Avo
|
|
5
5
|
extend Avo::Fields::FieldExtensions::HasFieldName
|
6
6
|
include Avo::Fields::FieldExtensions::VisibleInDifferentViews
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
8
|
+
attr_reader :id
|
9
|
+
attr_reader :name
|
10
|
+
attr_reader :translation_key
|
11
|
+
attr_reader :block
|
12
|
+
attr_reader :required
|
13
|
+
attr_reader :readonly
|
14
|
+
attr_reader :sortable
|
15
|
+
attr_reader :nullable
|
16
|
+
attr_reader :null_values
|
17
|
+
attr_reader :format_using
|
18
|
+
attr_reader :placeholder
|
19
|
+
attr_reader :help
|
20
|
+
attr_reader :default
|
21
|
+
attr_reader :visible
|
22
|
+
attr_reader :as_label
|
23
|
+
attr_reader :as_avatar
|
24
|
+
attr_reader :as_description
|
25
|
+
|
26
|
+
# Private options
|
27
|
+
attr_reader :updatable
|
28
|
+
attr_reader :computable # if allowed to be computable
|
29
|
+
attr_reader :computed # if block is present
|
30
|
+
attr_reader :computed_value # the value after computation
|
31
|
+
|
32
|
+
# Hydrated payload
|
33
|
+
attr_reader :model
|
34
|
+
attr_reader :view
|
35
|
+
attr_reader :resource
|
36
|
+
attr_reader :action
|
37
|
+
attr_reader :user
|
38
|
+
attr_reader :panel_name
|
37
39
|
|
38
40
|
class_attribute :field_name_attribute
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
def initialize(id, **args, &block)
|
42
|
+
def initialize(id, _options: {}, **args, &block)
|
43
43
|
super(id, **args, &block)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
@
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
help: nil,
|
68
|
-
default: nil,
|
69
|
-
visible: true,
|
70
|
-
meta: {},
|
71
|
-
panel_name: nil,
|
72
|
-
options: {}
|
73
|
-
}
|
74
|
-
|
75
|
-
# Set the values in the following order
|
76
|
-
# - app defaults
|
77
|
-
# - field defaults
|
78
|
-
# - field option
|
79
|
-
@field_properties.each do |name, default_value|
|
80
|
-
final_value = args[name.to_sym]
|
81
|
-
send("#{name}=", name != "null_values" && (final_value.nil? || !defined?(final_value)) ? default_value : final_value)
|
82
|
-
end
|
44
|
+
|
45
|
+
@id = id
|
46
|
+
@name = args[:name] || id.to_s.humanize(keep_id_suffix: true)
|
47
|
+
@translation_key = args[:translation_key]
|
48
|
+
@block = block
|
49
|
+
@required = args[:required] || false
|
50
|
+
@readonly = args[:readonly] || false
|
51
|
+
@sortable = args[:sortable] || false
|
52
|
+
@nullable = args[:nullable] || false
|
53
|
+
@null_values = args[:null_values] || [nil, ""]
|
54
|
+
@format_using = args[:format_using] || nil
|
55
|
+
@placeholder = args[:placeholder] || id.to_s.humanize(keep_id_suffix: true)
|
56
|
+
@help = args[:help] || nil
|
57
|
+
@default = args[:default] || nil
|
58
|
+
@visible = args[:visible] || true
|
59
|
+
@as_label = args[:as_label] || false
|
60
|
+
@as_avatar = args[:as_avatar] || false
|
61
|
+
@as_description = args[:as_description] || false
|
62
|
+
|
63
|
+
@updatable = true
|
64
|
+
@computable = true
|
65
|
+
@computed = block.present?
|
66
|
+
@computed_value = nil
|
83
67
|
|
84
68
|
# Set the visibility
|
85
69
|
show_on args[:show_on] if args[:show_on].present?
|
86
70
|
hide_on args[:hide_on] if args[:hide_on].present?
|
87
71
|
only_on args[:only_on] if args[:only_on].present?
|
88
72
|
except_on args[:except_on] if args[:except_on].present?
|
89
|
-
|
90
|
-
if args[:use_partials].present?
|
91
|
-
@custom_partials = args[:use_partials]
|
92
|
-
end
|
93
73
|
end
|
94
74
|
|
95
75
|
def hydrate(model: nil, resource: nil, action: nil, view: nil, panel_name: nil, user: nil)
|
@@ -142,12 +122,6 @@ module Avo
|
|
142
122
|
model
|
143
123
|
end
|
144
124
|
|
145
|
-
def partial_path_for(view)
|
146
|
-
return @custom_partials[view] if @custom_partials.present? && @custom_partials[view].present?
|
147
|
-
|
148
|
-
"avo/fields/#{view}/#{partial_name}"
|
149
|
-
end
|
150
|
-
|
151
125
|
# Try to see if the field has a different database ID than it's name
|
152
126
|
def database_id(model)
|
153
127
|
foreign_key
|
@@ -167,8 +141,13 @@ module Avo
|
|
167
141
|
id.to_sym
|
168
142
|
end
|
169
143
|
|
170
|
-
def
|
171
|
-
"
|
144
|
+
def view_component_name
|
145
|
+
"#{type.classify}Field"
|
146
|
+
end
|
147
|
+
|
148
|
+
def component_for_view(view = :index)
|
149
|
+
# puts ['component_for_view->', "Avo::Fields::#{type.classify}Field::#{view.to_s.classify}Component"].inspect
|
150
|
+
"Avo::Fields::#{view_component_name}::#{view.to_s.classify}Component".safe_constantize
|
172
151
|
end
|
173
152
|
|
174
153
|
def model_errors
|
@@ -181,6 +160,12 @@ module Avo
|
|
181
160
|
self.class.name.demodulize.to_s.underscore.gsub("_field", "")
|
182
161
|
end
|
183
162
|
|
163
|
+
def custom?
|
164
|
+
!method(:initialize).source_location.first.include?("lib/avo/field")
|
165
|
+
rescue
|
166
|
+
true
|
167
|
+
end
|
168
|
+
|
184
169
|
private
|
185
170
|
|
186
171
|
def model_or_class(model)
|