avo 0.5.0.beta7 → 0.5.0.beta12
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 +48 -47
- data/Gemfile.lock +28 -18
- 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 -32
- data/app/controllers/avo/application_controller.rb +122 -119
- data/app/controllers/avo/attachments_controller.rb +3 -3
- data/app/controllers/avo/base_controller.rb +80 -82
- 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 -30
- 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 +18 -60
- data/lib/avo/base_action.rb +55 -52
- data/lib/avo/base_resource.rb +66 -95
- 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 +1 -5
- data/lib/generators/avo/templates/resource/resource.tt +3 -13
- data/lib/tasks/avo_tasks.rake +0 -60
- 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 +144 -127
- 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
data/lib/avo/configuration.rb
CHANGED
@@ -9,8 +9,6 @@ module Avo
|
|
9
9
|
attr_accessor :locale
|
10
10
|
attr_accessor :currency
|
11
11
|
attr_accessor :default_view_type
|
12
|
-
attr_accessor :hide_resource_overview_component
|
13
|
-
attr_accessor :hide_documentation_link
|
14
12
|
attr_accessor :license
|
15
13
|
attr_accessor :license_key
|
16
14
|
attr_accessor :authorization_methods
|
@@ -23,29 +21,27 @@ module Avo
|
|
23
21
|
attr_accessor :context
|
24
22
|
|
25
23
|
def initialize
|
26
|
-
@root_path =
|
27
|
-
@app_name = Rails.application.class.to_s.split(
|
28
|
-
@timezone =
|
24
|
+
@root_path = "/avo"
|
25
|
+
@app_name = Rails.application.class.to_s.split("::").first.underscore.humanize(keep_id_suffix: true)
|
26
|
+
@timezone = "UTC"
|
29
27
|
@per_page = 24
|
30
28
|
@per_page_steps = [12, 24, 48, 72]
|
31
29
|
@via_per_page = 8
|
32
|
-
@locale =
|
33
|
-
@currency =
|
30
|
+
@locale = "en-US"
|
31
|
+
@currency = "USD"
|
34
32
|
@default_view_type = :table
|
35
|
-
@
|
36
|
-
@hide_documentation_link = false
|
37
|
-
@license = 'community'
|
33
|
+
@license = "community"
|
38
34
|
@license_key = nil
|
39
35
|
@current_user = proc {}
|
40
36
|
@authenticate = proc {}
|
41
37
|
@authorization_methods = {
|
42
|
-
index:
|
43
|
-
show:
|
44
|
-
edit:
|
45
|
-
new:
|
46
|
-
update:
|
47
|
-
create:
|
48
|
-
destroy:
|
38
|
+
index: "index?",
|
39
|
+
show: "show?",
|
40
|
+
edit: "edit?",
|
41
|
+
new: "new?",
|
42
|
+
update: "update?",
|
43
|
+
create: "create?",
|
44
|
+
destroy: "destroy?"
|
49
45
|
}
|
50
46
|
@id_links_to_resource = false
|
51
47
|
@full_width_container = false
|
@@ -59,11 +55,9 @@ module Avo
|
|
59
55
|
end
|
60
56
|
|
61
57
|
def language_code
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
'en'
|
66
|
-
end
|
58
|
+
locale_tag.language.code
|
59
|
+
rescue
|
60
|
+
"en"
|
67
61
|
end
|
68
62
|
|
69
63
|
def current_user_method(&block)
|
data/lib/avo/engine.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# requires all dependencies
|
2
|
-
Gem.loaded_specs[
|
2
|
+
Gem.loaded_specs["avo"].dependencies.each do |d|
|
3
3
|
require d.name
|
4
4
|
end
|
5
|
-
require
|
5
|
+
require "view_component/engine"
|
6
6
|
|
7
7
|
module Avo
|
8
8
|
class Engine < ::Rails::Engine
|
@@ -13,26 +13,42 @@ module Avo
|
|
13
13
|
::Avo::App.boot
|
14
14
|
end
|
15
15
|
|
16
|
-
initializer
|
17
|
-
Rails.autoloaders.main.push_dir(Rails.root.join(
|
18
|
-
Rails.autoloaders.main.push_dir(Rails.root.join(
|
19
|
-
Rails.autoloaders.main.push_dir(Rails.root.join(
|
16
|
+
initializer "avo.autoload", before: :set_autoload_paths do |app|
|
17
|
+
Rails.autoloaders.main.push_dir(Rails.root.join("app", "avo", "filters"))
|
18
|
+
Rails.autoloaders.main.push_dir(Rails.root.join("app", "avo", "actions"))
|
19
|
+
Rails.autoloaders.main.push_dir(Rails.root.join("app", "avo", "resources"))
|
20
20
|
end
|
21
21
|
|
22
|
-
initializer
|
22
|
+
initializer "avo.init_fields" do |app|
|
23
23
|
# Init the fields
|
24
24
|
::Avo::App.init_fields
|
25
25
|
end
|
26
26
|
|
27
|
-
initializer
|
27
|
+
initializer "avo.reload_avo_files" do |app|
|
28
|
+
if Avo::IN_DEVELOPMENT && ENV["RELOAD_AVO_FILES"]
|
29
|
+
avo_root_path = Avo::Engine.root.to_s
|
30
|
+
# Register reloader
|
31
|
+
app.reloaders << app.config.file_watcher.new([], {
|
32
|
+
Avo::Engine.root.join("lib", "avo").to_s => ["rb"]
|
33
|
+
}) {}
|
34
|
+
|
35
|
+
# What to do on file change
|
36
|
+
config.to_prepare do
|
37
|
+
Dir.glob(avo_root_path + "/lib/avo/**/*.rb".to_s).each { |c| load c }
|
38
|
+
Avo::App.boot
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
initializer "webpacker.proxy" do |app|
|
28
44
|
app.config.debug_exception_response_format = :api
|
29
45
|
# app.config.logger = ::Logger.new(STDOUT)
|
30
46
|
|
31
47
|
insert_middleware = begin
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
48
|
+
Avo.webpacker.config.dev_server.present?
|
49
|
+
rescue
|
50
|
+
nil
|
51
|
+
end
|
36
52
|
|
37
53
|
if insert_middleware
|
38
54
|
app.middleware.insert_before(
|
@@ -45,8 +61,8 @@ module Avo
|
|
45
61
|
|
46
62
|
config.app_middleware.use(
|
47
63
|
Rack::Static,
|
48
|
-
urls: [
|
49
|
-
root: Avo::Engine.root.join(
|
64
|
+
urls: ["/avo-packs"],
|
65
|
+
root: Avo::Engine.root.join("public")
|
50
66
|
)
|
51
67
|
|
52
68
|
config.generators do |g|
|
@@ -3,14 +3,14 @@ module Avo
|
|
3
3
|
class BadgeField < BaseField
|
4
4
|
def initialize(name, **args, &block)
|
5
5
|
@defaults = {
|
6
|
-
partial_name:
|
6
|
+
partial_name: "badge-field"
|
7
7
|
}
|
8
8
|
|
9
9
|
super(name, **args, &block)
|
10
10
|
|
11
11
|
hide_on [:edit, :new]
|
12
12
|
|
13
|
-
default_options = {
|
13
|
+
default_options = {info: :info, success: :success, danger: :danger, warning: :warning}
|
14
14
|
@meta[:options] = args[:options].present? ? default_options.merge(args[:options]) : default_options
|
15
15
|
end
|
16
16
|
end
|
@@ -24,7 +24,7 @@ module Avo
|
|
24
24
|
attr_accessor :placeholder
|
25
25
|
attr_accessor :help
|
26
26
|
attr_accessor :default
|
27
|
-
attr_accessor :
|
27
|
+
attr_accessor :visible
|
28
28
|
attr_accessor :model
|
29
29
|
attr_accessor :resource
|
30
30
|
attr_accessor :view
|
@@ -34,6 +34,8 @@ module Avo
|
|
34
34
|
attr_accessor :panel_name
|
35
35
|
attr_accessor :link_to_resource
|
36
36
|
|
37
|
+
class_attribute :field_name_attribute
|
38
|
+
|
37
39
|
@meta = {}
|
38
40
|
|
39
41
|
def initialize(id, **args, &block)
|
@@ -42,14 +44,14 @@ module Avo
|
|
42
44
|
|
43
45
|
args = @defaults.merge(args).symbolize_keys
|
44
46
|
|
45
|
-
null_values = [nil,
|
47
|
+
null_values = [nil, "", *args[:null_values]]
|
46
48
|
# The field properties as a hash {property: default_value}
|
47
49
|
@field_properties = {
|
48
50
|
id: id,
|
49
51
|
name: id.to_s.humanize(keep_id_suffix: true),
|
50
52
|
translation_key: nil,
|
51
53
|
block: block,
|
52
|
-
partial_name:
|
54
|
+
partial_name: "field",
|
53
55
|
required: false,
|
54
56
|
readonly: false,
|
55
57
|
updatable: true,
|
@@ -63,9 +65,9 @@ module Avo
|
|
63
65
|
placeholder: id.to_s.humanize,
|
64
66
|
help: nil,
|
65
67
|
default: nil,
|
66
|
-
|
68
|
+
visible: true,
|
67
69
|
meta: {},
|
68
|
-
panel_name: nil
|
70
|
+
panel_name: nil
|
69
71
|
}
|
70
72
|
|
71
73
|
# Set the values in the following order
|
@@ -74,7 +76,7 @@ module Avo
|
|
74
76
|
# - field option
|
75
77
|
@field_properties.each do |name, default_value|
|
76
78
|
final_value = args[name.to_sym]
|
77
|
-
|
79
|
+
send("#{name}=", name != "null_values" && (final_value.nil? || !defined?(final_value)) ? default_value : final_value)
|
78
80
|
end
|
79
81
|
|
80
82
|
# Set the visibility
|
@@ -99,27 +101,35 @@ module Avo
|
|
99
101
|
self
|
100
102
|
end
|
101
103
|
|
104
|
+
def visible?
|
105
|
+
if visible.present? && visible.respond_to?(:call)
|
106
|
+
visible.call resource: resource
|
107
|
+
else
|
108
|
+
visible
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
102
112
|
def value
|
103
113
|
# Get model value
|
104
|
-
|
114
|
+
final_value = @model.send(id) if (model_or_class(@model) == "model") && @model.respond_to?(id)
|
105
115
|
|
106
|
-
if @view === :new
|
107
|
-
if default.present?
|
108
|
-
|
116
|
+
if (@view === :new) || @action.present?
|
117
|
+
final_value = if default.present? && default.respond_to?(:call)
|
118
|
+
default.call
|
109
119
|
else
|
110
|
-
|
120
|
+
default
|
111
121
|
end
|
112
122
|
end
|
113
123
|
|
114
124
|
# Run callback block if present
|
115
|
-
if computable
|
116
|
-
|
125
|
+
if computable && block.present?
|
126
|
+
final_value = block.call @model, @resource, @view, self
|
117
127
|
end
|
118
128
|
|
119
129
|
# Run the value through resolver if present
|
120
|
-
|
130
|
+
final_value = @format_using.call final_value if @format_using.present?
|
121
131
|
|
122
|
-
|
132
|
+
final_value
|
123
133
|
end
|
124
134
|
|
125
135
|
def fill_field(model, key, value)
|
@@ -131,18 +141,16 @@ module Avo
|
|
131
141
|
end
|
132
142
|
|
133
143
|
def partial_path_for(view)
|
134
|
-
return @custom_partials[view] if @custom_partials.present?
|
144
|
+
return @custom_partials[view] if @custom_partials.present? && @custom_partials[view].present?
|
135
145
|
|
136
146
|
"avo/fields/#{view}/#{partial_name}"
|
137
147
|
end
|
138
148
|
|
139
149
|
# Try to see if the field has a different database ID than it's name
|
140
150
|
def database_id(model)
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
id
|
145
|
-
end
|
151
|
+
foreign_key
|
152
|
+
rescue
|
153
|
+
id
|
146
154
|
end
|
147
155
|
|
148
156
|
def has_own_panel?
|
@@ -158,7 +166,7 @@ module Avo
|
|
158
166
|
end
|
159
167
|
|
160
168
|
def component_name(view = :index)
|
161
|
-
"Avo::#{view.to_s.classify}::Fields::#{partial_name.gsub(
|
169
|
+
"Avo::#{view.to_s.classify}::Fields::#{partial_name.gsub("-field", "").underscore.camelize}FieldComponent"
|
162
170
|
end
|
163
171
|
|
164
172
|
def model_errors
|
@@ -168,17 +176,18 @@ module Avo
|
|
168
176
|
end
|
169
177
|
|
170
178
|
def type
|
171
|
-
self.class.name.demodulize.to_s.underscore
|
179
|
+
self.class.name.demodulize.to_s.underscore.gsub("_field", "")
|
172
180
|
end
|
173
181
|
|
174
182
|
private
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
183
|
+
|
184
|
+
def model_or_class(model)
|
185
|
+
if model.instance_of?(String)
|
186
|
+
"class"
|
187
|
+
else
|
188
|
+
"model"
|
181
189
|
end
|
190
|
+
end
|
182
191
|
end
|
183
192
|
end
|
184
193
|
end
|
@@ -3,13 +3,13 @@ module Avo
|
|
3
3
|
class BelongsToField < BaseField
|
4
4
|
def initialize(name, **args, &block)
|
5
5
|
@defaults = {
|
6
|
-
partial_name:
|
7
|
-
placeholder: I18n.t(
|
6
|
+
partial_name: "belongs-to-field",
|
7
|
+
placeholder: I18n.t("avo.choose_an_option")
|
8
8
|
}
|
9
9
|
|
10
10
|
super(name, **args, &block)
|
11
11
|
|
12
|
-
@meta[:searchable] = args[:searchable] == true
|
12
|
+
@meta[:searchable] = args[:searchable] == true
|
13
13
|
@meta[:relation_method] = name.to_s.parameterize.underscore
|
14
14
|
end
|
15
15
|
|
@@ -28,7 +28,7 @@ module Avo
|
|
28
28
|
|
29
29
|
def foreign_key
|
30
30
|
if @model.present?
|
31
|
-
if @model.
|
31
|
+
if @model.instance_of?(Class)
|
32
32
|
@model.reflections[@meta[:relation_method]].foreign_key
|
33
33
|
else
|
34
34
|
@model.class.reflections[@meta[:relation_method]].foreign_key
|
@@ -51,15 +51,16 @@ module Avo
|
|
51
51
|
end
|
52
52
|
|
53
53
|
private
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
54
|
+
|
55
|
+
def target_resource
|
56
|
+
if @model._reflections[id.to_s].klass.present?
|
57
|
+
App.get_resource_by_model_name @model._reflections[id.to_s].klass.to_s
|
58
|
+
elsif @model._reflections[id.to_s].options[:class_name].present?
|
59
|
+
App.get_resource_by_model_name @model._reflections[id.to_s].options[:class_name]
|
60
|
+
else
|
61
|
+
App.get_resource_by_name id.to_s
|
62
62
|
end
|
63
|
+
end
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
@@ -6,8 +6,8 @@ module Avo
|
|
6
6
|
|
7
7
|
def initialize(name, **args, &block)
|
8
8
|
@defaults = {
|
9
|
-
partial_name:
|
10
|
-
computable: true
|
9
|
+
partial_name: "boolean-field",
|
10
|
+
computable: true
|
11
11
|
}
|
12
12
|
|
13
13
|
super(name, **args, &block)
|
@@ -25,11 +25,11 @@ module Avo
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def truthy_values
|
28
|
-
[
|
28
|
+
["true", "1", @true_value]
|
29
29
|
end
|
30
30
|
|
31
31
|
def falsy_values
|
32
|
-
[
|
32
|
+
["false", "0", @false_value]
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -5,8 +5,8 @@ module Avo
|
|
5
5
|
|
6
6
|
def initialize(name, **args, &block)
|
7
7
|
@defaults = {
|
8
|
-
partial_name:
|
9
|
-
computable: true
|
8
|
+
partial_name: "boolean-group-field",
|
9
|
+
computable: true
|
10
10
|
}
|
11
11
|
|
12
12
|
super(name, **args, &block)
|
@@ -15,7 +15,7 @@ module Avo
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_permitted_param
|
18
|
-
["#{id}": []
|
18
|
+
["#{id}": []]
|
19
19
|
end
|
20
20
|
|
21
21
|
def fill_field(model, key, value)
|
@@ -10,16 +10,16 @@ module Avo
|
|
10
10
|
|
11
11
|
def initialize(name, **args, &block)
|
12
12
|
@defaults = {
|
13
|
-
partial_name:
|
13
|
+
partial_name: "code-field"
|
14
14
|
}
|
15
15
|
|
16
16
|
hide_on :index
|
17
17
|
|
18
18
|
super(name, **args, &block)
|
19
19
|
|
20
|
-
@language = args[:language].present? ? args[:language].to_s :
|
21
|
-
@theme = args[:theme].present? ? args[:theme].to_s :
|
22
|
-
@height = args[:height].present? ? args[:height].to_s :
|
20
|
+
@language = args[:language].present? ? args[:language].to_s : "javascript"
|
21
|
+
@theme = args[:theme].present? ? args[:theme].to_s : "material-darker"
|
22
|
+
@height = args[:height].present? ? args[:height].to_s : "auto"
|
23
23
|
@tab_size = args[:tab_size].present? ? args[:tab_size] : 2
|
24
24
|
@indent_with_tabs = args[:indent_with_tabs].present? ? args[:indent_with_tabs] : false
|
25
25
|
@line_wrapping = args[:line_wrapping].present? ? args[:line_wrapping] : true
|
@@ -6,8 +6,8 @@ module Avo
|
|
6
6
|
|
7
7
|
def initialize(name, **args, &block)
|
8
8
|
@defaults = {
|
9
|
-
partial_name:
|
10
|
-
placeholder: I18n.t(
|
9
|
+
partial_name: "country-field",
|
10
|
+
placeholder: I18n.t("avo.choose_a_country")
|
11
11
|
}
|
12
12
|
|
13
13
|
super(name, **args, &block)
|
@@ -3,8 +3,8 @@ module Avo
|
|
3
3
|
class CurrencyField < BaseField
|
4
4
|
def initialize(name, **args, &block)
|
5
5
|
@defaults = {
|
6
|
-
partial_name:
|
7
|
-
computable: true
|
6
|
+
partial_name: "currency-field",
|
7
|
+
computable: true
|
8
8
|
}
|
9
9
|
|
10
10
|
super(name, **args, &block)
|
@@ -16,7 +16,7 @@ module Avo
|
|
16
16
|
def hydrate_field(fields, model, resource, view)
|
17
17
|
{
|
18
18
|
currency: @currency,
|
19
|
-
locale: @locale
|
19
|
+
locale: @locale
|
20
20
|
}
|
21
21
|
end
|
22
22
|
end
|