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
@@ -3,6 +3,9 @@ require_dependency 'avo/application_controller'
|
|
3
3
|
module Avo
|
4
4
|
class HomeController < ApplicationController
|
5
5
|
def index
|
6
|
+
unless Rails.env.development?
|
7
|
+
redirect_to resources_path Avo::App.get_resources.sort_by { |resource| resource.route_key }.first.model_class
|
8
|
+
end
|
6
9
|
end
|
7
10
|
end
|
8
11
|
end
|
@@ -1,34 +1,103 @@
|
|
1
|
-
require_dependency 'avo/
|
1
|
+
require_dependency 'avo/base_controller'
|
2
2
|
|
3
3
|
module Avo
|
4
|
-
class RelationsController <
|
5
|
-
before_action :
|
4
|
+
class RelationsController < BaseController
|
5
|
+
before_action :set_model, only: [:show, :index, :new, :create, :destroy]
|
6
|
+
before_action :set_related_resource_name
|
7
|
+
before_action :set_related_resource
|
8
|
+
before_action :hydrate_related_resource
|
9
|
+
before_action :set_related_model, only: [:show]
|
10
|
+
before_action :set_attachment_class
|
11
|
+
before_action :set_attachment_resource
|
12
|
+
before_action :set_attachment_model, only: [:create, :destroy]
|
13
|
+
before_action :set_reflection, only: [:index]
|
6
14
|
|
7
|
-
def
|
8
|
-
resource.
|
15
|
+
def index
|
16
|
+
@parent_resource = @resource.dup
|
17
|
+
@resource = @related_resource
|
18
|
+
@parent_model = @parent_resource.model_class.find(params[:id])
|
19
|
+
@parent_resource.hydrate(model: @parent_model)
|
20
|
+
@query = @parent_model.public_send(params[:related_name])
|
9
21
|
|
10
|
-
|
11
|
-
success: true,
|
12
|
-
message: I18n.t('avo.attachment_class_attached', attachment_class: attachment_class),
|
13
|
-
}
|
22
|
+
super
|
14
23
|
end
|
15
24
|
|
16
|
-
def
|
17
|
-
|
25
|
+
def show
|
26
|
+
@reflection = params[:related_name]
|
27
|
+
@resource, @model = @related_resource, @related_model
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def new
|
33
|
+
query = @authorization.apply_policy @attachment_class
|
34
|
+
|
35
|
+
@options = query.all.map do |model|
|
36
|
+
{
|
37
|
+
value: model.id,
|
38
|
+
label: model.send(@attachment_resource.title)
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def create
|
44
|
+
if reflection_class == 'HasManyReflection'
|
45
|
+
@model.send("#{params[:related_name]}") << @attachment_model
|
46
|
+
else
|
47
|
+
@model.send("#{params[:related_name]}=", @attachment_model)
|
48
|
+
end
|
49
|
+
|
50
|
+
respond_to do |format|
|
51
|
+
if @model.save
|
52
|
+
format.html { redirect_to resource_path(@model), notice: t('avo.attachment_class_attached', attachment_class: @attachment_class) }
|
53
|
+
format.json { render :show, status: :created, location: resource_path(@model) }
|
54
|
+
else
|
55
|
+
format.html { render :new }
|
56
|
+
format.json { render json: @model.errors, status: :unprocessable_entity }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def destroy
|
62
|
+
if reflection_class == 'HasManyReflection'
|
63
|
+
@model.send("#{params[:related_name]}").delete @attachment_model
|
64
|
+
else
|
65
|
+
@model.send("#{params[:related_name]}=", nil)
|
66
|
+
end
|
67
|
+
|
68
|
+
respond_to do |format|
|
69
|
+
format.html { redirect_to params[:referrer] || resources_path(@model), notice: t('avo.attachment_class_detached', attachment_class: @attachment_class) }
|
70
|
+
end
|
23
71
|
end
|
24
72
|
|
25
73
|
private
|
26
|
-
def
|
27
|
-
|
74
|
+
def set_attachment_class
|
75
|
+
@attachment_class = @model._reflections[params[:related_name].to_s].klass
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_attachment_resource
|
79
|
+
@attachment_resource = App.get_resource_by_model_name @attachment_class
|
80
|
+
end
|
81
|
+
|
82
|
+
def set_attachment_model
|
83
|
+
@attachment_model = @model._reflections[params[:related_name].to_s].klass.find attachment_id
|
28
84
|
end
|
29
85
|
|
30
|
-
def
|
31
|
-
|
86
|
+
def set_reflection
|
87
|
+
@reflection = @model._reflections[params[:related_name].to_s]
|
88
|
+
end
|
89
|
+
|
90
|
+
def attachment_id
|
91
|
+
params[:related_id] or params.require(:fields).permit(:related_id)[:related_id]
|
92
|
+
end
|
93
|
+
|
94
|
+
def reflection_class
|
95
|
+
reflection = @model._reflections[params[:related_name]]
|
96
|
+
|
97
|
+
klass = @model._reflections[params[:related_name]].class.name.demodulize.to_s
|
98
|
+
klass = @model._reflections[params[:related_name]].through_reflection.class.name.demodulize.to_s if klass == 'ThroughReflection'
|
99
|
+
|
100
|
+
klass
|
32
101
|
end
|
33
102
|
end
|
34
103
|
end
|
@@ -4,7 +4,9 @@ module Avo
|
|
4
4
|
class ResourceOverviewController < ApplicationController
|
5
5
|
def index
|
6
6
|
resources = App.get_resources
|
7
|
-
.select
|
7
|
+
.select do |resource|
|
8
|
+
AuthorizationService::authorize _current_user, resource.model, Avo.configuration.authorization_methods.stringify_keys['index']
|
9
|
+
end
|
8
10
|
.sort_by(&:name)
|
9
11
|
.map do |resource|
|
10
12
|
{
|
@@ -1,263 +1,6 @@
|
|
1
|
-
require_dependency 'avo/
|
1
|
+
require_dependency 'avo/base_controller'
|
2
2
|
|
3
3
|
module Avo
|
4
|
-
class ResourcesController <
|
5
|
-
before_action :authorize_user
|
6
|
-
|
7
|
-
def index
|
8
|
-
params[:page] ||= 1
|
9
|
-
params[:per_page] ||= Avo.configuration.per_page
|
10
|
-
params[:sort_by] = params[:sort_by].present? ? params[:sort_by] : :created_at
|
11
|
-
params[:sort_direction] = params[:sort_direction].present? ? params[:sort_direction] : :desc
|
12
|
-
|
13
|
-
query = AuthorizationService.with_policy _current_user, resource_model
|
14
|
-
|
15
|
-
if params[:via_resource_name].present? and params[:via_resource_id].present? and params[:via_relationship].present?
|
16
|
-
# get the related resource (via_resource)
|
17
|
-
related_model = App.get_resource_by_name(params[:via_resource_name]).model
|
18
|
-
|
19
|
-
relation = related_model.find(params[:via_resource_id]).public_send(params[:via_relationship])
|
20
|
-
query = AuthorizationService.with_policy _current_user, relation
|
21
|
-
|
22
|
-
params[:per_page] = Avo.configuration.via_per_page
|
23
|
-
elsif ['has_many', 'has_and_belongs_to_many'].include? params[:for_relation]
|
24
|
-
# has_many searchable query
|
25
|
-
resources = resource_model.all.map do |model|
|
26
|
-
{
|
27
|
-
value: model.id,
|
28
|
-
label: model.send(avo_resource.title),
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
return render json: {
|
33
|
-
resources: resources
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
query = query.order("#{params[:sort_by]} #{params[:sort_direction]}")
|
38
|
-
|
39
|
-
applied_filters.each do |filter_class, filter_value|
|
40
|
-
query = filter_class.safe_constantize.new.apply_query request, query, filter_value
|
41
|
-
end
|
42
|
-
|
43
|
-
# Eager load the attachments
|
44
|
-
query = eager_load_files(query)
|
45
|
-
|
46
|
-
# Eager load the relations
|
47
|
-
if avo_resource.includes.present?
|
48
|
-
query = query.includes(*avo_resource.includes)
|
49
|
-
end
|
50
|
-
|
51
|
-
resources = query.page(params[:page]).per(params[:per_page])
|
52
|
-
|
53
|
-
resources_with_fields = []
|
54
|
-
resources.each do |resource|
|
55
|
-
resources_with_fields << Avo::Resources::Resource.hydrate_resource(model: resource, resource: avo_resource, view: :index, user: _current_user)
|
56
|
-
end
|
57
|
-
|
58
|
-
render json: {
|
59
|
-
success: true,
|
60
|
-
meta: build_meta,
|
61
|
-
resources: resources_with_fields,
|
62
|
-
per_page: params[:per_page],
|
63
|
-
total_pages: resources.total_pages,
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
def show
|
68
|
-
render json: {
|
69
|
-
resource: Avo::Resources::Resource.hydrate_resource(model: resource, resource: avo_resource, view: @view || :show, user: _current_user),
|
70
|
-
}
|
71
|
-
end
|
72
|
-
|
73
|
-
def edit
|
74
|
-
@view = :edit
|
75
|
-
|
76
|
-
show
|
77
|
-
end
|
78
|
-
|
79
|
-
def update
|
80
|
-
update_file_fields
|
81
|
-
|
82
|
-
# Filter out the file params
|
83
|
-
regular_resource_params = resource_params.select do |id, value|
|
84
|
-
!avo_resource.attached_file_fields.map(&:id).to_s.include? id
|
85
|
-
end
|
86
|
-
|
87
|
-
if avo_resource.has_devise_password and regular_resource_params[:password].blank?
|
88
|
-
regular_resource_params.delete(:password_confirmation)
|
89
|
-
regular_resource_params.delete(:password)
|
90
|
-
end
|
91
|
-
|
92
|
-
casted_params = cast_nullable(regular_resource_params)
|
93
|
-
avo_resource.fill_model(resource, casted_params).save!
|
94
|
-
|
95
|
-
render json: {
|
96
|
-
success: true,
|
97
|
-
resource: Avo::Resources::Resource.hydrate_resource(model: resource, resource: avo_resource, view: :show, user: _current_user),
|
98
|
-
message: I18n.t('avo.resource_updated'),
|
99
|
-
}
|
100
|
-
end
|
101
|
-
|
102
|
-
def create
|
103
|
-
create_params = resource_params
|
104
|
-
|
105
|
-
# Update the foreign key for a belongs_to relation from a has_many via creation.
|
106
|
-
if params[:via_relationship].present?
|
107
|
-
relationship_foreign_key = params[:via_resource_name].singularize.camelize.safe_constantize.reflections[params[:via_relationship]].foreign_key
|
108
|
-
if create_params[relationship_foreign_key].blank?
|
109
|
-
create_params[relationship_foreign_key] = params[:via_resource_id]
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
casted_params = cast_nullable(create_params)
|
114
|
-
|
115
|
-
resource = resource_model.new(casted_params)
|
116
|
-
resource.save!
|
117
|
-
|
118
|
-
render json: {
|
119
|
-
success: true,
|
120
|
-
resource: Avo::Resources::Resource.hydrate_resource(model: resource, resource: avo_resource, view: :create, user: _current_user),
|
121
|
-
message: I18n.t('avo.resource_created'),
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
|
-
def new
|
126
|
-
render json: {
|
127
|
-
resource: Avo::Resources::Resource.hydrate_resource(model: resource_model.new, resource: avo_resource, view: :create, user: _current_user),
|
128
|
-
}
|
129
|
-
end
|
130
|
-
|
131
|
-
def destroy
|
132
|
-
resource.destroy!
|
133
|
-
|
134
|
-
render json: {
|
135
|
-
message: I18n.t('avo.resource_destroyed'),
|
136
|
-
}
|
137
|
-
end
|
138
|
-
|
139
|
-
private
|
140
|
-
def permitted_params
|
141
|
-
permitted = avo_resource.get_fields.select(&:updatable).map do |field|
|
142
|
-
# If it's a relation
|
143
|
-
if field.methods.include? :foreign_key
|
144
|
-
database_id = field.foreign_key(avo_resource.model)
|
145
|
-
end
|
146
|
-
|
147
|
-
if database_id.present?
|
148
|
-
# Allow the database_id for belongs_to relation
|
149
|
-
database_id.to_sym
|
150
|
-
elsif field.is_array_param
|
151
|
-
# Allow array param if necessary
|
152
|
-
{ "#{field.id}": [] }
|
153
|
-
elsif field.is_object_param
|
154
|
-
# Allow array param if necessary
|
155
|
-
[:"#{field.id}", "#{field.id}": {} ]
|
156
|
-
else
|
157
|
-
field.id.to_sym
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
permitted
|
162
|
-
end
|
163
|
-
|
164
|
-
def resource_params
|
165
|
-
params.require(:resource).permit(permitted_params)
|
166
|
-
end
|
167
|
-
|
168
|
-
def update_file_fields
|
169
|
-
# Pick and attach file fields
|
170
|
-
attached_file_fields = avo_resource.attached_file_fields
|
171
|
-
if attached_file_fields.present?
|
172
|
-
file_fields_params = {}
|
173
|
-
|
174
|
-
# Map params to fields
|
175
|
-
attached_file_fields.each do |field|
|
176
|
-
file_fields_params[field.id] = resource_params[field.id.to_sym]
|
177
|
-
end
|
178
|
-
|
179
|
-
file_fields_params.each do |id, attachment|
|
180
|
-
# Identify field to make it easier to work with
|
181
|
-
field = resource.send(id)
|
182
|
-
|
183
|
-
if file_fields_params[id].is_a? Array
|
184
|
-
# Get the ID's that we kept
|
185
|
-
file_ids_kept = file_fields_params[id].select { |attachment| attachment.is_a? String }.map(&:to_i)
|
186
|
-
# Compute the difference
|
187
|
-
to_remove = field.pluck(:id) - file_ids_kept
|
188
|
-
# Remove the missing ones
|
189
|
-
to_remove.map { |attachment_id| field.find(attachment_id).purge }
|
190
|
-
end
|
191
|
-
|
192
|
-
# Figure out what has been submitted
|
193
|
-
if attachment.is_a? Array
|
194
|
-
# Files have been attached
|
195
|
-
attachment.each do |attachment|
|
196
|
-
process_file_field field, attachment
|
197
|
-
end
|
198
|
-
else
|
199
|
-
process_file_field field, attachment
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
def process_file_field(field, attachment)
|
206
|
-
if attachment.is_a? ActionDispatch::Http::UploadedFile
|
207
|
-
# New file has been attached
|
208
|
-
field.attach attachment
|
209
|
-
elsif attachment.blank?
|
210
|
-
# File has been deleted
|
211
|
-
field.purge
|
212
|
-
elsif attachment.is_a? String
|
213
|
-
# Field is unchanged
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def applied_filters
|
218
|
-
if params[:filters].present?
|
219
|
-
return JSON.parse(Base64.decode64(params[:filters]))
|
220
|
-
end
|
221
|
-
|
222
|
-
filter_defaults = {}
|
223
|
-
|
224
|
-
avo_resource.get_filters.each do |filter_class|
|
225
|
-
filter = filter_class.new
|
226
|
-
|
227
|
-
if filter.default.present?
|
228
|
-
filter_defaults[filter_class.to_s] = filter.default
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
filter_defaults
|
233
|
-
end
|
234
|
-
|
235
|
-
def cast_nullable(params)
|
236
|
-
fields = avo_resource.get_fields
|
237
|
-
|
238
|
-
nullable_fields = fields.filter { |field| field.nullable }
|
239
|
-
.map { |field| [field.id, field.null_values] }
|
240
|
-
.to_h
|
241
|
-
|
242
|
-
params.each do |key, value|
|
243
|
-
nullable = nullable_fields[key.to_sym]
|
244
|
-
|
245
|
-
if nullable.present? && value.in?(nullable)
|
246
|
-
params[key] = nil
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
params
|
251
|
-
end
|
252
|
-
|
253
|
-
def build_meta
|
254
|
-
{
|
255
|
-
per_page_steps: [*Avo.configuration.per_page_steps, Avo.configuration.per_page.to_i].sort.uniq,
|
256
|
-
available_view_types: avo_resource.available_view_types,
|
257
|
-
default_view_type: avo_resource.default_view_type || Avo.configuration.default_view_type,
|
258
|
-
translation_key: avo_resource.translation_key,
|
259
|
-
authorization: AuthorizationService::authorized_methods(_current_user, avo_resource.model)
|
260
|
-
}
|
261
|
-
end
|
4
|
+
class ResourcesController < BaseController
|
262
5
|
end
|
263
6
|
end
|
@@ -2,9 +2,10 @@ require_dependency 'avo/application_controller'
|
|
2
2
|
|
3
3
|
module Avo
|
4
4
|
class SearchController < ApplicationController
|
5
|
-
before_action :authorize_user
|
5
|
+
# before_action :authorize_user
|
6
6
|
|
7
7
|
def index
|
8
|
+
@authorization.set_record(resource_model).authorize_action :index
|
8
9
|
resources = []
|
9
10
|
|
10
11
|
resources_to_search_through = App.get_resources
|
@@ -44,12 +45,12 @@ module Avo
|
|
44
45
|
avo_resource.query_search(query: params[:q], via_resource_name: params[:via_resource_name], via_resource_id: params[:via_resource_id], user: _current_user)
|
45
46
|
end
|
46
47
|
|
47
|
-
def authorize_user
|
48
|
-
|
48
|
+
# def authorize_user
|
49
|
+
# return if params[:action] == 'index'
|
49
50
|
|
50
|
-
|
51
|
+
# action = params[:action] == 'resource' ? :index : params[:action]
|
51
52
|
|
52
|
-
|
53
|
-
end
|
53
|
+
# return render_unauthorized unless AuthorizationService::authorize_action _current_user, avo_resource.model, action
|
54
|
+
# end
|
54
55
|
end
|
55
56
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#toast-container > div {
|
2
|
+
box-shadow: none;
|
3
|
+
background-size: 1.5rem;
|
4
|
+
background-position: 0.8rem 0.8rem;
|
5
|
+
width: 500px;
|
6
|
+
|
7
|
+
@apply shadow-md opacity-100 border border-gray-200 rounded-md pt-3 pr-3 pb-3 bg-white;
|
8
|
+
|
9
|
+
&:hover {
|
10
|
+
@apply shadow-xl;
|
11
|
+
}
|
12
|
+
|
13
|
+
.toast-title {
|
14
|
+
@apply text-gray-800;
|
15
|
+
}
|
16
|
+
.toast-message {
|
17
|
+
@apply text-gray-800;
|
18
|
+
}
|
19
|
+
|
20
|
+
&.toast-success {
|
21
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0iIzM4YTE2OSI+CiAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi4yNjcgMy40NTVhMy4wNjYgMy4wNjYgMCAwMDEuNzQ1LS43MjMgMy4wNjYgMy4wNjYgMCAwMTMuOTc2IDAgMy4wNjYgMy4wNjYgMCAwMDEuNzQ1LjcyMyAzLjA2NiAzLjA2NiAwIDAxMi44MTIgMi44MTJjLjA1MS42NDMuMzA0IDEuMjU0LjcyMyAxLjc0NWEzLjA2NiAzLjA2NiAwIDAxMCAzLjk3NiAzLjA2NiAzLjA2NiAwIDAwLS43MjMgMS43NDUgMy4wNjYgMy4wNjYgMCAwMS0yLjgxMiAyLjgxMiAzLjA2NiAzLjA2NiAwIDAwLTEuNzQ1LjcyMyAzLjA2NiAzLjA2NiAwIDAxLTMuOTc2IDAgMy4wNjYgMy4wNjYgMCAwMC0xLjc0NS0uNzIzIDMuMDY2IDMuMDY2IDAgMDEtMi44MTItMi44MTIgMy4wNjYgMy4wNjYgMCAwMC0uNzIzLTEuNzQ1IDMuMDY2IDMuMDY2IDAgMDEwLTMuOTc2IDMuMDY2IDMuMDY2IDAgMDAuNzIzLTEuNzQ1IDMuMDY2IDMuMDY2IDAgMDEyLjgxMi0yLjgxMnptNy40NCA1LjI1MmExIDEgMCAwMC0xLjQxNC0xLjQxNEw5IDEwLjU4NiA3LjcwNyA5LjI5M2ExIDEgMCAwMC0xLjQxNCAxLjQxNGwyIDJhMSAxIDAgMDAxLjQxNCAwbDQtNHoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+Cg==) !important;
|
22
|
+
}
|
23
|
+
|
24
|
+
&.toast-warning {
|
25
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0icmdiYSgyMTcsIDExOSwgNiwgMSkiPgogIDxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTguMjU3IDMuMDk5Yy43NjUtMS4zNiAyLjcyMi0xLjM2IDMuNDg2IDBsNS41OCA5LjkyYy43NSAxLjMzNC0uMjEzIDIuOTgtMS43NDIgMi45OEg0LjQyYy0xLjUzIDAtMi40OTMtMS42NDYtMS43NDMtMi45OGw1LjU4LTkuOTJ6TTExIDEzYTEgMSAwIDExLTIgMCAxIDEgMCAwMTIgMHptLTEtOGExIDEgMCAwMC0xIDF2M2ExIDEgMCAwMDIgMFY2YTEgMSAwIDAwLTEtMXoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+Cg==) !important;
|
26
|
+
}
|
27
|
+
|
28
|
+
&.toast-info {
|
29
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0icmdiYSgzNywgOTksIDIzNSwgMSkiPgogIDxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTE4IDEwYTggOCAwIDExLTE2IDAgOCA4IDAgMDExNiAwem0tNy00YTEgMSAwIDExLTIgMCAxIDEgMCAwMTIgMHpNOSA5YTEgMSAwIDAwMCAydjNhMSAxIDAgMDAxIDFoMWExIDEgMCAxMDAtMnYtM2ExIDEgMCAwMC0xLTFIOXoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+Cg==) !important;
|
30
|
+
}
|
31
|
+
|
32
|
+
&.toast-error {
|
33
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0icmdiYSgyMjAsIDM4LCAzOCwgMSkiPgogIDxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTE4IDEwYTggOCAwIDExLTE2IDAgOCA4IDAgMDExNiAwem0tNyA0YTEgMSAwIDExLTIgMCAxIDEgMCAwMTIgMHptLTEtOWExIDEgMCAwMC0xIDF2NGExIDEgMCAxMDIgMFY2YTEgMSAwIDAwLTEtMXoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+Cg==) !important;
|
34
|
+
}
|
35
|
+
}
|