avo 0.5.0.beta5 → 0.5.0.beta10
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 +47 -48
- data/Gemfile.lock +28 -22
- data/Rakefile +14 -14
- data/app/components/avo/common/badge_viewer_component.html.erb +1 -1
- data/app/components/avo/common/gravatar_viewer_component.html.erb +2 -2
- data/app/components/avo/common/gravatar_viewer_component.rb +2 -1
- data/app/components/avo/common/multiple_file_viewer_component.rb +1 -1
- data/app/components/avo/common/single_file_viewer_component.rb +1 -1
- data/app/components/avo/edit/field_wrapper_component.rb +3 -3
- data/app/components/avo/edit/fields/trix_field_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.rb +1 -1
- data/app/components/avo/index/fields/belongs_to_field_component.html.erb +1 -5
- data/app/components/avo/index/fields/boolean_group_field_component.html.erb +1 -1
- data/app/components/avo/index/fields/gravatar_field_component.html.erb +2 -1
- data/app/components/avo/index/fields/has_one_field_component.html.erb +1 -5
- data/app/components/avo/index/fields/id_field_component.html.erb +1 -1
- data/app/components/avo/index/grid_item_component.html.erb +2 -2
- data/app/components/avo/index/grid_item_component.rb +10 -9
- data/app/components/avo/index/resource_controls_component.html.erb +12 -4
- data/app/components/avo/index/resource_controls_component.rb +2 -2
- data/app/components/avo/panel_component.rb +7 -6
- data/app/components/avo/resource_component.rb +4 -3
- data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/show/field_wrapper_component.rb +3 -3
- data/app/components/avo/show/fields/boolean_group_field_component.html.erb +1 -1
- data/app/components/avo/show/fields/external_image_field_component.html.erb +1 -1
- data/app/components/avo/views/resource_edit_component.rb +4 -3
- data/app/components/avo/views/resource_index_component.rb +8 -7
- data/app/components/avo/views/resource_new_component.rb +4 -3
- data/app/components/avo/views/resource_show_component.html.erb +14 -2
- data/app/components/avo/views/resource_show_component.rb +21 -21
- data/app/controllers/avo/actions_controller.rb +34 -33
- data/app/controllers/avo/application_controller.rb +124 -116
- data/app/controllers/avo/attachments_controller.rb +3 -3
- data/app/controllers/avo/base_controller.rb +80 -87
- data/app/controllers/avo/home_controller.rb +2 -2
- data/app/controllers/avo/relations_controller.rb +29 -28
- data/app/controllers/avo/resources_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +20 -19
- data/app/helpers/avo/application_helper.rb +49 -43
- data/app/helpers/avo/resources_helper.rb +11 -11
- data/app/mailers/avo/application_mailer.rb +2 -2
- data/app/{frontend/css → packs/entrypoints}/application.css +12 -11
- data/app/{frontend/packs → packs/entrypoints}/application.js +9 -3
- data/app/{frontend → packs}/fonts/nunito-v16-latin-700.eot +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-700.svg +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-700.ttf +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-700.woff +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-700.woff2 +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.eot +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.svg +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.ttf +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.woff +0 -0
- data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.woff2 +0 -0
- data/app/{frontend → packs}/images/logo.png +0 -0
- data/app/{frontend → packs}/importmap.json.erb +0 -0
- data/app/{frontend → packs}/js/controllers/action_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/actions_picker_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/alerts_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/attachments_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/boolean_filter_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/fields/code_field_controller.js +14 -14
- data/app/{frontend → packs}/js/controllers/fields/date_field_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/fields/simple_mde_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/filter_controller.js +20 -3
- data/app/{frontend → packs}/js/controllers/hidden_input_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/item_selector_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/modal_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/per_page_controller.js +5 -1
- data/app/{frontend → packs}/js/controllers/select_filter_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/tippy_controller.js +0 -0
- data/app/{frontend → packs}/js/controllers/toggle_panel_controller.js +0 -0
- data/app/{frontend → packs}/js/helpers/cast_boolean.js +0 -0
- data/app/{frontend → packs}/js/toastr.js +1 -0
- data/app/{frontend/css → packs/stylesheets}/alerts.css +0 -0
- data/app/packs/stylesheets/components/code.css +11 -0
- data/app/{frontend/css → packs/stylesheets}/components/status.css +0 -0
- data/app/{frontend/css → packs/stylesheets}/fonts.css +0 -0
- data/app/{frontend/css → packs/stylesheets}/loader.css +0 -0
- data/app/{frontend/css → packs/stylesheets}/pagination.css +0 -0
- data/app/{frontend/css → packs/stylesheets}/tailwindcss/base.css +0 -0
- data/app/{frontend/css → packs/stylesheets}/tailwindcss/components.css +0 -0
- data/app/{frontend/css → packs/stylesheets}/tailwindcss/utilities.css +0 -0
- data/app/{frontend/css → packs/stylesheets}/tooltips.css +0 -0
- data/app/{frontend/css → packs/stylesheets}/typography.css +0 -0
- data/app/{frontend → packs}/svgs/arrow-circle-right.svg +0 -0
- data/app/{frontend → packs}/svgs/arrow-left.svg +0 -0
- data/app/{frontend → packs}/svgs/avocado.svg +0 -0
- data/app/{frontend → packs}/svgs/badge-check-sm.svg +0 -0
- data/app/{frontend → packs}/svgs/check-circle.svg +0 -0
- data/app/{frontend → packs}/svgs/chevron-down.svg +0 -0
- data/app/{frontend → packs}/svgs/chevron-up.svg +0 -0
- data/app/{frontend → packs}/svgs/code.svg +0 -0
- data/app/{frontend → packs}/svgs/color-swatch.svg +0 -0
- data/app/{frontend → packs}/svgs/document-text.svg +0 -0
- data/app/{frontend → packs}/svgs/download.svg +0 -0
- data/app/{frontend → packs}/svgs/edit.svg +0 -0
- data/app/{frontend → packs}/svgs/exclamation-circle-sm.svg +0 -0
- data/app/{frontend → packs}/svgs/exclamation-sm.svg +0 -0
- data/app/{frontend → packs}/svgs/exclamation.svg +0 -0
- data/app/{frontend → packs}/svgs/eye.svg +0 -0
- data/app/{frontend → packs}/svgs/filter.svg +0 -0
- data/app/{frontend → packs}/svgs/fire.svg +0 -0
- data/app/{frontend → packs}/svgs/game-board.svg +0 -0
- data/app/{frontend → packs}/svgs/globe.svg +0 -0
- data/app/{frontend → packs}/svgs/information-circle-sm.svg +0 -0
- data/app/{frontend → packs}/svgs/information-circle.svg +0 -0
- data/app/{frontend → packs}/svgs/library.svg +0 -0
- data/app/{frontend → packs}/svgs/photograph.svg +0 -0
- data/app/{frontend → packs}/svgs/play.svg +0 -0
- data/app/{frontend → packs}/svgs/plus-circle.svg +0 -0
- data/app/{frontend → packs}/svgs/plus.svg +0 -0
- data/app/{frontend → packs}/svgs/question-mark-circle.svg +0 -0
- data/app/{frontend → packs}/svgs/save.svg +0 -0
- data/app/{frontend → packs}/svgs/selector.svg +0 -0
- data/app/{frontend → packs}/svgs/sort-ascending.svg +0 -0
- data/app/{frontend → packs}/svgs/sort-descending.svg +0 -0
- data/app/{frontend → packs}/svgs/switch-horizontal.svg +0 -0
- data/app/{frontend → packs}/svgs/thumbs-down.svg +0 -0
- data/app/{frontend → packs}/svgs/thumbs-up.svg +0 -0
- data/app/{frontend → packs}/svgs/times.svg +0 -0
- data/app/{frontend → packs}/svgs/trash-sm.svg +0 -0
- data/app/{frontend → packs}/svgs/trash.svg +0 -0
- data/app/{frontend → packs}/svgs/view-grid-add.svg +0 -0
- data/app/{frontend → packs}/svgs/view-grid.svg +0 -0
- data/app/{frontend → packs}/svgs/view-list.svg +0 -0
- data/app/{frontend → packs}/svgs/x-circle.svg +0 -0
- data/app/views/avo/actions/show.html.erb +3 -39
- data/app/views/avo/attachments/show.html.erb +8 -1
- data/app/views/avo/base/_boolean_filter.html.erb +1 -0
- data/app/views/avo/base/_filters.html.erb +1 -0
- data/app/views/avo/base/_select_filter.html.erb +1 -0
- data/app/views/avo/partials/_paginator.html.erb +24 -5
- data/app/views/avo/relations/new.html.erb +5 -1
- data/app/views/layouts/avo/application.html.erb +0 -5
- data/avo.gemspec +31 -31
- data/bin/helpers.rb +0 -0
- data/bin/rspec +1 -0
- data/bin/webpack +3 -1
- data/config/initializers/inline_svg.rb +1 -1
- data/config/initializers/pagy.rb +1 -1
- data/config/routes.rb +12 -12
- data/config/spring.rb +5 -5
- data/config/webpack/aliases.js +1 -1
- data/config/webpack/base.js +14 -0
- data/config/webpack/development.js +2 -2
- data/config/webpack/production.js +2 -2
- data/config/webpack/test.js +2 -2
- data/config/webpacker.yml +5 -44
- data/db/factories.rb +4 -5
- data/lib/avo.rb +6 -6
- data/lib/avo/action_model.rb +20 -0
- data/lib/avo/app.rb +34 -62
- data/lib/avo/base_action.rb +56 -45
- data/lib/avo/base_resource.rb +69 -93
- data/lib/avo/configuration.rb +16 -22
- data/lib/avo/engine.rb +30 -14
- data/lib/avo/fields/badge_field.rb +2 -2
- data/lib/avo/fields/base_field.rb +38 -29
- data/lib/avo/fields/belongs_to_field.rb +13 -12
- data/lib/avo/fields/boolean_field.rb +4 -4
- data/lib/avo/fields/boolean_group_field.rb +3 -3
- data/lib/avo/fields/code_field.rb +4 -4
- data/lib/avo/fields/country_field.rb +2 -2
- data/lib/avo/fields/currency_field.rb +3 -3
- data/lib/avo/fields/date_field.rb +3 -3
- data/lib/avo/fields/date_time_field.rb +2 -2
- data/lib/avo/fields/external_image_field.rb +2 -2
- data/lib/avo/fields/field_extensions/has_field_name.rb +2 -9
- data/lib/avo/fields/field_extensions/visible_in_different_views.rb +34 -33
- data/lib/avo/fields/file_field.rb +1 -1
- data/lib/avo/fields/files_field.rb +2 -2
- data/lib/avo/fields/gravatar_field.rb +10 -10
- data/lib/avo/fields/has_and_belongs_to_many_field.rb +1 -1
- data/lib/avo/fields/has_many_field.rb +1 -1
- data/lib/avo/fields/has_one_field.rb +2 -2
- data/lib/avo/fields/heading_field.rb +2 -2
- data/lib/avo/fields/hidden_field.rb +1 -1
- data/lib/avo/fields/id_field.rb +3 -3
- data/lib/avo/fields/key_value_field.rb +12 -12
- data/lib/avo/fields/markdown_field.rb +2 -2
- data/lib/avo/fields/number_field.rb +3 -3
- data/lib/avo/fields/password_field.rb +1 -1
- data/lib/avo/fields/select_field.rb +8 -12
- data/lib/avo/fields/status_field.rb +4 -4
- data/lib/avo/fields/text_field.rb +2 -2
- data/lib/avo/fields/textarea_field.rb +2 -2
- data/lib/avo/fields/trix_field.rb +1 -1
- data/lib/avo/fields_collector.rb +30 -0
- data/lib/avo/filters/base_filter.rb +6 -6
- data/lib/avo/filters/boolean_filter.rb +1 -1
- data/lib/avo/filters/select_filter.rb +1 -1
- data/lib/avo/grid_collector.rb +39 -0
- data/lib/avo/has_context.rb +7 -0
- data/lib/avo/licensing/h_q.rb +56 -55
- data/lib/avo/licensing/license.rb +5 -5
- data/lib/avo/licensing/license_manager.rb +4 -4
- data/lib/avo/licensing/null_license.rb +2 -2
- data/lib/avo/licensing/pro_license.rb +1 -1
- data/lib/avo/loaders/fields_loader.rb +4 -4
- data/lib/avo/services/authorization_service.rb +2 -2
- data/lib/avo/services/panel_service.rb +4 -4
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/action_generator.rb +4 -4
- data/lib/generators/avo/controller_generator.rb +4 -4
- data/lib/generators/avo/filter_generator.rb +5 -5
- data/lib/generators/avo/install_generator.rb +8 -8
- data/lib/generators/avo/locales_generator.rb +5 -5
- data/lib/generators/avo/partials_generator.rb +4 -4
- data/lib/generators/avo/resource_generator.rb +5 -5
- data/lib/generators/avo/templates/action.tt +2 -2
- data/lib/tasks/avo_tasks.rake +52 -53
- data/public/avo-packs/css/application-4e16d6a6.css +5975 -0
- data/public/avo-packs/css/application-4e16d6a6.css.br +0 -0
- data/public/avo-packs/css/application-4e16d6a6.css.gz +0 -0
- data/public/avo-packs/css/application-4e16d6a6.css.map +1 -0
- data/public/avo-packs/css/application-4e16d6a6.css.map.br +0 -0
- data/public/avo-packs/css/application-4e16d6a6.css.map.gz +0 -0
- data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js +2 -0
- data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.br +0 -0
- data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.gz +0 -0
- data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map +1 -0
- data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map.br +0 -0
- data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map.gz +0 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js +26 -0
- data/public/avo-packs/js/{application-8849c6e2c8f75d55c666.js.LICENSE.txt → application-8eb130a4688f2c667703.js.LICENSE.txt} +17 -17
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.br +0 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.gz +0 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map +1 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map.br +0 -0
- data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +46 -23
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg → images/13ae283c0d7cc04efe7e.svg} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.br → images/13ae283c0d7cc04efe7e.svg.br} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.gz → images/13ae283c0d7cc04efe7e.svg.gz} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg → images/195026a50008c53526ef.svg} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.br → images/195026a50008c53526ef.svg.br} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.gz → images/195026a50008c53526ef.svg.gz} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-cb632c9fe211ba2c2bf1564c9a9295cc.woff → images/1f30e08faa7c60d1f7ac.woff} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf → images/1fd17dabf6b7d2b15348.ttf} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.br → images/1fd17dabf6b7d2b15348.ttf.br} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.gz → images/1fd17dabf6b7d2b15348.ttf.gz} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-bcf84d6cb8a0ac214c8c14ba9af834f3.woff2 → images/39a18f443d434999b89b.woff2} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-412073df419ad5f6f8f2ea76eb4aced9.woff2 → images/4ad349571e28bb59c5a5.woff2} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-2fae1e2418251b68fe5d0505ab93dd5c.eot → images/57a5470848663767abbf.eot} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf → images/b2e4cf0fab6c8ca66b7f.ttf} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.br → images/b2e4cf0fab6c8ca66b7f.ttf.br} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.gz → images/b2e4cf0fab6c8ca66b7f.ttf.gz} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-df7e79af617f98cd3b95d320e8b2a1af.eot → images/b78d61ab7e046de8c156.eot} +0 -0
- data/public/avo-packs/media/{fonts/nunito-v16-latin-700-7c472b19cb573f537bad8ef62ca917ac.woff → images/c9ab29becb76ddab01d0.woff} +0 -0
- data/public/avo-packs/media/images/{logo-edf8d8d0d263e0c1f73bb32a222d9991.png → f1b4befac91a3336db9a.png} +0 -0
- metadata +135 -132
- data/app/frontend/css/components/code.css +0 -27
- data/app/views/layouts/avo/application_vue.html.erb +0 -61
- data/config/webpack/environment.js +0 -18
- data/db/migrate/20210305082639_add_url_to_teams.rb +0 -5
- data/public/avo-packs/css/application-c75ac28c.css +0 -6
- data/public/avo-packs/css/application-c75ac28c.css.br +0 -0
- data/public/avo-packs/css/application-c75ac28c.css.gz +0 -0
- data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js +0 -2
- 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 +0 -1
- 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-8849c6e2c8f75d55c666.js +0 -26
- data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.br +0 -0
- data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.gz +0 -0
- data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.map +0 -1
- data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.map.br +0 -0
- data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.map.gz +0 -0
- data/public/avo-packs/manifest.json.br +0 -0
- data/public/avo-packs/manifest.json.gz +0 -0
@@ -11,7 +11,7 @@ module Avo
|
|
11
11
|
rescue_from Pundit::NotAuthorizedError, with: :render_unauthorized
|
12
12
|
rescue_from ActiveRecord::RecordInvalid, with: :exception_logger
|
13
13
|
|
14
|
-
helper_method :_current_user, :resources_path, :resource_path, :new_resource_path, :edit_resource_path, :resource_attach_path, :resource_detach_path
|
14
|
+
helper_method :_current_user, :resources_path, :resource_path, :new_resource_path, :edit_resource_path, :resource_attach_path, :resource_detach_path, :related_resources_path
|
15
15
|
add_flash_types :info, :warning, :success, :error
|
16
16
|
|
17
17
|
def init_app
|
@@ -23,11 +23,13 @@ module Avo
|
|
23
23
|
def exception_logger(exception)
|
24
24
|
respond_to do |format|
|
25
25
|
format.html { raise exception }
|
26
|
-
format.json {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
format.json {
|
27
|
+
render json: {
|
28
|
+
errors: exception.respond_to?(:record) && exception.record.present? ? exception.record.errors : [],
|
29
|
+
message: exception.message,
|
30
|
+
traces: exception.backtrace
|
31
|
+
}, status: ActionDispatch::ExceptionWrapper.status_code_for_exception(exception.class.name)
|
32
|
+
}
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -48,20 +50,26 @@ module Avo
|
|
48
50
|
if keep_query_params
|
49
51
|
existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
|
50
52
|
end
|
51
|
-
rescue;end
|
52
|
-
|
53
|
+
rescue; end
|
53
54
|
send :"resources_#{model.model_name.route_key}_path", **existing_params, **args
|
54
55
|
end
|
55
56
|
|
56
|
-
def
|
57
|
+
def related_resources_path(parent_model, model, keep_query_params: false, **args)
|
58
|
+
return if model.nil?
|
59
|
+
|
57
60
|
existing_params = {}
|
58
61
|
|
59
62
|
begin
|
60
63
|
if keep_query_params
|
61
64
|
existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys
|
62
65
|
end
|
63
|
-
rescue;end
|
66
|
+
rescue; end
|
67
|
+
Addressable::Template.new("#{Avo.configuration.root_path}/resources/#{@parent_resource.model.model_name.route_key}/#{@parent_resource.model.id}/#{@resource.route_key}{?query*}")
|
68
|
+
.expand({query: {**existing_params, **args}})
|
69
|
+
.to_str
|
70
|
+
end
|
64
71
|
|
72
|
+
def resource_path(model = nil, resource_id: nil, keep_query_params: false, **args)
|
65
73
|
return send :"resources_#{model.model_name.route_key.singularize}_path", resource_id, **args if resource_id.present?
|
66
74
|
|
67
75
|
send :"resources_#{model.model_name.route_key.singularize}_path", model, **args
|
@@ -92,146 +100,146 @@ module Avo
|
|
92
100
|
end
|
93
101
|
|
94
102
|
private
|
95
|
-
def set_resource_name
|
96
|
-
@resource_name = resource_name
|
97
|
-
end
|
98
103
|
|
99
|
-
|
100
|
-
|
101
|
-
|
104
|
+
def set_resource_name
|
105
|
+
@resource_name = resource_name
|
106
|
+
end
|
102
107
|
|
103
|
-
|
104
|
-
|
105
|
-
|
108
|
+
def set_related_resource_name
|
109
|
+
@related_resource_name = related_resource_name
|
110
|
+
end
|
106
111
|
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
def set_resource
|
113
|
+
@resource = resource.hydrate(params: params)
|
114
|
+
end
|
110
115
|
|
111
|
-
|
112
|
-
|
113
|
-
|
116
|
+
def set_related_resource
|
117
|
+
@related_resource = related_resource.hydrate(params: params)
|
118
|
+
end
|
114
119
|
|
115
|
-
|
116
|
-
|
117
|
-
|
120
|
+
def set_model
|
121
|
+
@model = eager_load_files(@resource, @resource.model_class).find params[:id]
|
122
|
+
end
|
118
123
|
|
119
|
-
|
120
|
-
|
121
|
-
|
124
|
+
def set_related_model
|
125
|
+
@related_model = eager_load_files(@related_resource, @related_resource.model_class).find params[:related_id]
|
126
|
+
end
|
122
127
|
|
123
|
-
|
124
|
-
|
125
|
-
|
128
|
+
def hydrate_resource
|
129
|
+
@resource.hydrate(view: action_name.to_sym, user: _current_user)
|
130
|
+
end
|
126
131
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
132
|
+
def hydrate_related_resource
|
133
|
+
@related_resource.hydrate(view: action_name.to_sym, user: _current_user)
|
134
|
+
end
|
135
|
+
|
136
|
+
def authorize_action
|
137
|
+
if @model.present?
|
138
|
+
@authorization.set_record(@model).authorize_action :index
|
139
|
+
else
|
140
|
+
@authorization.set_record(@resource.model_class).authorize_action :index
|
133
141
|
end
|
142
|
+
end
|
134
143
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
144
|
+
# Get the pluralized resource name for this request
|
145
|
+
# Ex: projects, teams, users
|
146
|
+
def resource_name
|
147
|
+
return params[:resource_name] if params[:resource_name].present?
|
139
148
|
|
140
|
-
|
149
|
+
return controller_name if controller_name.present?
|
141
150
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
151
|
+
begin
|
152
|
+
request.path
|
153
|
+
.match(/\/?#{Avo.configuration.root_path.delete('/')}\/resources\/([a-z1-9\-_]*)\/?/mi)
|
154
|
+
.captures
|
155
|
+
.first
|
156
|
+
rescue
|
149
157
|
end
|
158
|
+
end
|
150
159
|
|
151
|
-
|
152
|
-
|
153
|
-
|
160
|
+
def related_resource_name
|
161
|
+
params[:related_name]
|
162
|
+
end
|
154
163
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
164
|
+
# Gets the Avo resource for this request based on the request from the `resource_name` "param"
|
165
|
+
# Ex: Avo::Resources::Project, Avo::Resources::Team, Avo::Resources::User
|
166
|
+
def resource
|
167
|
+
resource = App.get_resource @resource_name.to_s.camelize.singularize
|
160
168
|
|
161
|
-
|
162
|
-
reflection = @model._reflections[params[:related_name]]
|
169
|
+
return resource if resource.present?
|
163
170
|
|
164
|
-
|
165
|
-
|
166
|
-
else
|
167
|
-
reflected_model = reflection.klass
|
168
|
-
end
|
171
|
+
App.get_resource_by_controller_name @resource_name
|
172
|
+
end
|
169
173
|
|
170
|
-
|
171
|
-
|
174
|
+
def related_resource
|
175
|
+
reflection = @model._reflections[params[:related_name]]
|
176
|
+
|
177
|
+
reflected_model = reflection.klass
|
178
|
+
|
179
|
+
App.get_resource_by_model_name reflected_model
|
180
|
+
end
|
172
181
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
return query.eager_load "#{field.id}_#{attachment}": :blob
|
188
|
-
# return query.send :"with_attached_#{field}"
|
182
|
+
def eager_load_files(resource, query)
|
183
|
+
if resource.attached_file_fields.present?
|
184
|
+
resource.attached_file_fields.map do |field|
|
185
|
+
# abort "#{field.pluralize}".inspect
|
186
|
+
# abort field.class.inspect
|
187
|
+
attachment = case field.class.to_s
|
188
|
+
when "Avo::Fields::FileField"
|
189
|
+
"attachment"
|
190
|
+
when "Avo::Fields::FilesField"
|
191
|
+
"attachments"
|
192
|
+
else
|
193
|
+
"attachment"
|
189
194
|
end
|
190
|
-
end
|
191
195
|
|
192
|
-
|
196
|
+
return query.eager_load "#{field.id}_#{attachment}": :blob
|
197
|
+
# return query.send :"with_attached_#{field}"
|
198
|
+
end
|
193
199
|
end
|
194
200
|
|
201
|
+
query
|
202
|
+
end
|
195
203
|
|
196
|
-
|
197
|
-
|
204
|
+
# def authorize_user
|
205
|
+
# return if params[:controller] == 'avo/search'
|
198
206
|
|
199
|
-
|
207
|
+
# model = record = resource.model
|
200
208
|
|
201
|
-
|
202
|
-
|
203
|
-
|
209
|
+
# if ['show', 'edit', 'update'].include?(params[:action]) && params[:controller] == 'avo/resources'
|
210
|
+
# record = resource
|
211
|
+
# end
|
204
212
|
|
205
|
-
|
206
|
-
|
213
|
+
# # AuthorizationService::authorize_action _current_user, record, params[:action] return render_unauthorized unless
|
214
|
+
# end
|
207
215
|
|
208
|
-
|
209
|
-
|
210
|
-
|
216
|
+
def _authenticate!
|
217
|
+
instance_eval(&Avo.configuration.authenticate)
|
218
|
+
end
|
211
219
|
|
212
|
-
|
213
|
-
|
214
|
-
|
220
|
+
def render_unauthorized(exception)
|
221
|
+
if !exception.is_a? Pundit::NotDefinedError
|
222
|
+
flash[:notice] = t "avo.not_authorized"
|
215
223
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
end
|
221
|
-
|
222
|
-
redirect_to(redirect_url)
|
224
|
+
redirect_url = if request.referrer.blank? || (request.referrer == request.url)
|
225
|
+
root_url
|
226
|
+
else
|
227
|
+
request.referrer
|
223
228
|
end
|
224
|
-
end
|
225
229
|
|
226
|
-
|
227
|
-
@authorization = Services::AuthorizationService.new _current_user
|
230
|
+
redirect_to(redirect_url)
|
228
231
|
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def set_authorization
|
235
|
+
@authorization = Services::AuthorizationService.new _current_user
|
236
|
+
end
|
229
237
|
|
230
|
-
|
231
|
-
|
232
|
-
|
238
|
+
def set_container_classes
|
239
|
+
contain = !Avo.configuration.full_width_container
|
240
|
+
contain = false if Avo.configuration.full_width_index_view && action_name.to_sym == :index && self.class.superclass.to_s == "Avo::ResourcesController"
|
233
241
|
|
234
|
-
|
235
|
-
|
242
|
+
@container_classes = contain ? "2xl:container 2xl:mx-auto" : ""
|
243
|
+
end
|
236
244
|
end
|
237
245
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_dependency
|
1
|
+
require_dependency "avo/application_controller"
|
2
2
|
|
3
3
|
module Avo
|
4
4
|
class AttachmentsController < ApplicationController
|
@@ -16,9 +16,9 @@ module Avo
|
|
16
16
|
if attachment.present?
|
17
17
|
attachment.destroy
|
18
18
|
|
19
|
-
redirect_to params[:referrer] || resource_path(@model), notice: t(
|
19
|
+
redirect_to params[:referrer] || resource_path(@model), notice: t("avo.attachment_destroyed")
|
20
20
|
else
|
21
|
-
redirect_back fallback_location: resource_path(@model), notice: t(
|
21
|
+
redirect_back fallback_location: resource_path(@model), notice: t("avo.failed_to_find_attachment")
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_dependency
|
1
|
+
require_dependency "avo/application_controller"
|
2
2
|
|
3
3
|
module Avo
|
4
4
|
class BaseController < ApplicationController
|
@@ -66,16 +66,16 @@ module Avo
|
|
66
66
|
|
67
67
|
respond_to do |format|
|
68
68
|
if saved
|
69
|
-
if params[:via_relation_class].present? && params[:via_resource_id].present?
|
70
|
-
|
69
|
+
redirect_path = if params[:via_relation_class].present? && params[:via_resource_id].present?
|
70
|
+
resource_path(params[:via_relation_class].safe_constantize, resource_id: params[:via_resource_id])
|
71
71
|
else
|
72
|
-
|
72
|
+
resource_path(@model)
|
73
73
|
end
|
74
74
|
|
75
75
|
format.html { redirect_to redirect_path, notice: "#{@model.class.name} was successfully created." }
|
76
76
|
format.json { render :show, status: :created, location: @model }
|
77
77
|
else
|
78
|
-
flash[:error] = t
|
78
|
+
flash[:error] = t "avo.you_missed_something_check_form"
|
79
79
|
format.html { render :new, status: :unprocessable_entity }
|
80
80
|
format.json { render json: @model.errors, status: :unprocessable_entity }
|
81
81
|
end
|
@@ -92,7 +92,7 @@ module Avo
|
|
92
92
|
format.html { redirect_to params[:referrer] || resource_path(@model), notice: "#{@model.class.name} was successfully updated." }
|
93
93
|
format.json { render :show, status: :ok, location: @model }
|
94
94
|
else
|
95
|
-
flash[:error] = t
|
95
|
+
flash[:error] = t "avo.you_missed_something_check_form"
|
96
96
|
format.html { render :edit, status: :unprocessable_entity }
|
97
97
|
format.json { render json: @model.errors, status: :unprocessable_entity }
|
98
98
|
end
|
@@ -103,124 +103,117 @@ module Avo
|
|
103
103
|
@model.destroy!
|
104
104
|
|
105
105
|
respond_to do |format|
|
106
|
-
format.html { redirect_to params[:referrer] || resources_path(@model), notice: t(
|
106
|
+
format.html { redirect_to params[:referrer] || resources_path(@model, turbo_frame: params[:turbo_frame], view_type: params[:view_type]), notice: t("avo.resource_destroyed", attachment_class: @attachment_class) }
|
107
107
|
format.json { head :no_content }
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
private
|
112
|
-
def model_route_key
|
113
|
-
@resource.model_class.model_name.route_key.singularize
|
114
|
-
end
|
115
112
|
|
116
|
-
|
117
|
-
|
113
|
+
def model_route_key
|
114
|
+
@resource.model_class.model_name.route_key.singularize
|
115
|
+
end
|
118
116
|
|
119
|
-
|
120
|
-
|
121
|
-
request_params.delete(:password)
|
122
|
-
end
|
117
|
+
def model_params
|
118
|
+
request_params = params.require(model_route_key).permit(permitted_params)
|
123
119
|
|
124
|
-
|
120
|
+
if @resource.devise_password_optional && request_params[:password].blank? && request_params[:password_confirmation].blank?
|
121
|
+
request_params.delete(:password_confirmation)
|
122
|
+
request_params.delete(:password)
|
125
123
|
end
|
126
124
|
|
127
|
-
|
128
|
-
|
129
|
-
end
|
125
|
+
request_params
|
126
|
+
end
|
130
127
|
|
131
|
-
|
132
|
-
|
128
|
+
def permitted_params
|
129
|
+
@resource.get_field_definitions.select(&:updatable).map(&:to_permitted_param)
|
130
|
+
end
|
133
131
|
|
134
|
-
|
135
|
-
|
136
|
-
|
132
|
+
def cast_nullable(params)
|
133
|
+
fields = @resource.get_field_definitions
|
134
|
+
|
135
|
+
nullable_fields = fields.filter do |field|
|
136
|
+
field.nullable
|
137
|
+
end
|
137
138
|
.map do |field|
|
138
|
-
|
139
|
-
|
139
|
+
[field.id, field.null_values]
|
140
|
+
end
|
140
141
|
.to_h
|
141
142
|
|
142
|
-
|
143
|
-
|
143
|
+
params.each do |key, value|
|
144
|
+
nullable = nullable_fields[key.to_sym]
|
144
145
|
|
145
|
-
|
146
|
-
|
147
|
-
end
|
146
|
+
if nullable.present? && value.in?(nullable)
|
147
|
+
params[key] = nil
|
148
148
|
end
|
149
|
-
|
150
|
-
params
|
151
149
|
end
|
152
150
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
# Pagination
|
157
|
-
@index_params[:page] = params[:page] || 1
|
158
|
-
@index_params[:per_page] = Avo.configuration.per_page
|
159
|
-
|
160
|
-
if cookies[:per_page].present?
|
161
|
-
@index_params[:per_page] = cookies[:per_page]
|
162
|
-
end
|
151
|
+
params
|
152
|
+
end
|
163
153
|
|
164
|
-
|
165
|
-
|
166
|
-
end
|
154
|
+
def set_index_params
|
155
|
+
@index_params = {}
|
167
156
|
|
168
|
-
|
169
|
-
|
170
|
-
|
157
|
+
# Pagination
|
158
|
+
@index_params[:page] = params[:page] || 1
|
159
|
+
@index_params[:per_page] = Avo.configuration.per_page
|
171
160
|
|
172
|
-
|
173
|
-
|
174
|
-
|
161
|
+
if cookies[:per_page].present?
|
162
|
+
@index_params[:per_page] = cookies[:per_page]
|
163
|
+
end
|
175
164
|
|
176
|
-
|
177
|
-
@index_params[:
|
178
|
-
|
165
|
+
if @parent_model.present?
|
166
|
+
@index_params[:per_page] = Avo.configuration.via_per_page
|
167
|
+
end
|
179
168
|
|
180
|
-
|
181
|
-
@index_params[:
|
182
|
-
|
169
|
+
if params[:per_page].present?
|
170
|
+
@index_params[:per_page] = params[:per_page]
|
171
|
+
cookies[:per_page] = params[:per_page]
|
183
172
|
end
|
184
173
|
|
185
|
-
|
186
|
-
|
187
|
-
|
174
|
+
# Sorting
|
175
|
+
@index_params[:sort_by] = params[:sort_by] || :created_at
|
176
|
+
@index_params[:sort_direction] = params[:sort_direction] || :desc
|
188
177
|
|
189
|
-
|
190
|
-
|
191
|
-
|
178
|
+
# View types
|
179
|
+
@index_params[:view_type] = params[:view_type] || @resource.default_view_type || Avo.configuration.default_view_type
|
180
|
+
@index_params[:available_view_types] = @resource.available_view_types
|
181
|
+
end
|
192
182
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
end
|
183
|
+
def set_filters
|
184
|
+
@filters = @resource.get_filters.map do |filter_class|
|
185
|
+
filter = filter_class.new
|
197
186
|
|
198
|
-
|
199
|
-
|
187
|
+
filter
|
188
|
+
end
|
189
|
+
end
|
200
190
|
|
201
|
-
|
202
|
-
|
191
|
+
def set_actions
|
192
|
+
if params[:resource_id].present?
|
193
|
+
model = @resource.model_class.find params[:resource_id]
|
194
|
+
end
|
203
195
|
|
204
|
-
|
205
|
-
|
196
|
+
@actions = @resource.get_actions.map do |action|
|
197
|
+
action.new(model: model, resource: @resource)
|
206
198
|
end
|
199
|
+
end
|
207
200
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
201
|
+
def applied_filters
|
202
|
+
if params[:filters].present?
|
203
|
+
return JSON.parse(Base64.decode64(params[:filters]))
|
204
|
+
end
|
212
205
|
|
213
|
-
|
206
|
+
filter_defaults = {}
|
214
207
|
|
215
|
-
|
216
|
-
|
208
|
+
@resource.get_filters.each do |filter_class|
|
209
|
+
filter = filter_class.new
|
217
210
|
|
218
|
-
|
219
|
-
|
220
|
-
end
|
211
|
+
if filter.default.present?
|
212
|
+
filter_defaults[filter_class.to_s] = filter.default
|
221
213
|
end
|
222
|
-
|
223
|
-
filter_defaults
|
224
214
|
end
|
215
|
+
|
216
|
+
filter_defaults
|
217
|
+
end
|
225
218
|
end
|
226
219
|
end
|