avo 0.4.6 → 0.5.0.beta1
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 +35 -9
- data/Gemfile.lock +114 -88
- data/README.md +4 -0
- data/app/components/avo/common/badge_viewer_component.html.erb +24 -0
- data/app/components/avo/common/badge_viewer_component.rb +8 -0
- data/app/components/avo/common/boolean_check_component.html.erb +12 -0
- data/app/components/avo/common/boolean_check_component.rb +7 -0
- data/app/components/avo/common/boolean_group_component.html.erb +16 -0
- data/app/components/avo/common/boolean_group_component.rb +8 -0
- data/app/components/avo/common/files_list_viewer_component.html.erb +5 -0
- data/app/components/avo/common/files_list_viewer_component.rb +8 -0
- data/app/components/avo/common/gravatar_viewer_component.html.erb +12 -0
- data/app/components/avo/common/gravatar_viewer_component.rb +12 -0
- data/app/components/avo/common/heading_component.html.erb +13 -0
- data/app/components/avo/common/heading_component.rb +8 -0
- data/app/components/avo/common/multiple_file_viewer_component.html.erb +26 -0
- data/app/components/avo/common/multiple_file_viewer_component.rb +13 -0
- data/app/components/avo/common/single_file_viewer_component.html.erb +28 -0
- data/app/components/avo/common/single_file_viewer_component.rb +13 -0
- data/app/components/avo/common/status_viewer_component.html.erb +10 -0
- data/app/components/avo/common/status_viewer_component.rb +8 -0
- data/app/components/avo/edit/field_wrapper_component.html.erb +20 -0
- data/app/components/avo/edit/field_wrapper_component.rb +19 -0
- data/app/components/avo/edit/fields/belongs_to_field_component.html.erb +19 -0
- data/app/components/avo/edit/fields/belongs_to_field_component.rb +4 -0
- data/app/components/avo/edit/fields/boolean_field_component.html.erb +9 -0
- data/app/components/avo/edit/fields/boolean_field_component.rb +4 -0
- data/app/components/avo/edit/fields/boolean_group_field_component.html.erb +25 -0
- data/app/components/avo/edit/fields/boolean_group_field_component.rb +4 -0
- data/app/components/avo/edit/fields/code_field_component.html.erb +19 -0
- data/app/components/avo/edit/fields/code_field_component.rb +4 -0
- data/app/components/avo/edit/fields/country_field_component.html.erb +7 -0
- data/app/components/avo/edit/fields/country_field_component.rb +4 -0
- data/app/components/avo/edit/fields/date_field_component.html.erb +18 -0
- data/app/components/avo/edit/fields/date_field_component.rb +4 -0
- data/app/components/avo/edit/fields/date_time_field_component.html.erb +20 -0
- data/app/components/avo/edit/fields/date_time_field_component.rb +4 -0
- data/app/components/avo/edit/fields/external_image_field_component.html.erb +6 -0
- data/app/components/avo/edit/fields/external_image_field_component.rb +4 -0
- data/app/components/avo/edit/fields/field_component.rb +13 -0
- data/app/components/avo/edit/fields/file_field_component.html.erb +9 -0
- data/app/components/avo/edit/fields/file_field_component.rb +4 -0
- data/app/components/avo/edit/fields/files_field_component.html.erb +5 -0
- data/app/components/avo/edit/fields/files_field_component.rb +4 -0
- data/app/components/avo/edit/fields/heading_field_component.html.erb +3 -0
- data/app/components/avo/edit/fields/heading_field_component.rb +4 -0
- data/app/components/avo/edit/fields/hidden_field_component.html.erb +1 -0
- data/app/components/avo/edit/fields/hidden_field_component.rb +4 -0
- data/app/components/avo/edit/fields/id_field_component.html.erb +3 -0
- data/app/components/avo/edit/fields/id_field_component.rb +4 -0
- data/app/components/avo/edit/fields/markdown_field_component.html.erb +11 -0
- data/app/components/avo/edit/fields/markdown_field_component.rb +4 -0
- data/app/components/avo/edit/fields/number_field_component.html.erb +9 -0
- data/app/components/avo/edit/fields/number_field_component.rb +4 -0
- data/app/components/avo/edit/fields/password_field_component.html.erb +7 -0
- data/app/components/avo/edit/fields/password_field_component.rb +4 -0
- data/app/components/avo/edit/fields/select_field_component.html.erb +6 -0
- data/app/components/avo/edit/fields/select_field_component.rb +4 -0
- data/app/components/avo/edit/fields/status_field_component.html.erb +7 -0
- data/app/components/avo/edit/fields/status_field_component.rb +4 -0
- data/app/components/avo/edit/fields/text_field_component.html.erb +6 -0
- data/app/components/avo/edit/fields/text_field_component.rb +4 -0
- data/app/components/avo/edit/fields/textarea_field_component.html.erb +7 -0
- data/app/components/avo/edit/fields/textarea_field_component.rb +4 -0
- data/app/components/avo/edit/fields/trix_field_component.html.erb +11 -0
- data/app/components/avo/edit/fields/trix_field_component.rb +4 -0
- data/app/components/avo/index/field_wrapper_component.html.erb +7 -0
- data/app/components/avo/index/field_wrapper_component.rb +10 -0
- data/app/components/avo/index/fields/badge_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/badge_field_component.rb +4 -0
- data/app/components/avo/index/fields/belongs_to_field_component.html.erb +7 -0
- data/app/components/avo/index/fields/belongs_to_field_component.rb +4 -0
- data/app/components/avo/index/fields/boolean_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/boolean_field_component.rb +4 -0
- data/app/components/avo/index/fields/boolean_group_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/boolean_group_field_component.rb +4 -0
- data/app/components/avo/index/fields/country_field_component.html.erb +7 -0
- data/app/components/avo/index/fields/country_field_component.rb +4 -0
- data/app/components/avo/index/fields/date_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/date_field_component.rb +4 -0
- data/app/components/avo/index/fields/date_time_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/date_time_field_component.rb +4 -0
- data/app/components/avo/index/fields/external_image_field_component.html.erb +9 -0
- data/app/components/avo/index/fields/external_image_field_component.rb +4 -0
- data/app/components/avo/index/fields/field_component.html.erb +1 -0
- data/app/components/avo/index/fields/field_component.rb +11 -0
- data/app/components/avo/index/fields/file_field_component.html.erb +11 -0
- data/app/components/avo/index/fields/file_field_component.rb +4 -0
- data/app/components/avo/index/fields/files_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/files_field_component.rb +4 -0
- data/app/components/avo/index/fields/gravatar_field_component.html.erb +11 -0
- data/app/components/avo/index/fields/gravatar_field_component.rb +4 -0
- data/app/components/avo/index/fields/has_one_field_component.html.erb +7 -0
- data/app/components/avo/index/fields/has_one_field_component.rb +4 -0
- data/app/components/avo/index/fields/id_field_component.html.erb +10 -0
- data/app/components/avo/index/fields/id_field_component.rb +4 -0
- data/app/components/avo/index/fields/number_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/number_field_component.rb +4 -0
- data/app/components/avo/index/fields/select_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/select_field_component.rb +4 -0
- data/app/components/avo/index/fields/status_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/status_field_component.rb +4 -0
- data/app/components/avo/index/fields/text_field_component.html.erb +3 -0
- data/app/components/avo/index/fields/text_field_component.rb +4 -0
- data/app/components/avo/index/grid_item_component.html.erb +41 -0
- data/app/components/avo/index/grid_item_component.rb +31 -0
- data/app/components/avo/index/resource_controls_component.html.erb +56 -0
- data/app/components/avo/index/resource_controls_component.rb +39 -0
- data/app/components/avo/index/resource_grid_component.html.erb +13 -0
- data/app/components/avo/index/resource_grid_component.rb +10 -0
- data/app/components/avo/index/resource_table_component.html.erb +16 -0
- data/app/components/avo/index/resource_table_component.rb +10 -0
- data/app/components/avo/index/table_row_component.html.erb +18 -0
- data/app/components/avo/index/table_row_component.rb +11 -0
- data/app/components/avo/loading_component.html.erb +10 -0
- data/app/components/avo/loading_component.rb +7 -0
- data/app/components/avo/modal_component.html.erb +20 -0
- data/app/components/avo/modal_component.rb +5 -0
- data/app/components/avo/navigation_heading_component.html.erb +3 -0
- data/app/components/avo/navigation_heading_component.rb +7 -0
- data/app/components/avo/navigation_link_component.html.erb +3 -0
- data/app/components/avo/navigation_link_component.rb +10 -0
- data/app/components/avo/panel_component.html.erb +27 -0
- data/app/components/avo/panel_component.rb +20 -0
- data/app/components/avo/resource_component.rb +14 -0
- data/app/components/avo/show/field_wrapper_component.html.erb +16 -0
- data/app/components/avo/show/field_wrapper_component.rb +15 -0
- data/app/components/avo/show/fields/badge_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/badge_field_component.rb +4 -0
- data/app/components/avo/show/fields/belongs_to_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/belongs_to_field_component.rb +4 -0
- data/app/components/avo/show/fields/boolean_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/boolean_field_component.rb +4 -0
- data/app/components/avo/show/fields/boolean_group_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/boolean_group_field_component.rb +4 -0
- data/app/components/avo/show/fields/code_field_component.html.erb +19 -0
- data/app/components/avo/show/fields/code_field_component.rb +4 -0
- data/app/components/avo/show/fields/country_field_component.html.erb +7 -0
- data/app/components/avo/show/fields/country_field_component.rb +4 -0
- data/app/components/avo/show/fields/date_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/date_field_component.rb +4 -0
- data/app/components/avo/show/fields/date_time_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/date_time_field_component.rb +4 -0
- data/app/components/avo/show/fields/external_image_field_component.html.erb +5 -0
- data/app/components/avo/show/fields/external_image_field_component.rb +4 -0
- data/app/components/avo/show/fields/field_component.rb +11 -0
- data/app/components/avo/show/fields/file_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/file_field_component.rb +4 -0
- data/app/components/avo/show/fields/files_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/files_field_component.rb +4 -0
- data/app/components/avo/show/fields/gravatar_field_component.html.erb +7 -0
- data/app/components/avo/show/fields/gravatar_field_component.rb +4 -0
- data/app/components/avo/show/fields/has_many_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/has_many_field_component.rb +4 -0
- data/app/components/avo/show/fields/has_one_field_component.html.erb +19 -0
- data/app/components/avo/show/fields/has_one_field_component.rb +5 -0
- data/app/components/avo/show/fields/heading_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/heading_field_component.rb +4 -0
- data/app/components/avo/show/fields/id_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/id_field_component.rb +4 -0
- data/app/components/avo/show/fields/markdown_field_component.html.erb +10 -0
- data/app/components/avo/show/fields/markdown_field_component.rb +4 -0
- data/app/components/avo/show/fields/number_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/number_field_component.rb +4 -0
- data/app/components/avo/show/fields/select_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/select_field_component.rb +4 -0
- data/app/components/avo/show/fields/status_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/status_field_component.rb +4 -0
- data/app/components/avo/show/fields/text_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/text_field_component.rb +4 -0
- data/app/components/avo/show/fields/textarea_field_component.html.erb +3 -0
- data/app/components/avo/show/fields/textarea_field_component.rb +4 -0
- data/app/components/avo/show/fields/trix_field_component.html.erb +14 -0
- data/app/components/avo/show/fields/trix_field_component.rb +4 -0
- data/app/components/avo/views/resource_edit_component.html.erb +29 -0
- data/app/components/avo/views/resource_edit_component.rb +23 -0
- data/app/components/avo/views/resource_index_component.html.erb +62 -0
- data/app/components/avo/views/resource_index_component.rb +93 -0
- data/app/components/avo/views/resource_new_component.html.erb +25 -0
- data/app/components/avo/views/resource_new_component.rb +27 -0
- data/app/components/avo/views/resource_show_component.html.erb +64 -0
- data/app/components/avo/views/resource_show_component.rb +66 -0
- data/app/controllers/avo/actions_controller.rb +52 -22
- data/app/controllers/avo/application_controller.rb +183 -24
- data/app/controllers/avo/attachments_controller.rb +25 -0
- data/app/controllers/avo/base_controller.rb +218 -0
- data/app/controllers/avo/home_controller.rb +3 -0
- data/app/controllers/avo/relations_controller.rb +88 -19
- data/app/controllers/avo/resource_overview_controller.rb +3 -1
- data/app/controllers/avo/resources_controller.rb +2 -259
- data/app/controllers/avo/search_controller.rb +7 -6
- data/app/frontend/css/alerts.css +35 -0
- data/app/frontend/css/application.css +73 -0
- data/app/frontend/css/components/code.css +27 -0
- data/app/frontend/css/components/status.css +30 -0
- data/app/frontend/css/fonts.css +26 -0
- data/app/frontend/css/loader.css +134 -0
- data/app/frontend/css/pagination.css +67 -0
- data/app/frontend/css/tailwindcss/base.css +1 -0
- data/app/frontend/css/tailwindcss/components.css +1 -0
- data/app/frontend/css/tailwindcss/utilities.css +1 -0
- data/app/frontend/css/tooltips.css +105 -0
- data/app/frontend/css/typography.css +23 -0
- data/app/frontend/fonts/nunito-v16-latin-700.eot +0 -0
- data/app/frontend/fonts/nunito-v16-latin-700.svg +388 -0
- data/app/frontend/fonts/nunito-v16-latin-700.ttf +0 -0
- data/app/frontend/fonts/nunito-v16-latin-700.woff +0 -0
- data/app/frontend/fonts/nunito-v16-latin-700.woff2 +0 -0
- data/app/frontend/fonts/nunito-v16-latin-regular.eot +0 -0
- data/app/frontend/fonts/nunito-v16-latin-regular.svg +380 -0
- data/app/frontend/fonts/nunito-v16-latin-regular.ttf +0 -0
- data/app/frontend/fonts/nunito-v16-latin-regular.woff +0 -0
- data/app/frontend/fonts/nunito-v16-latin-regular.woff2 +0 -0
- data/app/frontend/images/logo.png +0 -0
- data/app/frontend/importmap.json.erb +5 -0
- data/app/frontend/js/controllers/action_controller.js +32 -0
- data/app/frontend/js/controllers/actions_picker_controller.js +44 -0
- data/app/frontend/js/controllers/alerts_controller.js +26 -0
- data/app/frontend/js/controllers/attachments_controller.js +9 -0
- data/app/frontend/js/controllers/boolean_filter_controller.js +21 -0
- data/app/frontend/js/controllers/fields/code_field_controller.js +35 -0
- data/app/frontend/js/controllers/fields/date_field_controller.js +53 -0
- data/app/frontend/js/controllers/fields/simple_mde_controller.js +26 -0
- data/app/frontend/js/controllers/filter_controller.js +52 -0
- data/app/frontend/js/controllers/hidden_input_controller.js +10 -0
- data/app/frontend/js/controllers/item_selector_controller.js +68 -0
- data/app/frontend/js/controllers/modal_controller.js +11 -0
- data/app/frontend/js/controllers/per_page_controller.js +9 -0
- data/app/frontend/js/controllers/select_filter_controller.js +15 -0
- data/app/frontend/js/controllers/tippy_controller.js +14 -0
- data/app/frontend/js/controllers/toggle_panel_controller.js +18 -0
- data/app/frontend/js/helpers/cast_boolean.js +2 -0
- data/app/frontend/js/toastr.js +9 -0
- data/app/frontend/packs/application.js +45 -0
- data/{public/avo-packs/media/svgs/arrow-circle-right-1ad1e15ec9a7aa54b67d126566a5aa2d.svg → app/frontend/svgs/arrow-circle-right.svg} +0 -0
- data/{public/avo-packs/media/svgs/arrow-left-0e8e808ff771a62a348d0232c8ccf539.svg → app/frontend/svgs/arrow-left.svg} +0 -0
- data/{public/avo-packs/media/svgs/avocado-bca389be7cf81162df902dfbd09b8adb.svg → app/frontend/svgs/avocado.svg} +0 -0
- data/app/frontend/svgs/badge-check-sm.svg +3 -0
- data/{public/avo-packs/media/svgs/check-circle-be9e4dcbd25467ae9a3d3c6c5c7a09fa.svg → app/frontend/svgs/check-circle.svg} +0 -0
- data/{public/avo-packs/media/svgs/chevron-down-01208b17a1f70a1bb8d82bba131da4f4.svg → app/frontend/svgs/chevron-down.svg} +0 -0
- data/{public/avo-packs/media/svgs/chevron-up-25ecf340dd76966d5ed63c85c025befc.svg → app/frontend/svgs/chevron-up.svg} +0 -0
- data/{public/avo-packs/media/svgs/code-69010c6ddb6ad50be8677f16468c51f8.svg → app/frontend/svgs/code.svg} +0 -0
- data/{public/avo-packs/media/svgs/color-swatch-60cf90fb6b5386e38f3b003f34e7ecbe.svg → app/frontend/svgs/color-swatch.svg} +0 -0
- data/app/frontend/svgs/document-text.svg +3 -0
- data/{public/avo-packs/media/svgs/download-c6ae3f12364a467c28cbf41dc90afbdd.svg → app/frontend/svgs/download.svg} +0 -0
- data/{public/avo-packs/media/svgs/edit-46c6dbef52ba6ddfc9afbc37186dfa2b.svg → app/frontend/svgs/edit.svg} +0 -0
- data/app/frontend/svgs/exclamation-circle-sm.svg +3 -0
- data/app/frontend/svgs/exclamation-sm.svg +3 -0
- data/{public/avo-packs/media/svgs/exclamation-8d1c0baa390a8df9bb52176011eb5892.svg → app/frontend/svgs/exclamation.svg} +0 -0
- data/{public/avo-packs/media/svgs/eye-cc6f85c70ebed6929712a5c7d51f102d.svg → app/frontend/svgs/eye.svg} +0 -0
- data/{public/avo-packs/media/svgs/filter-0007cddbc85cfe207f9876d4d184444a.svg → app/frontend/svgs/filter.svg} +0 -0
- data/{public/avo-packs/media/svgs/fire-782f08df79993311b6d907e12d9ebe9f.svg → app/frontend/svgs/fire.svg} +0 -0
- data/{public/avo-packs/media/svgs/game-board-6c59fe04181ac9954356c9f1f4d28053.svg → app/frontend/svgs/game-board.svg} +0 -0
- data/{public/avo-packs/media/svgs/globe-dfd9977c9d65814d2fc576904406dd08.svg → app/frontend/svgs/globe.svg} +0 -0
- data/app/frontend/svgs/information-circle-sm.svg +3 -0
- data/app/frontend/svgs/information-circle.svg +1 -0
- data/{public/avo-packs/media/svgs/library-7d391192a15da64fbb527908c9e035c7.svg → app/frontend/svgs/library.svg} +0 -0
- data/{public/avo-packs/media/svgs/photograph-9f37f1f5e6a48e68ce3b7d9cbe7b6fad.svg → app/frontend/svgs/photograph.svg} +0 -0
- data/app/frontend/svgs/play.svg +1 -0
- data/{public/avo-packs/media/svgs/plus-circle-b379b2a2aa803511ae5945b6fd323204.svg → app/frontend/svgs/plus-circle.svg} +0 -0
- data/{public/avo-packs/media/svgs/plus-530f0af27b9f1a4552454233c2f9a641.svg → app/frontend/svgs/plus.svg} +0 -0
- data/{public/avo-packs/media/svgs/question-mark-circle-3ece1d61091827910cdd097db711062b.svg → app/frontend/svgs/question-mark-circle.svg} +0 -0
- data/{public/avo-packs/media/svgs/save-e54acd7ac9646053e36382776f822756.svg → app/frontend/svgs/save.svg} +0 -0
- data/{public/avo-packs/media/svgs/selector-b43b3957d7cc121d06be14312613c218.svg → app/frontend/svgs/selector.svg} +0 -0
- data/{public/avo-packs/media/svgs/sort-ascending-f5bc0761702809cab20b0ea3065cb88a.svg → app/frontend/svgs/sort-ascending.svg} +0 -0
- data/{public/avo-packs/media/svgs/sort-descending-1c8ddc56c72be6781e59d808f9d06203.svg → app/frontend/svgs/sort-descending.svg} +0 -0
- data/{public/avo-packs/media/svgs/switch-horizontal-d23337f0fb533a86d14b746d25ad48ae.svg → app/frontend/svgs/switch-horizontal.svg} +0 -0
- data/{public/avo-packs/media/svgs/thumbs-down-44f83eacbf5b8fe0f2f085da75866ce0.svg → app/frontend/svgs/thumbs-down.svg} +0 -0
- data/{public/avo-packs/media/svgs/thumbs-up-b866900017db179b50d6b19a1424ed25.svg → app/frontend/svgs/thumbs-up.svg} +0 -0
- data/app/frontend/svgs/times.svg +3 -0
- data/app/frontend/svgs/trash-sm.svg +3 -0
- data/{public/avo-packs/media/svgs/trash-a61412a066e358bcc24494a5080b7255.svg → app/frontend/svgs/trash.svg} +0 -0
- data/{public/avo-packs/media/svgs/view-grid-add-d0ee477a044e5d46c0c62af66cb6de77.svg → app/frontend/svgs/view-grid-add.svg} +0 -0
- data/{public/avo-packs/media/svgs/view-grid-393669034db69f59497616d5416ae411.svg → app/frontend/svgs/view-grid.svg} +0 -0
- data/{public/avo-packs/media/svgs/view-list-8a7a159ca5d892f72cf8c6744a2074e2.svg → app/frontend/svgs/view-list.svg} +0 -0
- data/{public/avo-packs/media/svgs/x-circle-c540f9ccfe937ad9b4f662e0b65e47e2.svg → app/frontend/svgs/x-circle.svg} +0 -0
- data/app/helpers/avo/actions_helper.rb +4 -0
- data/app/helpers/avo/application_helper.rb +156 -3
- data/app/helpers/avo/attachments_helper.rb +4 -0
- data/app/helpers/avo/resources_helper.rb +101 -0
- data/app/mailers/avo/application_mailer.rb +1 -1
- data/app/views/avo/actions/show.html.erb +71 -0
- data/app/views/avo/attachments/show.html.erb +7 -0
- data/app/views/avo/base/_actions.html.erb +36 -0
- data/app/views/avo/base/_boolean_filter.html.erb +33 -0
- data/app/views/avo/base/_filters.html.erb +37 -0
- data/app/views/avo/base/_select_filter.html.erb +20 -0
- data/app/views/avo/base/edit.html.erb +1 -0
- data/app/views/avo/base/index.html.erb +15 -0
- data/app/views/avo/base/new.html.erb +1 -0
- data/app/views/avo/base/show.html.erb +3 -0
- data/app/views/avo/home/_actions.html.erb +16 -0
- data/app/views/avo/home/_docs.html.erb +9 -0
- data/app/views/avo/home/_filters.html.erb +16 -0
- data/app/views/avo/home/_resources.html.erb +29 -0
- data/app/views/avo/home/index.html.erb +54 -3
- data/app/views/avo/partials/_a_button.html.erb +7 -0
- data/app/views/avo/partials/_a_link.html.erb +7 -0
- data/app/views/avo/partials/_alert.html.erb +1 -0
- data/app/views/avo/partials/_alerts.html.erb +3 -0
- data/app/views/avo/partials/_empty_state.html.erb +17 -0
- data/app/views/{partials → avo/partials}/_footer.html.erb +0 -0
- data/app/views/{partials → avo/partials}/_header.html.erb +0 -0
- data/app/views/avo/partials/_javascript.html.erb +3 -0
- data/app/views/{partials → avo/partials}/_logo.html.erb +0 -0
- data/app/views/avo/partials/_paginator.html.erb +30 -0
- data/app/views/avo/partials/_sortable_component.html.erb +14 -0
- data/app/views/avo/partials/_table_header.html.erb +50 -0
- data/app/views/avo/partials/_view_toggle_button.html.erb +17 -0
- data/app/views/avo/relations/new.html.erb +29 -0
- data/app/views/avo/sidebar/_license_warning.html.erb +12 -0
- data/app/views/avo/sidebar/_license_warnings.html.erb +6 -0
- data/app/views/avo/sidebar/_sidebar.html.erb +23 -0
- data/app/views/kaminari/_first_page.html.erb +3 -0
- data/app/views/kaminari/_last_page.html.erb +3 -0
- data/app/views/kaminari/_next_page.html.erb +9 -0
- data/app/views/kaminari/_page.html.erb +12 -0
- data/app/views/kaminari/_prev_page.html.erb +9 -0
- data/app/views/layouts/avo/_filter_wrapper.html.erb +8 -0
- data/app/views/layouts/avo/application.html.erb +28 -40
- data/app/views/layouts/avo/application_vue.html.erb +61 -0
- data/avo.gemspec +5 -2
- data/bin/helpers.rb +34 -0
- data/bin/init +35 -0
- data/bin/rspec +8 -0
- data/bin/spring +17 -0
- data/bin/test +21 -0
- data/bin/webpack +9 -10
- data/bin/webpack-dev-server +9 -10
- data/config/cable.yml +11 -0
- data/config/initializers/inline_svg.rb +33 -0
- data/config/initializers/pagy.rb +1 -0
- data/config/routes.rb +22 -18
- data/config/spring.rb +7 -0
- data/config/webpack/environment.js +14 -10
- data/config/webpacker.yml +5 -4
- data/config/webpacker_packed.yml +86 -0
- data/db/factories.rb +10 -3
- data/db/migrate/20210305082639_add_url_to_teams.rb +5 -0
- data/lib/avo.rb +3 -0
- data/lib/avo/app/action.rb +51 -45
- data/lib/avo/app/actions_loader.rb +11 -0
- data/lib/avo/app/app.rb +57 -45
- data/lib/avo/app/fields/badge_field.rb +3 -30
- data/lib/avo/app/fields/belongs_to.rb +38 -50
- data/lib/avo/app/fields/boolean_field.rb +8 -10
- data/lib/avo/app/fields/boolean_group_field.rb +13 -11
- data/lib/avo/app/fields/code_field.rb +11 -9
- data/lib/avo/app/fields/country_field.rb +12 -21
- data/lib/avo/app/fields/currency_field.rb +1 -2
- data/lib/avo/app/fields/date_field.rb +16 -11
- data/lib/avo/app/fields/date_time_field.rb +38 -0
- data/lib/avo/app/fields/external_image_field.rb +23 -0
- data/lib/avo/app/fields/field.rb +76 -84
- data/lib/avo/app/fields/field_extensions/visible_in_different_views.rb +5 -5
- data/lib/avo/app/fields/file_field.rb +8 -14
- data/lib/avo/app/fields/files_field.rb +10 -18
- data/lib/avo/app/fields/gravatar_field.rb +18 -13
- data/lib/avo/app/fields/has_and_belongs_to_many.rb +13 -24
- data/lib/avo/app/fields/has_many.rb +13 -26
- data/lib/avo/app/fields/has_one.rb +23 -30
- data/lib/avo/app/fields/heading_field.rb +2 -8
- data/lib/avo/app/fields/hidden_field.rb +2 -2
- data/lib/avo/app/fields/id_field.rb +2 -8
- data/lib/avo/app/fields/key_value_field.rb +5 -2
- data/lib/avo/app/fields/markdown_field.rb +1 -1
- data/lib/avo/app/fields/number_field.rb +5 -12
- data/lib/avo/app/fields/password_field.rb +1 -1
- data/lib/avo/app/fields/select_field.rb +33 -10
- data/lib/avo/app/fields/status_field.rb +9 -7
- data/lib/avo/app/fields/text_field.rb +1 -8
- data/lib/avo/app/fields/textarea_field.rb +2 -9
- data/lib/avo/app/fields/trix_field.rb +3 -7
- data/lib/avo/app/fields_loader.rb +29 -0
- data/lib/avo/app/licensing/hq.rb +3 -3
- data/lib/avo/app/licensing/license.rb +1 -1
- data/lib/avo/app/resource.rb +184 -126
- data/lib/avo/app/services/authorization_service.rb +68 -6
- data/lib/avo/app/services/panel_service.rb +25 -0
- data/lib/avo/configuration.rb +7 -1
- data/lib/avo/engine.rb +4 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/controller_generator.rb +13 -0
- data/lib/generators/avo/resource_generator.rb +16 -2
- data/lib/generators/avo/templates/initializer/avo.rb +3 -0
- data/lib/generators/avo/templates/locales/avo.en.yml +5 -1
- data/lib/generators/avo/templates/resource/%plural_name%_controller.tt +2 -0
- data/lib/generators/avo/templates/resource/%singular_name%.tt +20 -0
- data/public/avo-packs/css/application-3598cfbb.css +6 -0
- data/public/avo-packs/css/application-3598cfbb.css.br +0 -0
- data/public/avo-packs/css/application-3598cfbb.css.gz +0 -0
- data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js +2 -0
- data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.br +0 -0
- data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.gz +0 -0
- data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map +1 -0
- data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map.br +0 -0
- data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map.gz +0 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js +26 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.LICENSE.txt +77 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.br +0 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.gz +0 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map +1 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map.br +0 -0
- data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +17 -46
- data/public/avo-packs/manifest.json.br +0 -0
- data/public/avo-packs/manifest.json.gz +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.br +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.gz +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg +388 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.br +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.gz +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-412073df419ad5f6f8f2ea76eb4aced9.woff2 +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-7c472b19cb573f537bad8ef62ca917ac.woff +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-700-df7e79af617f98cd3b95d320e8b2a1af.eot +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg +380 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.br +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.gz +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-2fae1e2418251b68fe5d0505ab93dd5c.eot +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-bcf84d6cb8a0ac214c8c14ba9af834f3.woff2 +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-cb632c9fe211ba2c2bf1564c9a9295cc.woff +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.br +0 -0
- data/public/avo-packs/media/fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.gz +0 -0
- metadata +421 -134
- data/app/controllers/avo/filters_controller.rb +0 -19
- data/app/views/avo/home/router.html.erb +0 -8
- data/app/views/layouts/avo/_javascript.html.erb +0 -8
- data/app/views/layouts/avo/_translations.html.erb +0 -5
- data/config/webpack/loaders/vue-post-css.js +0 -20
- data/config/webpack/loaders/vue-svg.js +0 -21
- data/config/webpack/loaders/vue.js +0 -6
- data/lib/avo/app/fields/datetime_field.rb +0 -34
- data/lib/avo/app/resource_actions.rb +0 -18
- data/lib/avo/app/resource_fields.rb +0 -26
- data/lib/avo/app/resource_filters.rb +0 -18
- data/lib/generators/avo/templates/resource.rb +0 -14
- data/public/avo-packs/css/application-c9595d99.css +0 -3
- data/public/avo-packs/css/application-c9595d99.css.br +0 -0
- data/public/avo-packs/css/application-c9595d99.css.gz +0 -0
- data/public/avo-packs/js/application-54cdc48985a045c704ef.js +0 -3
- data/public/avo-packs/js/application-54cdc48985a045c704ef.js.LICENSE.txt +0 -767
- data/public/avo-packs/js/application-54cdc48985a045c704ef.js.br +0 -0
- data/public/avo-packs/js/application-54cdc48985a045c704ef.js.gz +0 -0
- data/public/avo-packs/js/application-54cdc48985a045c704ef.js.map +0 -1
- data/public/avo-packs/js/application-54cdc48985a045c704ef.js.map.br +0 -0
- data/public/avo-packs/js/application-54cdc48985a045c704ef.js.map.gz +0 -0
- data/public/avo-packs/media/font/fontello-068ca2b3.ttf +0 -0
- data/public/avo-packs/media/font/fontello-068ca2b3.ttf.br +0 -0
- data/public/avo-packs/media/font/fontello-068ca2b3.ttf.gz +0 -0
- data/public/avo-packs/media/font/fontello-8d4a4e6f.woff2 +0 -0
- data/public/avo-packs/media/font/fontello-9354499c.svg +0 -72
- data/public/avo-packs/media/font/fontello-9354499c.svg.br +0 -0
- data/public/avo-packs/media/font/fontello-9354499c.svg.gz +0 -0
- data/public/avo-packs/media/font/fontello-a782baa8.woff +0 -0
- data/public/avo-packs/media/font/fontello-e73a0647.eot +0 -0
- data/public/avo-packs/media/font/fontello-e73a0647.eot.br +0 -0
- data/public/avo-packs/media/font/fontello-e73a0647.eot.gz +0 -0
- data/public/avo-packs/media/svgs/arrow-circle-right-1ad1e15ec9a7aa54b67d126566a5aa2d.svg.br +0 -0
- data/public/avo-packs/media/svgs/arrow-circle-right-1ad1e15ec9a7aa54b67d126566a5aa2d.svg.gz +0 -0
- data/public/avo-packs/media/svgs/arrow-left-0e8e808ff771a62a348d0232c8ccf539.svg.br +0 -0
- data/public/avo-packs/media/svgs/avocado-bca389be7cf81162df902dfbd09b8adb.svg.br +0 -0
- data/public/avo-packs/media/svgs/avocado-bca389be7cf81162df902dfbd09b8adb.svg.gz +0 -0
- data/public/avo-packs/media/svgs/check-circle-be9e4dcbd25467ae9a3d3c6c5c7a09fa.svg.br +0 -0
- data/public/avo-packs/media/svgs/chevron-down-01208b17a1f70a1bb8d82bba131da4f4.svg.br +0 -0
- data/public/avo-packs/media/svgs/chevron-down-01208b17a1f70a1bb8d82bba131da4f4.svg.gz +0 -0
- data/public/avo-packs/media/svgs/chevron-up-25ecf340dd76966d5ed63c85c025befc.svg.br +0 -0
- data/public/avo-packs/media/svgs/chevron-up-25ecf340dd76966d5ed63c85c025befc.svg.gz +0 -0
- data/public/avo-packs/media/svgs/code-69010c6ddb6ad50be8677f16468c51f8.svg.br +0 -0
- data/public/avo-packs/media/svgs/color-swatch-60cf90fb6b5386e38f3b003f34e7ecbe.svg.br +0 -0
- data/public/avo-packs/media/svgs/color-swatch-60cf90fb6b5386e38f3b003f34e7ecbe.svg.gz +0 -0
- data/public/avo-packs/media/svgs/download-c6ae3f12364a467c28cbf41dc90afbdd.svg.br +0 -0
- data/public/avo-packs/media/svgs/download-c6ae3f12364a467c28cbf41dc90afbdd.svg.gz +0 -0
- data/public/avo-packs/media/svgs/edit-46c6dbef52ba6ddfc9afbc37186dfa2b.svg.br +0 -0
- data/public/avo-packs/media/svgs/edit-46c6dbef52ba6ddfc9afbc37186dfa2b.svg.gz +0 -0
- data/public/avo-packs/media/svgs/exclamation-8d1c0baa390a8df9bb52176011eb5892.svg.br +0 -0
- data/public/avo-packs/media/svgs/exclamation-8d1c0baa390a8df9bb52176011eb5892.svg.gz +0 -0
- data/public/avo-packs/media/svgs/eye-cc6f85c70ebed6929712a5c7d51f102d.svg.br +0 -1
- data/public/avo-packs/media/svgs/eye-cc6f85c70ebed6929712a5c7d51f102d.svg.gz +0 -0
- data/public/avo-packs/media/svgs/filter-0007cddbc85cfe207f9876d4d184444a.svg.br +0 -0
- data/public/avo-packs/media/svgs/filter-0007cddbc85cfe207f9876d4d184444a.svg.gz +0 -0
- data/public/avo-packs/media/svgs/fire-782f08df79993311b6d907e12d9ebe9f.svg.br +0 -0
- data/public/avo-packs/media/svgs/fire-782f08df79993311b6d907e12d9ebe9f.svg.gz +0 -0
- data/public/avo-packs/media/svgs/game-board-6c59fe04181ac9954356c9f1f4d28053.svg.br +0 -0
- data/public/avo-packs/media/svgs/game-board-6c59fe04181ac9954356c9f1f4d28053.svg.gz +0 -0
- data/public/avo-packs/media/svgs/globe-dfd9977c9d65814d2fc576904406dd08.svg.br +0 -0
- data/public/avo-packs/media/svgs/globe-dfd9977c9d65814d2fc576904406dd08.svg.gz +0 -0
- data/public/avo-packs/media/svgs/library-7d391192a15da64fbb527908c9e035c7.svg.br +0 -0
- data/public/avo-packs/media/svgs/photograph-9f37f1f5e6a48e68ce3b7d9cbe7b6fad.svg.br +0 -2
- data/public/avo-packs/media/svgs/photograph-9f37f1f5e6a48e68ce3b7d9cbe7b6fad.svg.gz +0 -0
- data/public/avo-packs/media/svgs/plus-530f0af27b9f1a4552454233c2f9a641.svg.br +0 -0
- data/public/avo-packs/media/svgs/plus-circle-b379b2a2aa803511ae5945b6fd323204.svg.br +0 -0
- data/public/avo-packs/media/svgs/question-mark-circle-3ece1d61091827910cdd097db711062b.svg.br +0 -0
- data/public/avo-packs/media/svgs/question-mark-circle-3ece1d61091827910cdd097db711062b.svg.gz +0 -0
- data/public/avo-packs/media/svgs/save-e54acd7ac9646053e36382776f822756.svg.br +0 -0
- data/public/avo-packs/media/svgs/save-e54acd7ac9646053e36382776f822756.svg.gz +0 -0
- data/public/avo-packs/media/svgs/selector-b43b3957d7cc121d06be14312613c218.svg.br +0 -0
- data/public/avo-packs/media/svgs/sort-ascending-f5bc0761702809cab20b0ea3065cb88a.svg.br +0 -0
- data/public/avo-packs/media/svgs/sort-descending-1c8ddc56c72be6781e59d808f9d06203.svg.br +0 -0
- data/public/avo-packs/media/svgs/switch-horizontal-d23337f0fb533a86d14b746d25ad48ae.svg.br +0 -2
- data/public/avo-packs/media/svgs/switch-horizontal-d23337f0fb533a86d14b746d25ad48ae.svg.gz +0 -0
- data/public/avo-packs/media/svgs/thumbs-down-44f83eacbf5b8fe0f2f085da75866ce0.svg.br +0 -0
- data/public/avo-packs/media/svgs/thumbs-down-44f83eacbf5b8fe0f2f085da75866ce0.svg.gz +0 -0
- data/public/avo-packs/media/svgs/thumbs-up-b866900017db179b50d6b19a1424ed25.svg.br +0 -4
- data/public/avo-packs/media/svgs/thumbs-up-b866900017db179b50d6b19a1424ed25.svg.gz +0 -0
- data/public/avo-packs/media/svgs/times-539256e95a00360c3bbc6160c6b695cd.svg +0 -1
- data/public/avo-packs/media/svgs/times-539256e95a00360c3bbc6160c6b695cd.svg.br +0 -0
- data/public/avo-packs/media/svgs/times-539256e95a00360c3bbc6160c6b695cd.svg.gz +0 -0
- data/public/avo-packs/media/svgs/trash-a61412a066e358bcc24494a5080b7255.svg.br +0 -0
- data/public/avo-packs/media/svgs/trash-a61412a066e358bcc24494a5080b7255.svg.gz +0 -0
- data/public/avo-packs/media/svgs/view-grid-393669034db69f59497616d5416ae411.svg.br +0 -1
- data/public/avo-packs/media/svgs/view-grid-393669034db69f59497616d5416ae411.svg.gz +0 -0
- data/public/avo-packs/media/svgs/view-grid-add-d0ee477a044e5d46c0c62af66cb6de77.svg.br +0 -0
- data/public/avo-packs/media/svgs/view-grid-add-d0ee477a044e5d46c0c62af66cb6de77.svg.gz +0 -0
- data/public/avo-packs/media/svgs/view-list-8a7a159ca5d892f72cf8c6744a2074e2.svg.br +0 -3
- data/public/avo-packs/media/svgs/view-list-8a7a159ca5d892f72cf8c6744a2074e2.svg.gz +0 -0
- data/public/avo-packs/media/svgs/x-circle-c540f9ccfe937ad9b4f662e0b65e47e2.svg.br +0 -0
- data/public/avo-packs/media/svgs/x-circle-c540f9ccfe937ad9b4f662e0b65e47e2.svg.gz +0 -0
data/lib/avo/app/action.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require_relative 'fields_loader'
|
2
|
+
|
3
|
+
|
1
4
|
module Avo
|
2
5
|
module Actions
|
3
6
|
class Action
|
@@ -16,25 +19,16 @@ module Avo
|
|
16
19
|
# }
|
17
20
|
attr_accessor :response
|
18
21
|
attr_accessor :no_confirmation
|
22
|
+
attr_accessor :model
|
23
|
+
attr_accessor :resource
|
24
|
+
attr_accessor :user
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
class << self
|
23
|
-
@@fields = {}
|
24
|
-
|
25
|
-
def fields(&block)
|
26
|
-
@@fields[self] ||= []
|
27
|
-
yield
|
28
|
-
end
|
26
|
+
attr_accessor :field_loader
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
28
|
+
alias :field :field_loader
|
29
|
+
alias :f :field
|
33
30
|
|
34
|
-
|
35
|
-
@@fields[action].push field
|
36
|
-
end
|
37
|
-
end
|
31
|
+
@@default = nil
|
38
32
|
|
39
33
|
def initialize
|
40
34
|
@name ||= name
|
@@ -44,13 +38,33 @@ module Avo
|
|
44
38
|
@confirm_text = I18n.t('avo.run')
|
45
39
|
@cancel_text = I18n.t('avo.cancel')
|
46
40
|
@response ||= {}
|
47
|
-
@response[:message_type] ||= :
|
41
|
+
@response[:message_type] ||= :notice
|
48
42
|
@response[:message] ||= I18n.t('avo.action_ran_successfully')
|
49
43
|
@theme ||= 'success'
|
50
44
|
@no_confirmation ||= false
|
51
45
|
end
|
52
46
|
|
53
|
-
def
|
47
|
+
def boot_fields(request)
|
48
|
+
@field_loader = Avo::FieldsLoader.new
|
49
|
+
fields request if self.respond_to? :fields
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_fields(view_type: :table)
|
53
|
+
get_field_definitions.map do |field|
|
54
|
+
field.hydrate(action: self, model: @model)
|
55
|
+
end
|
56
|
+
.select do |field|
|
57
|
+
field.can_see.present? ? field.can_see.call : true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_field_definitions
|
62
|
+
@field_loader.bag.map do |field|
|
63
|
+
field.hydrate(action: self)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def render_response
|
54
68
|
fields = get_fields.map { |field| field.fetch_for_action(model, resource) }
|
55
69
|
|
56
70
|
{
|
@@ -67,6 +81,14 @@ module Avo
|
|
67
81
|
}
|
68
82
|
end
|
69
83
|
|
84
|
+
def hydrate(model: nil, resource: nil, user: nil)
|
85
|
+
@model = model if model.present?
|
86
|
+
@resource = resource if resource.present?
|
87
|
+
@user = user if user.present?
|
88
|
+
|
89
|
+
self
|
90
|
+
end
|
91
|
+
|
70
92
|
def handle_action(request, models, raw_fields)
|
71
93
|
avo_fields = get_fields.map { |field| [field.id, field] }.to_h
|
72
94
|
|
@@ -85,7 +107,7 @@ module Avo
|
|
85
107
|
self
|
86
108
|
end
|
87
109
|
|
88
|
-
def
|
110
|
+
def param_id
|
89
111
|
self.class.name.underscore.gsub '/', '_'
|
90
112
|
end
|
91
113
|
|
@@ -94,29 +116,26 @@ module Avo
|
|
94
116
|
end
|
95
117
|
|
96
118
|
def succeed(text)
|
97
|
-
self.response[:message_type] = :
|
119
|
+
self.response[:message_type] = :notice
|
98
120
|
self.response[:message] = text
|
99
121
|
|
100
122
|
self
|
101
123
|
end
|
102
124
|
|
103
125
|
def fail(text)
|
104
|
-
self.response[:message_type] = :
|
126
|
+
self.response[:message_type] = :alert
|
105
127
|
self.response[:message] = text
|
106
128
|
|
107
129
|
self
|
108
130
|
end
|
109
131
|
|
110
|
-
def
|
132
|
+
def redirect_to(path = nil, &block)
|
111
133
|
self.response[:type] = :redirect
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
def http_redirect(path)
|
118
|
-
self.response[:type] = :http_redirect
|
119
|
-
self.response[:path] = path
|
134
|
+
if block.present?
|
135
|
+
self.response[:path] = block
|
136
|
+
else
|
137
|
+
self.response[:path] = path
|
138
|
+
end
|
120
139
|
|
121
140
|
self
|
122
141
|
end
|
@@ -127,19 +146,6 @@ module Avo
|
|
127
146
|
self
|
128
147
|
end
|
129
148
|
|
130
|
-
def reload_resources
|
131
|
-
self.response[:type] = :reload_resources
|
132
|
-
|
133
|
-
self
|
134
|
-
end
|
135
|
-
|
136
|
-
def open_in_new_tab(path)
|
137
|
-
self.response[:type] = :open_in_new_tab
|
138
|
-
self.response[:path] = path
|
139
|
-
|
140
|
-
self
|
141
|
-
end
|
142
|
-
|
143
149
|
def download(path, filename)
|
144
150
|
self.response[:type] = :download
|
145
151
|
self.response[:path] = path
|
@@ -148,8 +154,8 @@ module Avo
|
|
148
154
|
self
|
149
155
|
end
|
150
156
|
|
151
|
-
def
|
152
|
-
self.
|
157
|
+
def self.param_id
|
158
|
+
self.name.underscore.gsub '/', '_'
|
153
159
|
end
|
154
160
|
end
|
155
161
|
end
|
data/lib/avo/app/app.rb
CHANGED
@@ -11,13 +11,14 @@ module Avo
|
|
11
11
|
@@app = {
|
12
12
|
root_path: '',
|
13
13
|
resources: [],
|
14
|
-
field_names: {},
|
15
14
|
cache_store: nil
|
16
15
|
}
|
17
16
|
@@license = nil
|
17
|
+
@@fields = []
|
18
18
|
|
19
19
|
class << self
|
20
20
|
def boot
|
21
|
+
# init_controllers
|
21
22
|
@@app[:root_path] = Pathname.new(File.join(__dir__, '..', '..'))
|
22
23
|
init_fields
|
23
24
|
I18n.locale = Avo.configuration.language_code
|
@@ -30,7 +31,10 @@ module Avo
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def init(current_request = nil)
|
33
|
-
|
34
|
+
# Set the current host for ActiveStorage
|
35
|
+
ActiveStorage::Current.host = current_request.base_url
|
36
|
+
|
37
|
+
init_resources current_request
|
34
38
|
@@license = LicenseManager.new(HQ.new(current_request).response).license
|
35
39
|
end
|
36
40
|
|
@@ -38,6 +42,10 @@ module Avo
|
|
38
42
|
@@app
|
39
43
|
end
|
40
44
|
|
45
|
+
def fields
|
46
|
+
@@fields
|
47
|
+
end
|
48
|
+
|
41
49
|
def license
|
42
50
|
@@license
|
43
51
|
end
|
@@ -46,12 +54,13 @@ module Avo
|
|
46
54
|
@@app[:cache_store]
|
47
55
|
end
|
48
56
|
|
49
|
-
# This method will
|
57
|
+
# This method will find all fields available in the Avo::Fields namespace and add them to a @@fields array
|
58
|
+
# so later we can instantiate them on our resources.
|
50
59
|
#
|
51
60
|
# If the field has their `def_method` set up it will follow that convention, if not it will snake_case the name:
|
52
61
|
#
|
53
62
|
# Avo::Fields::TextField -> text
|
54
|
-
# Avo::Fields::
|
63
|
+
# Avo::Fields::DateTimeField -> date_time
|
55
64
|
def init_fields
|
56
65
|
Avo::Fields.constants.each do |class_name|
|
57
66
|
next if class_name.to_s == 'Field'
|
@@ -61,8 +70,6 @@ module Avo
|
|
61
70
|
if class_name.to_s.end_with? 'Field'
|
62
71
|
field_class = "Avo::Fields::#{class_name.to_s}".safe_constantize
|
63
72
|
method_name = field_class.get_field_name
|
64
|
-
|
65
|
-
next if Avo::Resources::Resource.method_defined? method_name.to_sym
|
66
73
|
else
|
67
74
|
# Try one level deeper for custom fields
|
68
75
|
namespace = class_name
|
@@ -87,82 +94,87 @@ module Avo
|
|
87
94
|
end
|
88
95
|
|
89
96
|
def load_field(method_name, klass)
|
90
|
-
@@
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
klass_entity.define_singleton_method method_name.to_sym do |*args, &block|
|
95
|
-
if block.present?
|
96
|
-
field_class = klass::new(args[0], **args[1] || {}, &block)
|
97
|
-
else
|
98
|
-
field_class = klass::new(args[0], **args[1] || {})
|
99
|
-
end
|
100
|
-
|
101
|
-
klass_entity.add_field(self, field_class)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def get_field_names
|
107
|
-
@@app[:field_names]
|
97
|
+
@@fields.push(
|
98
|
+
name: method_name,
|
99
|
+
class: klass,
|
100
|
+
)
|
108
101
|
end
|
109
102
|
|
110
|
-
def init_resources
|
111
|
-
@@app[:resources] = Avo::Resources.constants
|
112
|
-
|
113
|
-
|
103
|
+
def init_resources(request)
|
104
|
+
@@app[:resources] = Avo::Resources.constants
|
105
|
+
.select do |r|
|
106
|
+
r != :Resource
|
107
|
+
end
|
108
|
+
.map do |c|
|
109
|
+
if Avo::Resources.const_get(c).is_a? Class
|
110
|
+
"Avo::Resources::#{c}".safe_constantize.new request
|
111
|
+
end
|
114
112
|
end
|
115
|
-
end
|
116
113
|
end
|
117
114
|
|
118
115
|
def get_resources
|
119
116
|
@@app[:resources]
|
120
117
|
end
|
121
118
|
|
119
|
+
# Returns the Avo resource by camelized name
|
120
|
+
#
|
121
|
+
# get_resource_by_name('User') => Avo::Resources::User
|
122
122
|
def get_resource(resource)
|
123
123
|
@@app[:resources].find do |available_resource|
|
124
124
|
"Avo::Resources::#{resource}".safe_constantize == available_resource.class
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
#
|
128
|
+
# Returns the Avo resource by singular snake_cased name
|
129
129
|
#
|
130
130
|
# get_resource_by_name('user') => Avo::Resources::User
|
131
131
|
def get_resource_by_name(name)
|
132
132
|
self.get_resource name.singularize.camelize
|
133
133
|
end
|
134
134
|
|
135
|
-
#
|
135
|
+
# Returns the Avo resource by singular snake_cased name
|
136
136
|
#
|
137
137
|
# get_resource_by_name('User') => Avo::Resources::User
|
138
138
|
# get_resource_by_name(User) => Avo::Resources::User
|
139
139
|
def get_resource_by_model_name(name)
|
140
140
|
get_resources.find do |resource|
|
141
|
-
resource.
|
141
|
+
resource.model_class.model_name.name == name.to_s
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
#
|
145
|
+
# Returns the Rails model class by singular snake_cased name
|
146
146
|
#
|
147
147
|
# get_model_class_by_name('user') => User
|
148
148
|
def get_model_class_by_name(name)
|
149
149
|
name.to_s.camelize.singularize
|
150
150
|
end
|
151
151
|
|
152
|
-
def get_available_resources(user)
|
152
|
+
def get_available_resources(user = nil)
|
153
153
|
App.get_resources
|
154
|
-
.select
|
155
|
-
|
156
|
-
{
|
157
|
-
label: resource.plural_name.humanize(keep_id_suffix: true),
|
158
|
-
resource_name: resource.url.pluralize,
|
159
|
-
translation_key: resource.translation_key
|
160
|
-
}
|
154
|
+
.select do |resource|
|
155
|
+
AuthorizationService::authorize user, resource.model, Avo.configuration.authorization_methods.stringify_keys['index'], raise_exception: false
|
161
156
|
end
|
162
|
-
.
|
163
|
-
|
164
|
-
|
165
|
-
|
157
|
+
.sort_by { |r| r.name }
|
158
|
+
end
|
159
|
+
|
160
|
+
def get_navigation_items(user = nil)
|
161
|
+
get_available_resources(user).select do |resource|
|
162
|
+
resource.model_class.present?
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def draw_routes
|
167
|
+
Proc.new do
|
168
|
+
Avo::Resources.constants
|
169
|
+
.select do |r|
|
170
|
+
r != :Resource
|
171
|
+
end
|
172
|
+
.map do |r|
|
173
|
+
if Avo::Resources.const_get(r).is_a? Class
|
174
|
+
resources r.to_s.underscore.downcase.pluralize.to_sym
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
166
178
|
end
|
167
179
|
end
|
168
180
|
end
|
@@ -3,42 +3,15 @@ module Avo
|
|
3
3
|
class BadgeField < Field
|
4
4
|
def initialize(name, **args, &block)
|
5
5
|
@defaults = {
|
6
|
-
|
7
|
-
component: 'badge-field',
|
6
|
+
partial_name: 'badge-field',
|
8
7
|
}
|
9
8
|
|
10
9
|
super(name, **args, &block)
|
11
10
|
|
12
|
-
hide_on [:edit, :
|
11
|
+
hide_on [:edit, :new]
|
13
12
|
|
14
13
|
default_options = { info: :info, success: :success, danger: :danger, warning: :warning }
|
15
|
-
@options = args[:options].present? ? default_options.merge(args[:options]) : default_options
|
16
|
-
end
|
17
|
-
|
18
|
-
def hydrate_field(fields, model, resource, view)
|
19
|
-
if fields[:computed_value].present?
|
20
|
-
return {
|
21
|
-
value: fields[:computed_value]
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
value = {}
|
26
|
-
|
27
|
-
@options.invert.each do |values, type|
|
28
|
-
db_value = model[id] || ''
|
29
|
-
|
30
|
-
if [values].flatten.map { |value| value.to_s }.include? db_value
|
31
|
-
value = {
|
32
|
-
label: db_value,
|
33
|
-
type: type,
|
34
|
-
}
|
35
|
-
next
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
{
|
40
|
-
value: value
|
41
|
-
}
|
14
|
+
@meta[:options] = args[:options].present? ? default_options.merge(args[:options]) : default_options
|
42
15
|
end
|
43
16
|
end
|
44
17
|
end
|
@@ -1,77 +1,65 @@
|
|
1
1
|
module Avo
|
2
2
|
module Fields
|
3
3
|
class BelongsToField < Field
|
4
|
-
attr_accessor :searchable
|
5
|
-
attr_accessor :relation_method
|
6
|
-
|
7
4
|
def initialize(name, **args, &block)
|
8
5
|
@defaults = {
|
9
|
-
|
6
|
+
partial_name: 'belongs-to-field',
|
10
7
|
placeholder: I18n.t('avo.choose_an_option')
|
11
8
|
}
|
12
9
|
|
13
|
-
@searchable = args[:searchable] == true ? true : false
|
14
|
-
@relation_method = name.to_s.parameterize.underscore
|
15
|
-
|
16
10
|
super(name, **args, &block)
|
17
|
-
end
|
18
|
-
|
19
|
-
def hydrate_field(fields, model, resource, view)
|
20
|
-
return fields if model_or_class(model) == 'class'
|
21
11
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
target_resource = get_target_resource model
|
27
|
-
|
28
|
-
relation_model = model.public_send(@relation_method)
|
12
|
+
@meta[:searchable] = args[:searchable] == true ? true : false
|
13
|
+
@meta[:relation_method] = name.to_s.parameterize.underscore
|
14
|
+
end
|
29
15
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
16
|
+
def options
|
17
|
+
target_resource.model_class.all.map do |model|
|
18
|
+
{
|
19
|
+
value: model.id,
|
20
|
+
label: model.send(target_resource.title)
|
21
|
+
}
|
35
22
|
end
|
23
|
+
end
|
36
24
|
|
37
|
-
|
38
|
-
|
25
|
+
def database_value
|
26
|
+
target_resource.id
|
27
|
+
end
|
39
28
|
|
40
|
-
|
41
|
-
|
42
|
-
|
29
|
+
def foreign_key
|
30
|
+
if @model.present?
|
31
|
+
if @model.class == Class
|
32
|
+
@model.reflections[@meta[:relation_method]].foreign_key
|
43
33
|
else
|
44
|
-
|
45
|
-
{
|
46
|
-
value: model.id,
|
47
|
-
label: model.send(target_resource.title)
|
48
|
-
}
|
49
|
-
end
|
34
|
+
@model.class.reflections[@meta[:relation_method]].foreign_key
|
50
35
|
end
|
36
|
+
elsif @resource.present?
|
37
|
+
@resource.model_class.reflections[@meta[:relation_method]].foreign_key
|
51
38
|
end
|
39
|
+
end
|
52
40
|
|
53
|
-
|
41
|
+
def relation_model_class
|
42
|
+
@resource.model_class
|
43
|
+
end
|
54
44
|
|
55
|
-
|
45
|
+
def label
|
46
|
+
value.send(target_resource.title)
|
56
47
|
end
|
57
48
|
|
58
|
-
def
|
59
|
-
|
60
|
-
model.reflections[@relation_method].foreign_key
|
61
|
-
else
|
62
|
-
model.class.reflections[@relation_method].foreign_key
|
63
|
-
end
|
49
|
+
def to_permitted_param
|
50
|
+
foreign_key.to_sym
|
64
51
|
end
|
65
52
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
53
|
+
private
|
54
|
+
def target_resource
|
55
|
+
if @model._reflections[id.to_s].klass.present?
|
56
|
+
App.get_resource_by_model_name @model._reflections[id.to_s].klass.to_s
|
57
|
+
elsif @model._reflections[id.to_s].options[:class_name].present?
|
58
|
+
App.get_resource_by_model_name @model._reflections[id.to_s].options[:class_name]
|
59
|
+
else
|
60
|
+
App.get_resource_by_name id.to_s
|
61
|
+
end
|
73
62
|
end
|
74
|
-
end
|
75
63
|
end
|
76
64
|
end
|
77
65
|
end
|