avo 1.3.5 → 1.4.3
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.lock +3 -3
- data/README.md +1 -0
- data/app/components/avo/fields/badge_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/badge_field/index_component.rb +4 -0
- data/app/components/avo/fields/badge_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/badge_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/belongs_to_field_component.html.erb → fields/belongs_to_field/edit_component.html.erb} +0 -0
- data/app/components/avo/{edit/fields/belongs_to_field_component.rb → fields/belongs_to_field/edit_component.rb} +1 -1
- data/app/components/avo/{index/fields/belongs_to_field_component.html.erb → fields/belongs_to_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/belongs_to_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/belongs_to_field_component.html.erb → fields/belongs_to_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/belongs_to_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/boolean_field_component.html.erb → fields/boolean_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/boolean_field/edit_component.rb +4 -0
- data/app/components/avo/fields/boolean_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/boolean_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/boolean_field_component.html.erb → fields/boolean_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/boolean_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/boolean_group_field_component.html.erb → fields/boolean_group_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/boolean_group_field/edit_component.rb +4 -0
- data/app/components/avo/fields/boolean_group_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/boolean_group_field/index_component.rb +4 -0
- data/app/components/avo/fields/boolean_group_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/boolean_group_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/code_field_component.html.erb → fields/code_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/code_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/code_field_component.html.erb → fields/code_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/code_field/show_component.rb +4 -0
- data/app/components/avo/{common → fields/common}/badge_viewer_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/badge_viewer_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/boolean_check_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/boolean_check_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/boolean_group_component.html.erb +1 -1
- data/app/components/avo/{common → fields/common}/boolean_group_component.rb +1 -1
- data/app/components/avo/fields/common/files_list_viewer_component.html.erb +5 -0
- data/app/components/avo/{common → fields/common}/files_list_viewer_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/gravatar_viewer_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/gravatar_viewer_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/heading_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/heading_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/key_value_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/key_value_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/multiple_file_viewer_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/multiple_file_viewer_component.rb +1 -1
- data/app/components/avo/{common → fields/common}/single_file_viewer_component.html.erb +0 -0
- data/app/components/avo/{common → fields/common}/single_file_viewer_component.rb +1 -1
- data/app/components/avo/fields/common/status_viewer_component.html.erb +18 -0
- data/app/components/avo/{common → fields/common}/status_viewer_component.rb +1 -1
- data/app/components/avo/{edit/fields/country_field_component.html.erb → fields/country_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/country_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/country_field_component.html.erb → fields/country_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/country_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/country_field_component.html.erb → fields/country_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/country_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/date_field_component.html.erb → fields/date_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/date_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/date_field_component.html.erb → fields/date_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/date_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/date_field_component.html.erb → fields/date_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/date_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/date_time_field_component.html.erb → fields/date_time_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/date_time_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/date_time_field_component.html.erb → fields/date_time_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/date_time_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/date_time_field_component.html.erb → fields/date_time_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/date_time_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/field_component.rb → fields/edit_component.rb} +1 -1
- data/app/components/avo/{edit/fields/external_image_field_component.html.erb → fields/external_image_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/external_image_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/external_image_field_component.html.erb → fields/external_image_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/external_image_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/external_image_field_component.html.erb → fields/external_image_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/external_image_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/file_field_component.html.erb → fields/file_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/file_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/file_field_component.html.erb → fields/file_field/index_component.html.erb} +1 -1
- data/app/components/avo/fields/file_field/index_component.rb +4 -0
- data/app/components/avo/fields/file_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/file_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/files_field_component.html.erb → fields/files_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/files_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/files_field_component.html.erb → fields/files_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/files_field/index_component.rb +4 -0
- data/app/components/avo/fields/files_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/files_field/show_component.rb +4 -0
- data/app/components/avo/{index/fields/gravatar_field_component.html.erb → fields/gravatar_field/index_component.html.erb} +2 -2
- data/app/components/avo/fields/gravatar_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/gravatar_field_component.html.erb → fields/gravatar_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/gravatar_field/show_component.rb +4 -0
- data/app/components/avo/{show/fields/has_many_field_component.html.erb → fields/has_many_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/has_many_field/show_component.rb +4 -0
- data/app/components/avo/{index/fields/has_one_field_component.html.erb → fields/has_one_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/has_one_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/has_one_field_component.html.erb → fields/has_one_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/has_one_field/show_component.rb +5 -0
- data/app/components/avo/{show/fields/heading_field_component.html.erb → fields/heading_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/heading_field/edit_component.rb +4 -0
- data/app/components/avo/{edit/fields/heading_field_component.html.erb → fields/heading_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/heading_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/hidden_field_component.html.erb → fields/hidden_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/hidden_field/edit_component.rb +4 -0
- data/app/components/avo/{edit/fields/id_field_component.html.erb → fields/id_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/id_field/edit_component.rb +4 -0
- data/app/components/avo/fields/id_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/id_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/id_field_component.html.erb → fields/id_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/id_field/show_component.rb +4 -0
- data/app/components/avo/fields/index_component.rb +20 -0
- data/app/components/avo/{edit/fields/key_value_field_component.html.erb → fields/key_value_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/key_value_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/key_value_field_component.html.erb → fields/key_value_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/key_value_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/markdown_field_component.html.erb → fields/markdown_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/markdown_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/markdown_field_component.html.erb → fields/markdown_field/show_component.html.erb} +1 -1
- data/app/components/avo/fields/markdown_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/number_field_component.html.erb → fields/number_field/edit_component.html.erb} +3 -3
- data/app/components/avo/fields/number_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/number_field_component.html.erb → fields/number_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/number_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/number_field_component.html.erb → fields/number_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/number_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/password_field_component.html.erb → fields/password_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/password_field/edit_component.rb +4 -0
- data/app/components/avo/fields/progress_bar_field/edit_component.html.erb +26 -0
- data/app/components/avo/fields/progress_bar_field/edit_component.rb +4 -0
- data/app/components/avo/fields/progress_bar_field/index_component.html.erb +8 -0
- data/app/components/avo/fields/progress_bar_field/index_component.rb +4 -0
- data/app/components/avo/fields/progress_bar_field/show_component.html.erb +8 -0
- data/app/components/avo/fields/progress_bar_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/select_field_component.html.erb → fields/select_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/select_field/edit_component.rb +4 -0
- data/app/components/avo/{index/fields/select_field_component.html.erb → fields/select_field/index_component.html.erb} +0 -0
- data/app/components/avo/fields/select_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/select_field_component.html.erb → fields/select_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/select_field/show_component.rb +4 -0
- data/app/components/avo/{show/fields/field_component.rb → fields/show_component.rb} +1 -1
- data/app/components/avo/{edit/fields/status_field_component.html.erb → fields/status_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/status_field/edit_component.rb +4 -0
- data/app/components/avo/fields/status_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/status_field/index_component.rb +4 -0
- data/app/components/avo/fields/status_field/show_component.html.erb +3 -0
- data/app/components/avo/fields/status_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/text_field_component.html.erb → fields/text_field/edit_component.html.erb} +0 -0
- data/app/components/avo/fields/text_field/edit_component.rb +4 -0
- data/app/components/avo/fields/text_field/index_component.html.erb +3 -0
- data/app/components/avo/fields/text_field/index_component.rb +4 -0
- data/app/components/avo/{show/fields/text_field_component.html.erb → fields/text_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/text_field/show_component.rb +4 -0
- data/app/components/avo/{edit/fields/textarea_field_component.html.erb → fields/textarea_field/edit_component.html.erb} +1 -1
- data/app/components/avo/fields/textarea_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/textarea_field_component.html.erb → fields/textarea_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/textarea_field/show_component.rb +4 -0
- data/app/components/avo/fields/trix_field/edit_component.html.erb +19 -0
- data/app/components/avo/fields/trix_field/edit_component.rb +4 -0
- data/app/components/avo/{show/fields/trix_field_component.html.erb → fields/trix_field/show_component.html.erb} +0 -0
- data/app/components/avo/fields/trix_field/show_component.rb +4 -0
- data/app/components/avo/index/resource_controls_component.html.erb +2 -3
- data/app/components/avo/index/table_row_component.html.erb +1 -1
- data/app/components/avo/panel_component.html.erb +1 -1
- data/app/components/avo/panel_component.rb +4 -4
- data/app/components/avo/views/resource_edit_component.html.erb +2 -2
- data/app/components/avo/views/resource_index_component.html.erb +3 -3
- data/app/components/avo/views/resource_new_component.html.erb +2 -2
- data/app/components/avo/views/resource_show_component.html.erb +5 -5
- data/app/controllers/avo/application_controller.rb +5 -1
- data/app/controllers/avo/attachments_controller.rb +14 -3
- data/app/controllers/avo/base_controller.rb +26 -2
- data/app/controllers/avo/home_controller.rb +1 -1
- data/app/controllers/avo/search_controller.rb +1 -1
- data/app/helpers/avo/resources_helper.rb +0 -44
- data/app/packs/entrypoints/application.css +1 -0
- data/app/packs/entrypoints/application.js +0 -1
- data/app/packs/js/controllers/fields/date_field_controller.js +1 -1
- data/app/packs/js/controllers/fields/key_value_controller.js +0 -1
- data/app/packs/js/controllers/fields/trix_field_controller.js +121 -0
- data/app/packs/stylesheets/components/progress.css +13 -0
- data/app/packs/stylesheets/components/status.css +31 -20
- data/app/packs/svgs/check-circle-sm.svg +3 -0
- data/app/packs/svgs/x-circle-sm.svg +3 -0
- data/app/views/avo/actions/show.html.erb +1 -1
- data/app/views/avo/partials/_javascript.html.erb +3 -1
- data/app/views/avo/partials/_profile_dropdown.html.erb +19 -0
- data/app/views/layouts/avo/application.html.erb +6 -3
- data/config/routes.rb +4 -0
- data/config/webpacker.yml +2 -2
- data/db/factories.rb +3 -0
- data/db/migrate/20210421064037_add_color_to_teams.rb +5 -0
- data/db/migrate/20210423075924_add_progress_to_projects.rb +5 -0
- data/lib/avo/app.rb +9 -20
- data/lib/avo/base_resource.rb +9 -1
- data/lib/avo/configuration.rb +1 -1
- data/lib/avo/engine.rb +1 -0
- data/lib/avo/fields/badge_field.rb +4 -6
- data/lib/avo/fields/base_field.rb +62 -83
- data/lib/avo/fields/belongs_to_field.rb +11 -11
- data/lib/avo/fields/boolean_field.rb +2 -7
- data/lib/avo/fields/boolean_group_field.rb +2 -7
- data/lib/avo/fields/code_field.rb +3 -7
- data/lib/avo/fields/country_field.rb +3 -6
- data/lib/avo/fields/currency_field.rb +4 -13
- data/lib/avo/fields/date_field.rb +2 -8
- data/lib/avo/fields/date_time_field.rb +2 -3
- data/lib/avo/fields/external_image_field.rb +3 -7
- data/lib/avo/fields/file_field.rb +4 -8
- data/lib/avo/fields/files_field.rb +6 -8
- data/lib/avo/fields/gravatar_field.rb +6 -9
- data/lib/avo/fields/has_and_belongs_to_many_field.rb +6 -7
- data/lib/avo/fields/has_many_field.rb +3 -9
- data/lib/avo/fields/has_one_field.rb +3 -8
- data/lib/avo/fields/heading_field.rb +10 -8
- data/lib/avo/fields/hidden_field.rb +2 -6
- data/lib/avo/fields/id_field.rb +5 -17
- data/lib/avo/fields/key_value_field.rb +4 -6
- data/lib/avo/fields/markdown_field.rb +3 -5
- data/lib/avo/fields/number_field.rb +8 -11
- data/lib/avo/fields/password_field.rb +2 -6
- data/lib/avo/fields/progress_bar_field.rb +19 -0
- data/lib/avo/fields/select_field.rb +13 -12
- data/lib/avo/fields/status_field.rb +2 -6
- data/lib/avo/fields/text_field.rb +3 -6
- data/lib/avo/fields/textarea_field.rb +4 -7
- data/lib/avo/fields/trix_field.rb +7 -7
- data/lib/avo/fields_collector.rb +47 -11
- data/lib/avo/licensing/pro_license.rb +2 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/eject_generator.rb +1 -0
- data/lib/generators/avo/field_generator.rb +17 -0
- data/lib/generators/avo/filter_generator.rb +1 -1
- data/lib/generators/avo/templates/field/%singular_name%_field.rb.tt +5 -0
- data/lib/generators/avo/templates/field/components/edit_component.html.erb.tt +6 -0
- data/lib/generators/avo/templates/field/components/edit_component.rb.tt +4 -0
- data/lib/generators/avo/templates/field/components/index_component.html.erb.tt +3 -0
- data/lib/generators/avo/templates/field/components/index_component.rb.tt +4 -0
- data/lib/generators/avo/templates/field/components/show_component.html.erb.tt +3 -0
- data/lib/generators/avo/templates/field/components/show_component.rb.tt +4 -0
- data/lib/generators/avo/templates/tool/view.tt +1 -1
- data/public/avo-packs/css/{application-0b91a712.css → application-68691c73.css} +132 -49
- data/public/avo-packs/css/application-68691c73.css.br +0 -0
- data/public/avo-packs/css/application-68691c73.css.gz +0 -0
- data/public/avo-packs/css/application-68691c73.css.map +1 -0
- data/public/avo-packs/css/application-68691c73.css.map.br +0 -0
- data/public/avo-packs/css/application-68691c73.css.map.gz +0 -0
- data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js +26 -0
- data/public/avo-packs/js/{application-c2a8a64ca8f5d2805d79.js.LICENSE.txt → application-6a0b9e58526ae6bef242.js.LICENSE.txt} +0 -0
- data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.br +0 -0
- data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.gz +0 -0
- data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.map +1 -0
- data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.map.br +0 -0
- data/public/avo-packs/js/application-6a0b9e58526ae6bef242.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +15 -15
- metadata +186 -165
- data/app/components/avo/common/files_list_viewer_component.html.erb +0 -5
- data/app/components/avo/common/status_viewer_component.html.erb +0 -10
- data/app/components/avo/edit/fields/boolean_field_component.rb +0 -4
- data/app/components/avo/edit/fields/boolean_group_field_component.rb +0 -4
- data/app/components/avo/edit/fields/code_field_component.rb +0 -4
- data/app/components/avo/edit/fields/country_field_component.rb +0 -4
- data/app/components/avo/edit/fields/date_field_component.rb +0 -4
- data/app/components/avo/edit/fields/date_time_field_component.rb +0 -4
- data/app/components/avo/edit/fields/external_image_field_component.rb +0 -4
- data/app/components/avo/edit/fields/file_field_component.rb +0 -4
- data/app/components/avo/edit/fields/files_field_component.rb +0 -4
- data/app/components/avo/edit/fields/heading_field_component.rb +0 -4
- data/app/components/avo/edit/fields/hidden_field_component.rb +0 -4
- data/app/components/avo/edit/fields/id_field_component.rb +0 -4
- data/app/components/avo/edit/fields/key_value_field_component.rb +0 -4
- data/app/components/avo/edit/fields/markdown_field_component.rb +0 -4
- data/app/components/avo/edit/fields/number_field_component.rb +0 -4
- data/app/components/avo/edit/fields/password_field_component.rb +0 -4
- data/app/components/avo/edit/fields/select_field_component.rb +0 -4
- data/app/components/avo/edit/fields/status_field_component.rb +0 -4
- data/app/components/avo/edit/fields/text_field_component.rb +0 -4
- data/app/components/avo/edit/fields/textarea_field_component.rb +0 -4
- data/app/components/avo/edit/fields/trix_field_component.html.erb +0 -11
- data/app/components/avo/edit/fields/trix_field_component.rb +0 -4
- data/app/components/avo/index/fields/badge_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/badge_field_component.rb +0 -4
- data/app/components/avo/index/fields/belongs_to_field_component.rb +0 -4
- data/app/components/avo/index/fields/boolean_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/boolean_field_component.rb +0 -4
- data/app/components/avo/index/fields/boolean_group_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/boolean_group_field_component.rb +0 -4
- data/app/components/avo/index/fields/country_field_component.rb +0 -4
- data/app/components/avo/index/fields/date_field_component.rb +0 -4
- data/app/components/avo/index/fields/date_time_field_component.rb +0 -4
- data/app/components/avo/index/fields/external_image_field_component.rb +0 -4
- data/app/components/avo/index/fields/field_component.html.erb +0 -1
- data/app/components/avo/index/fields/field_component.rb +0 -11
- data/app/components/avo/index/fields/file_field_component.rb +0 -4
- data/app/components/avo/index/fields/files_field_component.rb +0 -4
- data/app/components/avo/index/fields/gravatar_field_component.rb +0 -4
- data/app/components/avo/index/fields/has_one_field_component.rb +0 -4
- data/app/components/avo/index/fields/id_field_component.html.erb +0 -10
- data/app/components/avo/index/fields/id_field_component.rb +0 -4
- data/app/components/avo/index/fields/number_field_component.rb +0 -4
- data/app/components/avo/index/fields/select_field_component.rb +0 -4
- data/app/components/avo/index/fields/status_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/status_field_component.rb +0 -4
- data/app/components/avo/index/fields/text_field_component.html.erb +0 -3
- data/app/components/avo/index/fields/text_field_component.rb +0 -4
- data/app/components/avo/show/fields/badge_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/badge_field_component.rb +0 -4
- data/app/components/avo/show/fields/belongs_to_field_component.rb +0 -4
- data/app/components/avo/show/fields/boolean_field_component.rb +0 -4
- data/app/components/avo/show/fields/boolean_group_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/boolean_group_field_component.rb +0 -4
- data/app/components/avo/show/fields/code_field_component.rb +0 -4
- data/app/components/avo/show/fields/country_field_component.rb +0 -4
- data/app/components/avo/show/fields/date_field_component.rb +0 -4
- data/app/components/avo/show/fields/date_time_field_component.rb +0 -4
- data/app/components/avo/show/fields/external_image_field_component.rb +0 -4
- data/app/components/avo/show/fields/file_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/file_field_component.rb +0 -4
- data/app/components/avo/show/fields/files_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/files_field_component.rb +0 -4
- data/app/components/avo/show/fields/gravatar_field_component.rb +0 -4
- data/app/components/avo/show/fields/has_many_field_component.rb +0 -4
- data/app/components/avo/show/fields/has_one_field_component.rb +0 -5
- data/app/components/avo/show/fields/heading_field_component.rb +0 -4
- data/app/components/avo/show/fields/id_field_component.rb +0 -4
- data/app/components/avo/show/fields/key_value_field_component.rb +0 -4
- data/app/components/avo/show/fields/markdown_field_component.rb +0 -4
- data/app/components/avo/show/fields/number_field_component.rb +0 -4
- data/app/components/avo/show/fields/select_field_component.rb +0 -4
- data/app/components/avo/show/fields/status_field_component.html.erb +0 -3
- data/app/components/avo/show/fields/status_field_component.rb +0 -4
- data/app/components/avo/show/fields/text_field_component.rb +0 -4
- data/app/components/avo/show/fields/textarea_field_component.rb +0 -4
- data/app/components/avo/show/fields/trix_field_component.rb +0 -4
- data/public/avo-packs/css/application-0b91a712.css.br +0 -0
- data/public/avo-packs/css/application-0b91a712.css.gz +0 -0
- data/public/avo-packs/css/application-0b91a712.css.map +0 -1
- data/public/avo-packs/css/application-0b91a712.css.map.br +0 -0
- data/public/avo-packs/css/application-0b91a712.css.map.gz +0 -0
- data/public/avo-packs/js/application-c2a8a64ca8f5d2805d79.js +0 -26
- data/public/avo-packs/js/application-c2a8a64ca8f5d2805d79.js.br +0 -0
- data/public/avo-packs/js/application-c2a8a64ca8f5d2805d79.js.gz +0 -0
- data/public/avo-packs/js/application-c2a8a64ca8f5d2805d79.js.map +0 -1
- data/public/avo-packs/js/application-c2a8a64ca8f5d2805d79.js.map.br +0 -0
- data/public/avo-packs/js/application-c2a8a64ca8f5d2805d79.js.map.gz +0 -0
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal, full_width: true do %>
|
2
|
+
<div
|
3
|
+
data-controller="trix-field"
|
4
|
+
data-trix-field-target="controller"
|
5
|
+
data-resource-name="<%= @resource.model_class.model_name.route_key %>"
|
6
|
+
data-resource-id="<%= @resource.model.id %>"
|
7
|
+
data-attachments-disabled="<%= @field.attachments_disabled %>"
|
8
|
+
data-attachment-key="<%= @field.attachment_key %>"
|
9
|
+
>
|
10
|
+
<% trix_id = "trix_#{@resource.name.underscore}_#{@field.id}" %>
|
11
|
+
<trix-editor data-trix-field-target="editor" input="<%= trix_id %>" placeholder="<%= @field.placeholder %>"><%== @field.value %></trix-editor>
|
12
|
+
<%= @form.text_area @field.id,
|
13
|
+
id: trix_id,
|
14
|
+
class: helpers.input_classes('w-full hidden', has_error: (@resource.model.present? and @resource.model.errors.include?(@field.id))),
|
15
|
+
placeholder: @field.placeholder,
|
16
|
+
disabled: @field.readonly
|
17
|
+
%>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
File without changes
|
@@ -36,9 +36,8 @@
|
|
36
36
|
'tippy': 'tooltip',
|
37
37
|
}
|
38
38
|
%>
|
39
|
-
<%= hidden_field_tag :turbo_frame, params[:turbo_frame], id: "
|
40
|
-
<%= hidden_field_tag :referrer, request.fullpath, id: "
|
41
|
-
<%#= hidden_field_tag :referrer, request.fullpath, id: "referrer_detach_#{@resource.model.id}" if params[:via_resource_class] %>
|
39
|
+
<%= hidden_field_tag :turbo_frame, params[:turbo_frame], id: "turbo_frame_detach_#{@resource.model.id}" if params[:turbo_frame] %>
|
40
|
+
<%= hidden_field_tag :referrer, request.fullpath, id: "referrer_detach_#{@resource.model.id}" if params[:turbo_frame] %>
|
42
41
|
<% end %>
|
43
42
|
<% end %>
|
44
43
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
</div>
|
9
9
|
</td>
|
10
10
|
<% @resource.get_fields(reflection: @reflection).each_with_index do |field, index| %>
|
11
|
-
<%=
|
11
|
+
<%= render field.component_for_view(:index).new(field: field, resource: @resource, index: index, parent_model: @parent_model) %>
|
12
12
|
<% end %>
|
13
13
|
<td class="text-right whitespace-nowrap px-2">
|
14
14
|
<div class="flex items-center justify-end flex-grow-0 h-full w-full">
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div <%== data_attributes %>>
|
2
2
|
<div class="mb-6">
|
3
3
|
<div>
|
4
|
-
<% if
|
4
|
+
<% if display_breadcrumbs? %>
|
5
5
|
<div class="breadcrumbs">
|
6
6
|
<%= helpers.render_breadcrumbs(separator: helpers.svg('chevron-right', class: 'inline-block h-3 stroke-current relative top-[-1px] ml-1' )) if Avo.configuration.display_breadcrumbs %>
|
7
7
|
</div>
|
@@ -6,11 +6,11 @@ class Avo::PanelComponent < ViewComponent::Base
|
|
6
6
|
renders_one :bare_content
|
7
7
|
renders_one :footer
|
8
8
|
|
9
|
-
def initialize(title: nil, body_classes: nil, data: {},
|
9
|
+
def initialize(title: nil, body_classes: nil, data: {}, display_breadcrumbs: false)
|
10
10
|
@title = title
|
11
11
|
@body_classes = body_classes
|
12
12
|
@data = data
|
13
|
-
@
|
13
|
+
@display_breadcrumbs = display_breadcrumbs
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -23,7 +23,7 @@ class Avo::PanelComponent < ViewComponent::Base
|
|
23
23
|
end.join
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
@
|
26
|
+
def display_breadcrumbs?
|
27
|
+
@display_breadcrumbs
|
28
28
|
end
|
29
29
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<%= form_with model: @resource.model, url: helpers.resource_path(@resource.model), method: :put, multipart: true do |form| %>
|
4
4
|
<%= hidden_field_tag :referrer, back_path if params[:via_resource_class] %>
|
5
5
|
|
6
|
-
<%= render Avo::PanelComponent.new(title: resource_panel[:name]) do |c| %>
|
6
|
+
<%= render Avo::PanelComponent.new(title: resource_panel[:name], display_breadcrumbs: true) do |c| %>
|
7
7
|
<% c.tools do %>
|
8
8
|
<div class="flex justify-end space-x-2">
|
9
9
|
<%= a_link back_path do %>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
<% c.body do %>
|
22
22
|
<% @resource.get_fields.each_with_index do |field, index| %>
|
23
|
-
<%=
|
23
|
+
<%= render field.component_for_view(:edit).new(field: field, resource: @resource, index: index, form: form) unless field.computed %>
|
24
24
|
<% end %>
|
25
25
|
<% end %>
|
26
26
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render Avo::PanelComponent.new
|
1
|
+
<%= render Avo::PanelComponent.new(title: title, body_classes: 'py-4', data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %>
|
2
2
|
<% c.tools do %>
|
3
3
|
<%= render 'actions' if @actions.present? %>
|
4
4
|
|
@@ -50,8 +50,8 @@
|
|
50
50
|
<% end %>
|
51
51
|
<% end %>
|
52
52
|
|
53
|
-
<%
|
54
|
-
<%
|
53
|
+
<% c.bare_content do %>
|
54
|
+
<% if view_type.to_sym == :grid %>
|
55
55
|
<%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
|
56
56
|
|
57
57
|
<div class="bg-white rounded-xl shadow-xl mt-8 py-6">
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div>
|
2
2
|
<% @resource.panels.each do |resource_panel| %>
|
3
3
|
<%= form_with model: @resource.model, url: helpers.resources_path(@resource.model, via_relation_class: params[:via_relation_class], via_resource_id: params[:via_resource_id]), local: true, multipart: true do |form| %>
|
4
|
-
<%= render Avo::PanelComponent.new(title: resource_panel[:name]) do |c| %>
|
4
|
+
<%= render Avo::PanelComponent.new(title: resource_panel[:name], display_breadcrumbs: true) do |c| %>
|
5
5
|
<% c.tools do %>
|
6
6
|
<div class="flex justify-end space-x-2">
|
7
7
|
<%= a_link back_path do %>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
<% c.body do %>
|
18
18
|
<% @resource.get_fields.each_with_index do |field, index| %>
|
19
|
-
<%=
|
19
|
+
<%= render field.component_for_view(:edit).new(field: field, resource: @resource, index: index, form: form) unless field.computed %>
|
20
20
|
<% end %>
|
21
21
|
<% end %>
|
22
22
|
<% end %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
data-selected-resources="[<%= @resource.model.id %>]"
|
4
4
|
>
|
5
5
|
<% @resource.panels.each do |resource_panel| %>
|
6
|
-
<%= render Avo::PanelComponent.new(title: resource_panel[:name],
|
6
|
+
<%= render Avo::PanelComponent.new(title: resource_panel[:name], display_breadcrumbs: @reflection.blank?) do |c| %>
|
7
7
|
<% c.tools do %>
|
8
8
|
<% if resource_panel[:name] == @resource.default_panel_name %>
|
9
9
|
<%= render 'actions' %>
|
@@ -47,7 +47,7 @@
|
|
47
47
|
<% c.body do %>
|
48
48
|
<% if fields_by_panel[resource_panel[:name]].present? %>
|
49
49
|
<% fields_by_panel[resource_panel[:name]].each_with_index do |field, index| %>
|
50
|
-
<%=
|
50
|
+
<%= render field.component_for_view(:show).new(field: field, resource: @resource, index: index) %>
|
51
51
|
<% end %>
|
52
52
|
<% end %>
|
53
53
|
<% end %>
|
@@ -57,19 +57,19 @@
|
|
57
57
|
<% if @reflection.blank? %>
|
58
58
|
<% if has_one_panels.present? %>
|
59
59
|
<% has_one_panels.each_with_index do |field, index| %>
|
60
|
-
<%=
|
60
|
+
<%= render field.component_for_view(:show).new(field: field, resource: @resource, index: index) %>
|
61
61
|
<% end %>
|
62
62
|
<% end %>
|
63
63
|
|
64
64
|
<% if has_many_panels.present? %>
|
65
65
|
<% has_many_panels.each_with_index do |field, index| %>
|
66
|
-
<%=
|
66
|
+
<%= render field.component_for_view(:show).new(field: field, resource: @resource, index: index) %>
|
67
67
|
<% end %>
|
68
68
|
<% end %>
|
69
69
|
|
70
70
|
<% if has_as_belongs_to_many_panels.present? %>
|
71
71
|
<% has_as_belongs_to_many_panels.each_with_index do |field, index| %>
|
72
|
-
<%=
|
72
|
+
<%= render field.component_for_view(:show).new(field: field, resource: @resource, index: index) %>
|
73
73
|
<% end %>
|
74
74
|
<% end %>
|
75
75
|
<% end %>
|
@@ -42,7 +42,7 @@ module Avo
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def check_avo_license
|
45
|
-
unless on_root_path || on_resources_path
|
45
|
+
unless on_root_path || on_resources_path || on_api_path
|
46
46
|
if @license.invalid? || @license.lacks(:custom_tools)
|
47
47
|
if Rails.env.development?
|
48
48
|
@custom_tools_alert_visible = true
|
@@ -272,5 +272,9 @@ module Avo
|
|
272
272
|
def on_resources_path
|
273
273
|
request.original_url.match?(/.*\/#{Avo.configuration.namespace}\/resources\/.*/)
|
274
274
|
end
|
275
|
+
|
276
|
+
def on_api_path
|
277
|
+
request.original_url.match?(/.*\/#{Avo.configuration.namespace}\/avo_api\/.*/)
|
278
|
+
end
|
275
279
|
end
|
276
280
|
end
|
@@ -2,9 +2,20 @@ require_dependency "avo/application_controller"
|
|
2
2
|
|
3
3
|
module Avo
|
4
4
|
class AttachmentsController < ApplicationController
|
5
|
-
before_action :set_resource_name, only: :destroy
|
6
|
-
before_action :set_resource, only: :destroy
|
7
|
-
before_action :set_model, only: :destroy
|
5
|
+
before_action :set_resource_name, only: [:destroy, :create]
|
6
|
+
before_action :set_resource, only: [:destroy, :create]
|
7
|
+
before_action :set_model, only: [:destroy, :create]
|
8
|
+
|
9
|
+
def create
|
10
|
+
blob = ActiveStorage::Blob.create_and_upload! io: params[:file], filename: params[:filename]
|
11
|
+
|
12
|
+
@model.send(params[:attachment_key]).attach blob
|
13
|
+
|
14
|
+
render json: {
|
15
|
+
url: main_app.url_for(blob),
|
16
|
+
href: main_app.url_for(blob)
|
17
|
+
}
|
18
|
+
end
|
8
19
|
|
9
20
|
def show
|
10
21
|
end
|
@@ -53,7 +53,19 @@ module Avo
|
|
53
53
|
@resource = @resource.hydrate(model: @model, view: :show, user: _current_user, params: params)
|
54
54
|
|
55
55
|
@page_title = @resource.default_panel_name
|
56
|
-
|
56
|
+
|
57
|
+
# If we're accessing this resource via another resource add the parent to the breadcrumbs.
|
58
|
+
if params[:via_resource_class].present? && params[:via_resource_id].present?
|
59
|
+
via_resource = Avo::App.get_resource_by_model_name params[:via_resource_class]
|
60
|
+
via_model = via_resource.model_class.find params[:via_resource_id]
|
61
|
+
via_resource.hydrate model: via_model
|
62
|
+
|
63
|
+
add_breadcrumb via_resource.plural_name, resources_path(via_resource.model_class)
|
64
|
+
add_breadcrumb via_resource.model_title, resource_path(via_model)
|
65
|
+
else
|
66
|
+
add_breadcrumb resource_name.humanize, resources_path(@resource.model_class)
|
67
|
+
end
|
68
|
+
|
57
69
|
add_breadcrumb @resource.model_title
|
58
70
|
end
|
59
71
|
|
@@ -70,7 +82,19 @@ module Avo
|
|
70
82
|
@resource = @resource.hydrate(model: @model, view: :edit, user: _current_user)
|
71
83
|
|
72
84
|
@page_title = @resource.default_panel_name
|
73
|
-
|
85
|
+
|
86
|
+
# If we're accessing this resource via another resource add the parent to the breadcrumbs.
|
87
|
+
if params[:via_resource_class].present? && params[:via_resource_id].present?
|
88
|
+
via_resource = Avo::App.get_resource_by_model_name params[:via_resource_class]
|
89
|
+
via_model = via_resource.model_class.find params[:via_resource_id]
|
90
|
+
via_resource.hydrate model: via_model
|
91
|
+
|
92
|
+
add_breadcrumb via_resource.plural_name, resources_path(via_resource.model_class)
|
93
|
+
add_breadcrumb via_resource.model_title, resource_path(via_model)
|
94
|
+
else
|
95
|
+
add_breadcrumb resource_name.humanize, resources_path(@resource.model_class)
|
96
|
+
end
|
97
|
+
|
74
98
|
add_breadcrumb @resource.model_title, resource_path(@resource.model)
|
75
99
|
add_breadcrumb t("avo.edit").humanize
|
76
100
|
end
|
@@ -7,7 +7,7 @@ module Avo
|
|
7
7
|
redirect_to Avo.configuration.home_path
|
8
8
|
elsif !Rails.env.development?
|
9
9
|
@page_title = "Get started"
|
10
|
-
redirect_to resources_path Avo::App.
|
10
|
+
redirect_to resources_path Avo::App.resources.min_by { |resource| resource.route_key }.model_class
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -8,7 +8,7 @@ module Avo
|
|
8
8
|
@authorization.set_record(resource_model).authorize_action :index
|
9
9
|
resources = []
|
10
10
|
|
11
|
-
App.
|
11
|
+
App.resources
|
12
12
|
.select { |resource| resource.search.present? }
|
13
13
|
.select { |resource| AuthorizationService.authorize_action _current_user, resource.model, "index" }
|
14
14
|
.each do |resource_model|
|
@@ -14,50 +14,6 @@ module Avo
|
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
-
def index_field(field, index, resource)
|
18
|
-
component = field.component_name(:index)
|
19
|
-
|
20
|
-
if Object.const_defined? component
|
21
|
-
render component.safe_constantize.new(field: field, resource: resource, index: index)
|
22
|
-
else
|
23
|
-
render partial: field.partial_path_for(:index), locals: {
|
24
|
-
field: field,
|
25
|
-
index: index,
|
26
|
-
resource: resource
|
27
|
-
}
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def show_field(field, index, resource)
|
32
|
-
component = field.component_name(:show)
|
33
|
-
|
34
|
-
if Object.const_defined? component
|
35
|
-
render component.safe_constantize.new(field: field, resource: resource, index: index)
|
36
|
-
else
|
37
|
-
render partial: field.partial_path_for(:show), locals: {
|
38
|
-
field: field,
|
39
|
-
index: index,
|
40
|
-
resource: resource
|
41
|
-
}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def edit_field(field, index, resource, form, displayed_in_modal: false)
|
46
|
-
component = field.component_name(:edit)
|
47
|
-
|
48
|
-
if Object.const_defined? component
|
49
|
-
render component.safe_constantize.new(field: field, resource: resource, index: index, form: form, displayed_in_modal: displayed_in_modal)
|
50
|
-
else
|
51
|
-
render partial: field.partial_path_for(:edit), locals: {
|
52
|
-
field: field,
|
53
|
-
index: index,
|
54
|
-
resource: resource,
|
55
|
-
form: form,
|
56
|
-
displayed_in_modal: displayed_in_modal
|
57
|
-
}
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
17
|
def index_field_wrapper(**args, &block)
|
62
18
|
render Index::FieldWrapperComponent.new(**args) do
|
63
19
|
capture(&block)
|
@@ -18,6 +18,7 @@
|
|
18
18
|
|
19
19
|
@import './../stylesheets/components/status.css';
|
20
20
|
@import './../stylesheets/components/code.css';
|
21
|
+
@import './../stylesheets/components/progress.css';
|
21
22
|
@import './../stylesheets/tailwindcss/components.css';
|
22
23
|
|
23
24
|
@import './../stylesheets/tailwindcss/utilities.css';
|
@@ -2,7 +2,6 @@
|
|
2
2
|
import 'core-js/stable'
|
3
3
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
4
4
|
import 'regenerator-runtime/runtime'
|
5
|
-
import 'trix'
|
6
5
|
import * as Mousetrap from 'mousetrap'
|
7
6
|
import { Application } from 'stimulus'
|
8
7
|
import { Turbo } from '@hotwired/turbo-rails'
|
@@ -33,7 +33,7 @@ export default class extends Controller {
|
|
33
33
|
|
34
34
|
// enable timezone display
|
35
35
|
if (enableTime) {
|
36
|
-
currentValue = DateTime.fromISO(this.inputTarget.value, { zone: window.timezone })
|
36
|
+
currentValue = DateTime.fromISO(this.inputTarget.value, { zone: window.Avo.configuration.timezone })
|
37
37
|
currentValue = currentValue.setZone(this.inputTarget.dataset.timezone)
|
38
38
|
currentValue = currentValue.toISO()
|
39
39
|
|
@@ -0,0 +1,121 @@
|
|
1
|
+
import 'trix'
|
2
|
+
import { Controller } from 'stimulus'
|
3
|
+
import { castBoolean } from '@/js/helpers/cast_boolean'
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
static targets = ['editor', 'controller']
|
7
|
+
|
8
|
+
get resourceId() {
|
9
|
+
return this.controllerTarget.dataset.resourceId
|
10
|
+
}
|
11
|
+
|
12
|
+
get resourceName() {
|
13
|
+
return this.controllerTarget.dataset.resourceName
|
14
|
+
}
|
15
|
+
|
16
|
+
get attachmentKey() {
|
17
|
+
return this.controllerTarget.dataset.attachmentKey
|
18
|
+
}
|
19
|
+
|
20
|
+
get attachmentsDisabled() {
|
21
|
+
return castBoolean(this.controllerTarget.dataset.attachmentsDisabled)
|
22
|
+
}
|
23
|
+
|
24
|
+
get uploadUrl() {
|
25
|
+
return `${window.location.origin}${window.Avo.configuration.root_path}/avo_api/resources/${this.resourceName}/${this.resourceId}/attachments`
|
26
|
+
}
|
27
|
+
|
28
|
+
connect() {
|
29
|
+
if (this.attachmentsDisabled) {
|
30
|
+
// Remove the attachments button
|
31
|
+
this.controllerTarget.querySelector('.trix-button-group--file-tools').remove()
|
32
|
+
}
|
33
|
+
|
34
|
+
window.addEventListener('trix-file-accept', (event) => {
|
35
|
+
if (event.target === this.editorTarget) {
|
36
|
+
// Prevent file uploads for fields that have attachments disabled.
|
37
|
+
if (this.attachmentsDisabled) {
|
38
|
+
event.preventDefault()
|
39
|
+
window.toastr.warning('This field has attachments disabled.')
|
40
|
+
|
41
|
+
return
|
42
|
+
}
|
43
|
+
|
44
|
+
// Prevent file uploads for resources that haven't been saved yet.
|
45
|
+
if (this.resourceId === '') {
|
46
|
+
event.preventDefault()
|
47
|
+
window.toastr.warning("You can't upload files into the Trix editor until you save the resource.")
|
48
|
+
|
49
|
+
return
|
50
|
+
}
|
51
|
+
|
52
|
+
// Prevent file uploads for fields without an attachment key.
|
53
|
+
if (this.attachmentKey === '') {
|
54
|
+
event.preventDefault()
|
55
|
+
window.toastr.warning("You haven't set an <a href='https://google.com' class='!text-blue-700 underline'>attachment_key</a> to this Trix field.")
|
56
|
+
}
|
57
|
+
}
|
58
|
+
})
|
59
|
+
|
60
|
+
window.addEventListener('trix-attachment-add', (event) => {
|
61
|
+
if (event.target === this.editorTarget) {
|
62
|
+
if (event.attachment.file) {
|
63
|
+
this.uploadFileAttachment(event.attachment)
|
64
|
+
}
|
65
|
+
}
|
66
|
+
})
|
67
|
+
}
|
68
|
+
|
69
|
+
uploadFileAttachment(attachment) {
|
70
|
+
this.uploadFile(
|
71
|
+
attachment.file,
|
72
|
+
(progress) => attachment.setUploadProgress(progress),
|
73
|
+
(attributes) => attachment.setAttributes(attributes),
|
74
|
+
)
|
75
|
+
}
|
76
|
+
|
77
|
+
uploadFile(file, progressCallback, successCallback) {
|
78
|
+
const formData = this.createFormData(file)
|
79
|
+
const xhr = new XMLHttpRequest()
|
80
|
+
|
81
|
+
xhr.open('POST', this.uploadUrl, true)
|
82
|
+
|
83
|
+
xhr.setRequestHeader('X-CSRF-Token', document.querySelector('meta[name="csrf-token"]').content)
|
84
|
+
|
85
|
+
xhr.upload.addEventListener('progress', (event) => {
|
86
|
+
// eslint-disable-next-line no-mixed-operators
|
87
|
+
const progress = event.loaded / event.total * 100
|
88
|
+
progressCallback(progress)
|
89
|
+
})
|
90
|
+
|
91
|
+
xhr.addEventListener('load', () => {
|
92
|
+
if (xhr.status === 200) {
|
93
|
+
let response
|
94
|
+
try {
|
95
|
+
response = JSON.parse(xhr.response)
|
96
|
+
} catch (error) {
|
97
|
+
response = {}
|
98
|
+
}
|
99
|
+
|
100
|
+
const attributes = {
|
101
|
+
url: response.url,
|
102
|
+
href: response.href,
|
103
|
+
}
|
104
|
+
|
105
|
+
successCallback(attributes)
|
106
|
+
}
|
107
|
+
})
|
108
|
+
|
109
|
+
xhr.send(formData)
|
110
|
+
}
|
111
|
+
|
112
|
+
createFormData(file) {
|
113
|
+
const data = new FormData()
|
114
|
+
data.append('Content-Type', file.type)
|
115
|
+
data.append('file', file)
|
116
|
+
data.append('filename', file.name)
|
117
|
+
data.append('attachment_key', this.attachmentKey)
|
118
|
+
|
119
|
+
return data
|
120
|
+
}
|
121
|
+
}
|