avo 0.5.0.beta4 → 0.5.0.beta9
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 +8 -6
- data/Gemfile.lock +28 -22
- 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/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/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 +8 -8
- data/app/components/avo/index/grid_item_component.rb +6 -12
- data/app/components/avo/index/resource_controls_component.html.erb +12 -4
- data/app/components/avo/index/resource_table_component.html.erb +1 -1
- data/app/components/avo/index/table_row_component.html.erb +1 -1
- data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
- 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_show_component.html.erb +14 -2
- data/app/controllers/avo/actions_controller.rb +6 -8
- data/app/controllers/avo/application_controller.rb +30 -6
- data/app/controllers/avo/base_controller.rb +5 -16
- data/app/controllers/avo/relations_controller.rb +2 -2
- data/app/controllers/avo/search_controller.rb +1 -1
- data/app/helpers/avo/application_helper.rb +1 -1
- data/app/{frontend/css → packs/entrypoints}/application.css +12 -11
- data/app/{frontend/packs → packs/entrypoints}/application.js +7 -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 +0 -0
- 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 +19 -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 +0 -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/_actions.html.erb +0 -6
- data/app/views/avo/base/_boolean_filter.html.erb +2 -1
- data/app/views/avo/base/_filters.html.erb +4 -11
- data/app/views/avo/base/_select_filter.html.erb +2 -1
- data/app/views/avo/home/_resources.html.erb +0 -1
- 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/_filter_wrapper.html.erb +1 -1
- data/avo.gemspec +1 -1
- data/bin/helpers.rb +0 -0
- data/bin/rspec +1 -0
- data/bin/webpack +3 -1
- 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 +10 -62
- data/db/factories.rb +1 -0
- data/lib/avo.rb +5 -16
- data/lib/avo/action_model.rb +20 -0
- data/lib/avo/app.rb +162 -0
- data/lib/avo/base_action.rb +126 -0
- data/lib/avo/base_resource.rb +301 -0
- data/lib/avo/configuration.rb +6 -4
- data/lib/avo/engine.rb +17 -20
- data/lib/avo/{app/fields → fields}/badge_field.rb +1 -1
- data/lib/avo/{app/fields/field.rb → fields/base_field.rb} +22 -16
- data/lib/avo/{app/fields/belongs_to.rb → fields/belongs_to_field.rb} +3 -3
- data/lib/avo/{app/fields → fields}/boolean_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/boolean_group_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/code_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/country_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/currency_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/date_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/date_time_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/external_image_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/field_extensions/has_field_name.rb +2 -9
- data/lib/avo/{app/fields → fields}/field_extensions/visible_in_different_views.rb +1 -1
- data/lib/avo/{app/fields → fields}/file_field.rb +1 -2
- data/lib/avo/{app/fields → fields}/files_field.rb +1 -2
- data/lib/avo/{app/fields → fields}/gravatar_field.rb +2 -2
- data/lib/avo/{app/fields/has_and_belongs_to_many.rb → fields/has_and_belongs_to_many_field.rb} +1 -1
- data/lib/avo/{app/fields/has_many.rb → fields/has_many_field.rb} +1 -1
- data/lib/avo/{app/fields/has_one.rb → fields/has_one_field.rb} +1 -1
- data/lib/avo/{app/fields → fields}/heading_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/hidden_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/id_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/key_value_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/markdown_field.rb +1 -3
- data/lib/avo/{app/fields → fields}/number_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/password_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/select_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/status_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/text_field.rb +1 -1
- data/lib/avo/{app/fields → fields}/textarea_field.rb +0 -2
- data/lib/avo/{app/fields → fields}/trix_field.rb +1 -3
- data/lib/avo/fields_collector.rb +31 -0
- data/lib/avo/filters/base_filter.rb +20 -0
- data/lib/avo/filters/boolean_filter.rb +7 -0
- data/lib/avo/filters/select_filter.rb +7 -0
- data/lib/avo/grid_collector.rb +39 -0
- data/lib/avo/{app/grid_fields → grid_fields}/body_field.rb +0 -2
- data/lib/avo/{app/grid_fields → grid_fields}/grid_field.rb +0 -0
- data/lib/avo/{app/grid_fields → grid_fields}/preview_field.rb +0 -2
- data/lib/avo/{app/grid_fields → grid_fields}/title_field.rb +0 -2
- data/lib/avo/has_context.rb +7 -0
- data/lib/avo/licensing/community_license.rb +6 -0
- data/lib/avo/licensing/h_q.rb +88 -0
- data/lib/avo/licensing/license.rb +50 -0
- data/lib/avo/licensing/license_manager.rb +22 -0
- data/lib/avo/licensing/null_license.rb +14 -0
- data/lib/avo/licensing/pro_license.rb +11 -0
- data/lib/avo/loaders/actions_loader.rb +6 -0
- data/lib/avo/loaders/fields_loader.rb +27 -0
- data/lib/avo/loaders/filters_loader.rb +6 -0
- data/lib/avo/loaders/loader.rb +15 -0
- data/lib/avo/services/authorization_service.rb +93 -0
- data/lib/avo/services/panel_service.rb +27 -0
- data/lib/avo/{app/tools_manager.rb → tools_manager.rb} +0 -0
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/action_generator.rb +11 -5
- data/lib/generators/avo/controller_generator.rb +14 -8
- data/lib/generators/avo/filter_generator.rb +14 -8
- data/lib/generators/avo/install_generator.rb +14 -10
- data/lib/generators/avo/locales_generator.rb +11 -7
- data/lib/generators/avo/partials_generator.rb +11 -5
- data/lib/generators/avo/resource_generator.rb +33 -15
- data/lib/generators/avo/templates/{action.rb → action.tt} +4 -6
- data/lib/generators/avo/templates/filters/boolean_filter.tt +11 -0
- data/lib/generators/avo/templates/filters/select_filter.tt +11 -0
- data/lib/generators/avo/templates/initializer/{avo.rb → avo.tt} +6 -0
- data/lib/generators/avo/templates/resource/controller.tt +2 -0
- data/lib/generators/avo/templates/resource/resource.tt +17 -0
- data/public/avo-packs/css/application-38e7e91b.css +5975 -0
- data/public/avo-packs/css/application-38e7e91b.css.br +0 -0
- data/public/avo-packs/css/application-38e7e91b.css.gz +0 -0
- data/public/avo-packs/css/application-38e7e91b.css.map +1 -0
- data/public/avo-packs/css/application-38e7e91b.css.map.br +0 -0
- data/public/avo-packs/css/application-38e7e91b.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-2b90fe889f7d6df1ad92.js +26 -0
- data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.LICENSE.txt → application-2b90fe889f7d6df1ad92.js.LICENSE.txt} +17 -17
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.br +0 -0
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.gz +0 -0
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map +1 -0
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.br +0 -0
- data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.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 +195 -193
- 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/config/webpacker_packed.yml +0 -86
- data/db/migrate/20210305082639_add_url_to_teams.rb +0 -5
- data/lib/avo/app/action.rb +0 -145
- data/lib/avo/app/actions_loader.rb +0 -11
- data/lib/avo/app/app.rb +0 -183
- data/lib/avo/app/fields_loader.rb +0 -29
- data/lib/avo/app/filter.rb +0 -23
- data/lib/avo/app/filters/boolean_filter.rb +0 -13
- data/lib/avo/app/filters/select_filter.rb +0 -13
- data/lib/avo/app/licensing/community_license.rb +0 -4
- data/lib/avo/app/licensing/hq.rb +0 -86
- data/lib/avo/app/licensing/license.rb +0 -48
- data/lib/avo/app/licensing/license_manager.rb +0 -25
- data/lib/avo/app/licensing/null_license.rb +0 -12
- data/lib/avo/app/licensing/pro_license.rb +0 -9
- data/lib/avo/app/resource.rb +0 -299
- data/lib/avo/app/resource_grid_fields.rb +0 -30
- data/lib/avo/app/services/authorization_service.rb +0 -110
- data/lib/avo/app/services/panel_service.rb +0 -25
- data/lib/avo/app/tool.rb +0 -5
- data/lib/generators/avo/templates/filters/boolean_filter.rb +0 -17
- data/lib/generators/avo/templates/filters/select_filter.rb +0 -17
- data/lib/generators/avo/templates/resource/%plural_name%_controller.tt +0 -2
- data/lib/generators/avo/templates/resource/%singular_name%.tt +0 -20
- data/public/avo-packs/css/application-3598cfbb.css +0 -6
- 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 +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-6ba2bd1bca05d69b96e0.js +0 -26
- 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 +0 -1
- 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.br +0 -0
- data/public/avo-packs/manifest.json.gz +0 -0
@@ -1,29 +0,0 @@
|
|
1
|
-
class Avo::FieldsLoader
|
2
|
-
attr_accessor :bag
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@bag = []
|
6
|
-
end
|
7
|
-
|
8
|
-
def add_field(field)
|
9
|
-
@bag.push field
|
10
|
-
end
|
11
|
-
|
12
|
-
def method_missing(method, *args, &block)
|
13
|
-
matched_field = Avo::App.fields.find do |field|
|
14
|
-
field[:name].to_s == method.to_s
|
15
|
-
end
|
16
|
-
|
17
|
-
if matched_field.present? and matched_field[:class].present?
|
18
|
-
klass = matched_field[:class]
|
19
|
-
|
20
|
-
if block.present?
|
21
|
-
field = klass::new(args[0], **args[1] || {}, &block)
|
22
|
-
else
|
23
|
-
field = klass::new(args[0], **args[1] || {})
|
24
|
-
end
|
25
|
-
|
26
|
-
add_field field
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/avo/app/filter.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Avo
|
2
|
-
class Filter
|
3
|
-
attr_accessor :name
|
4
|
-
attr_accessor :component
|
5
|
-
attr_accessor :default
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@name ||= 'Filter'
|
9
|
-
@component ||= 'boolean-filter'
|
10
|
-
@default ||= ''
|
11
|
-
end
|
12
|
-
|
13
|
-
def apply_query(request, query, value)
|
14
|
-
value.symbolize_keys! if value.is_a? Hash
|
15
|
-
|
16
|
-
self.apply(request, query, value)
|
17
|
-
end
|
18
|
-
|
19
|
-
def id
|
20
|
-
self.class.name.underscore.gsub('/', '_')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/avo/app/licensing/hq.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
module Avo
|
2
|
-
class HQ
|
3
|
-
attr_accessor :current_request
|
4
|
-
|
5
|
-
ENDPOINT = 'https://avohq.io/api/v1/licenses/check' unless const_defined?(:ENDPOINT)
|
6
|
-
CACHE_KEY = 'avo.hq.response' unless const_defined?(:CACHE_KEY)
|
7
|
-
REQUEST_TIMEOUT = 5 unless const_defined?(:REQUEST_TIMEOUT) # seconds
|
8
|
-
|
9
|
-
def initialize(current_request)
|
10
|
-
@current_request = current_request
|
11
|
-
@cache_store = Avo::App.cache_store
|
12
|
-
end
|
13
|
-
|
14
|
-
def response
|
15
|
-
@hq_response or request
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
def request
|
20
|
-
return cached_response if has_cached_response
|
21
|
-
|
22
|
-
begin
|
23
|
-
perform_and_cache_request
|
24
|
-
rescue HTTParty::Error => exception
|
25
|
-
cache_and_return_error 'HTTP client error.', exception.message
|
26
|
-
rescue Net::OpenTimeout => exception
|
27
|
-
cache_and_return_error 'Request timeout.', exception.message
|
28
|
-
rescue SocketError => exception
|
29
|
-
cache_and_return_error 'Connection error.', exception.message
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def perform_and_cache_request
|
34
|
-
hq_response = perform_request
|
35
|
-
|
36
|
-
return cache_and_return_error 'Avo HQ Internal server error.', hq_response.body if hq_response.code == 500
|
37
|
-
|
38
|
-
cache_response 1.hour.to_i, hq_response.parsed_response if hq_response.code == 200
|
39
|
-
end
|
40
|
-
|
41
|
-
def cache_response(time, response)
|
42
|
-
response.merge!(
|
43
|
-
expiry: time,
|
44
|
-
**payload,
|
45
|
-
).stringify_keys!
|
46
|
-
|
47
|
-
@cache_store.write(CACHE_KEY, response, expires_in: time)
|
48
|
-
|
49
|
-
@hq_response = response
|
50
|
-
|
51
|
-
response
|
52
|
-
end
|
53
|
-
|
54
|
-
def perform_request
|
55
|
-
puts 'Performing request to avohq.io API to check license availability.'.inspect if Rails.env.development?
|
56
|
-
|
57
|
-
HTTParty.post ENDPOINT, body: payload.to_json, headers: { 'Content-type': 'application/json' }, timeout: REQUEST_TIMEOUT
|
58
|
-
end
|
59
|
-
|
60
|
-
def payload
|
61
|
-
{
|
62
|
-
license: Avo.configuration.license,
|
63
|
-
license_key: Avo.configuration.license_key,
|
64
|
-
avo_version: Avo::VERSION,
|
65
|
-
rails_version: Rails::VERSION::STRING,
|
66
|
-
ruby_version: RUBY_VERSION,
|
67
|
-
environment: Rails.env,
|
68
|
-
ip: current_request.ip,
|
69
|
-
host: current_request.host,
|
70
|
-
port: current_request.port,
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
def cache_and_return_error(error, exception_message = '')
|
75
|
-
cache_response 5.minutes.to_i, { error: error, exception_message: exception_message }.stringify_keys
|
76
|
-
end
|
77
|
-
|
78
|
-
def has_cached_response
|
79
|
-
@cache_store.exist? CACHE_KEY
|
80
|
-
end
|
81
|
-
|
82
|
-
def cached_response
|
83
|
-
@cache_store.read CACHE_KEY
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Avo
|
2
|
-
class License
|
3
|
-
attr_accessor :id
|
4
|
-
attr_accessor :response
|
5
|
-
attr_accessor :valid
|
6
|
-
|
7
|
-
def initialize(response)
|
8
|
-
@response = response
|
9
|
-
@id = response['id']
|
10
|
-
@valid = response['valid']
|
11
|
-
end
|
12
|
-
|
13
|
-
def valid?
|
14
|
-
valid
|
15
|
-
end
|
16
|
-
|
17
|
-
def invalid?
|
18
|
-
!valid?
|
19
|
-
end
|
20
|
-
|
21
|
-
def pro?
|
22
|
-
id == 'pro'
|
23
|
-
end
|
24
|
-
|
25
|
-
def error
|
26
|
-
@response['error']
|
27
|
-
end
|
28
|
-
|
29
|
-
def properties
|
30
|
-
@response.slice('valid', 'id', 'error').symbolize_keys
|
31
|
-
end
|
32
|
-
|
33
|
-
def abilities
|
34
|
-
[]
|
35
|
-
end
|
36
|
-
|
37
|
-
def can(ability)
|
38
|
-
abilities.include? ability
|
39
|
-
end
|
40
|
-
|
41
|
-
def cant(ability)
|
42
|
-
!can ability
|
43
|
-
end
|
44
|
-
|
45
|
-
alias_method :has, :can
|
46
|
-
alias_method :lacks, :cant
|
47
|
-
end
|
48
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require_relative 'license'
|
2
|
-
require_relative 'community_license'
|
3
|
-
require_relative 'pro_license'
|
4
|
-
require_relative 'null_license'
|
5
|
-
|
6
|
-
module Avo
|
7
|
-
class LicenseManager
|
8
|
-
def initialize(hq_response)
|
9
|
-
@hq_response = hq_response
|
10
|
-
end
|
11
|
-
|
12
|
-
def license
|
13
|
-
return NullLicense.new if Rails.env.test? and ENV['RUN_WITH_NULL_LICENSE'] == '1'
|
14
|
-
|
15
|
-
case @hq_response['id']
|
16
|
-
when 'community'
|
17
|
-
CommunityLicense.new @hq_response
|
18
|
-
when 'pro'
|
19
|
-
ProLicense.new @hq_response
|
20
|
-
else
|
21
|
-
NullLicense.new @hq_response
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/avo/app/resource.rb
DELETED
@@ -1,299 +0,0 @@
|
|
1
|
-
require_relative 'resource_grid_fields'
|
2
|
-
require_relative 'fields/field'
|
3
|
-
|
4
|
-
module Avo
|
5
|
-
module Resources
|
6
|
-
class Resource
|
7
|
-
attr_writer :name
|
8
|
-
|
9
|
-
attr_accessor :id
|
10
|
-
attr_accessor :title
|
11
|
-
attr_accessor :search
|
12
|
-
attr_accessor :includes
|
13
|
-
attr_accessor :translation_key
|
14
|
-
attr_accessor :default_view_type
|
15
|
-
attr_accessor :devise_password_optional
|
16
|
-
attr_accessor :view
|
17
|
-
attr_accessor :model
|
18
|
-
attr_accessor :user
|
19
|
-
attr_accessor :fields_loader
|
20
|
-
attr_accessor :grid_loader
|
21
|
-
attr_accessor :actions_loader
|
22
|
-
attr_accessor :filters_loader
|
23
|
-
attr_accessor :params
|
24
|
-
|
25
|
-
alias :field :fields_loader
|
26
|
-
alias :f :field
|
27
|
-
alias :g :grid_loader
|
28
|
-
alias :action :actions_loader
|
29
|
-
alias :a :action
|
30
|
-
alias :filter :filters_loader
|
31
|
-
|
32
|
-
def initialize(request = nil)
|
33
|
-
@id = :id
|
34
|
-
@title = 'Resource'
|
35
|
-
@search = []
|
36
|
-
@includes = []
|
37
|
-
@translation_key = nil
|
38
|
-
@default_view_type = :table
|
39
|
-
@devise_password_optional = false
|
40
|
-
|
41
|
-
configure
|
42
|
-
boot_fields request
|
43
|
-
end
|
44
|
-
|
45
|
-
def boot_fields(request)
|
46
|
-
@fields_loader = Avo::FieldsLoader.new
|
47
|
-
fields request
|
48
|
-
|
49
|
-
@grid_loader = Avo::FieldsLoader.new
|
50
|
-
grid request if self.respond_to? :grid
|
51
|
-
|
52
|
-
@actions_loader = Avo::ActionsLoader.new
|
53
|
-
actions request if self.respond_to? :actions
|
54
|
-
|
55
|
-
@filters_loader = Avo::ActionsLoader.new
|
56
|
-
filters request if self.respond_to? :filters
|
57
|
-
end
|
58
|
-
|
59
|
-
def hydrate(model: nil, view: nil, user: nil, params: nil)
|
60
|
-
@view = view if view.present?
|
61
|
-
@user = user if user.present?
|
62
|
-
@params = params if params.present?
|
63
|
-
|
64
|
-
if model.present?
|
65
|
-
@model = model
|
66
|
-
|
67
|
-
hydrate_model_with_default_values if @view == :new
|
68
|
-
end
|
69
|
-
|
70
|
-
self
|
71
|
-
end
|
72
|
-
|
73
|
-
def get_fields(panel: nil, view_type: :table, reflection: nil)
|
74
|
-
case view_type.to_sym
|
75
|
-
when :table
|
76
|
-
fields = get_field_definitions.select do |field|
|
77
|
-
field.send("show_on_#{@view.to_s}")
|
78
|
-
end
|
79
|
-
.select do |field|
|
80
|
-
field.can_see.present? ? field.can_see.call : true
|
81
|
-
end
|
82
|
-
.select do |field|
|
83
|
-
unless field.respond_to?(:foreign_key) &&
|
84
|
-
reflection.present? &&
|
85
|
-
reflection.respond_to?(:foreign_key) &&
|
86
|
-
reflection.foreign_key == field.foreign_key
|
87
|
-
true
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
when :grid
|
92
|
-
fields = @grid_loader.bag
|
93
|
-
end
|
94
|
-
|
95
|
-
if panel.present?
|
96
|
-
fields = fields.select do |field|
|
97
|
-
field.panel_name == panel
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
fields = fields.map do |field|
|
102
|
-
field.hydrate(model: @model, view: @view, resource: self)
|
103
|
-
end
|
104
|
-
|
105
|
-
fields
|
106
|
-
end
|
107
|
-
|
108
|
-
def get_field_definitions
|
109
|
-
@fields_loader.bag.map do |field|
|
110
|
-
field.hydrate(resource: self, panel_name: default_panel_name, user: user)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def default_panel_name
|
115
|
-
return @params[:related_name].capitalize if @params[:related_name].present?
|
116
|
-
|
117
|
-
case @view
|
118
|
-
when :show
|
119
|
-
I18n.t('avo.resource_details', item: self.name.downcase, title: model_title).upcase_first
|
120
|
-
when :edit
|
121
|
-
I18n.t('avo.update_item', item: self.name.downcase, title: model_title).upcase_first
|
122
|
-
when :new
|
123
|
-
I18n.t('avo.create_new_item', item: self.name.downcase).upcase_first
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def panels
|
128
|
-
panels = [
|
129
|
-
{
|
130
|
-
name: default_panel_name,
|
131
|
-
type: :fields,
|
132
|
-
in_panel: true,
|
133
|
-
}
|
134
|
-
]
|
135
|
-
|
136
|
-
panels
|
137
|
-
end
|
138
|
-
|
139
|
-
def model_class
|
140
|
-
return @model.class if @model.present?
|
141
|
-
|
142
|
-
self.class.name.demodulize.safe_constantize
|
143
|
-
end
|
144
|
-
|
145
|
-
def model_title
|
146
|
-
return @model.send title if @model.present?
|
147
|
-
|
148
|
-
name
|
149
|
-
end
|
150
|
-
|
151
|
-
def name
|
152
|
-
return @name if @name.present?
|
153
|
-
|
154
|
-
return I18n.t(@translation_key, count: 1).capitalize if @translation_key
|
155
|
-
|
156
|
-
self.class.name.demodulize.titlecase
|
157
|
-
end
|
158
|
-
|
159
|
-
def singular_name
|
160
|
-
name
|
161
|
-
end
|
162
|
-
|
163
|
-
def plural_name
|
164
|
-
return I18n.t(@translation_key, count: 2).capitalize if @translation_key
|
165
|
-
|
166
|
-
name.pluralize
|
167
|
-
end
|
168
|
-
|
169
|
-
def underscore_name
|
170
|
-
return @name if @name.present?
|
171
|
-
|
172
|
-
self.class.name.demodulize.underscore
|
173
|
-
end
|
174
|
-
|
175
|
-
def available_view_types
|
176
|
-
get_fields(view_type: :grid).length > 0 ? [:grid, :table] : [:table]
|
177
|
-
end
|
178
|
-
|
179
|
-
def get_filters
|
180
|
-
@filters_loader.bag
|
181
|
-
end
|
182
|
-
|
183
|
-
def get_actions
|
184
|
-
@actions_loader.bag
|
185
|
-
end
|
186
|
-
|
187
|
-
def route_key
|
188
|
-
model_class.model_name.route_key
|
189
|
-
end
|
190
|
-
|
191
|
-
def query_search(query: '', via_resource_name: , via_resource_id:, user:)
|
192
|
-
# model_class = self.model
|
193
|
-
|
194
|
-
db_query = AuthorizationService.apply_policy(user, model_class)
|
195
|
-
|
196
|
-
if via_resource_name.present?
|
197
|
-
related_model = App.get_resource_by_name(via_resource_name).model
|
198
|
-
|
199
|
-
db_query = related_model.find(via_resource_id).public_send(self.plural_name.downcase)
|
200
|
-
end
|
201
|
-
|
202
|
-
new_query = []
|
203
|
-
|
204
|
-
[self.search].flatten.each_with_index do |search_by, index|
|
205
|
-
new_query.push 'or' if index != 0
|
206
|
-
|
207
|
-
new_query.push "text(#{search_by}) ILIKE '%#{query}%'"
|
208
|
-
end
|
209
|
-
|
210
|
-
db_query.where(new_query.join(' '))
|
211
|
-
end
|
212
|
-
|
213
|
-
def attached_file_fields
|
214
|
-
get_field_definitions.select do |field|
|
215
|
-
[Avo::Fields::FileField, Avo::Fields::FilesField].include? field.class
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
def fill_model(model, params)
|
220
|
-
# Map the received params to their actual fields
|
221
|
-
fields_by_database_id = self.get_field_definitions.map { |field| [field.database_id(model).to_s, field] }.to_h
|
222
|
-
|
223
|
-
params.each do |key, value|
|
224
|
-
field = fields_by_database_id[key]
|
225
|
-
|
226
|
-
next unless field
|
227
|
-
|
228
|
-
model = field.fill_field model, key, value
|
229
|
-
end
|
230
|
-
|
231
|
-
model
|
232
|
-
end
|
233
|
-
|
234
|
-
def authorization
|
235
|
-
AuthorizationService.new(user, model)
|
236
|
-
end
|
237
|
-
|
238
|
-
def file_hash
|
239
|
-
content_to_be_hashed = ''
|
240
|
-
|
241
|
-
# resource file hash
|
242
|
-
resource_path = Rails.root.join('app', 'avo', 'resources', "#{name.underscore}.rb").to_s
|
243
|
-
if File.file? resource_path
|
244
|
-
content_to_be_hashed += File.read(resource_path)
|
245
|
-
end
|
246
|
-
|
247
|
-
# policy file hash
|
248
|
-
policy_path = Rails.root.join('app', 'policies', "#{name.underscore}_policy.rb").to_s
|
249
|
-
if File.file? policy_path
|
250
|
-
content_to_be_hashed += File.read(policy_path)
|
251
|
-
end
|
252
|
-
|
253
|
-
Digest::MD5.hexdigest(content_to_be_hashed)
|
254
|
-
end
|
255
|
-
|
256
|
-
def cache_hash(parent_model)
|
257
|
-
if parent_model.present?
|
258
|
-
[self.model, self.file_hash, parent_model]
|
259
|
-
else
|
260
|
-
[self.model, self.file_hash]
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
# For :new views we're hydrating the model with the values from the resource's default attribute.
|
265
|
-
# We will not overwrite any attributes that come pre-filled in the model.
|
266
|
-
def hydrate_model_with_default_values
|
267
|
-
default_values = get_fields.select do |field|
|
268
|
-
!field.computed
|
269
|
-
end
|
270
|
-
.map do |field|
|
271
|
-
id = field.id
|
272
|
-
value = field.value
|
273
|
-
|
274
|
-
if field.respond_to? :foreign_key
|
275
|
-
id = field.foreign_key.to_sym
|
276
|
-
|
277
|
-
reflection = @model._reflections[@params[:via_relation]]
|
278
|
-
|
279
|
-
if reflection.present? && reflection.foreign_key.present?
|
280
|
-
value = @params[:via_resource_id]
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
[id, value]
|
285
|
-
end
|
286
|
-
.to_h
|
287
|
-
.select do |id, value|
|
288
|
-
value.present?
|
289
|
-
end
|
290
|
-
|
291
|
-
default_values.each do |id, value|
|
292
|
-
if @model.send(id).nil?
|
293
|
-
@model.send("#{id}=", value)
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|