biovision 0.0.200518.1 → 0.12.211124.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +105 -52
- data/app/assets/images/biovision/icons/back.svg +19 -0
- data/app/assets/images/biovision/icons/create.svg +19 -0
- data/app/assets/images/biovision/icons/destroy.svg +12 -0
- data/app/assets/images/biovision/icons/dropdown.svg +3 -0
- data/app/assets/images/biovision/icons/edit.svg +22 -0
- data/app/assets/images/biovision/icons/gear.svg +11 -0
- data/app/assets/images/biovision/icons/return.svg +25 -0
- data/app/assets/images/biovision/icons/world.svg +11 -0
- data/app/assets/stylesheets/biovision/admin/components/users.scss +20 -0
- data/app/assets/stylesheets/biovision/admin/components.scss +13 -1
- data/app/assets/stylesheets/biovision/admin/layout.scss +27 -12
- data/app/assets/stylesheets/biovision/biovision.scss +105 -26
- data/app/assets/stylesheets/biovision/components/breadcrumbs.scss +13 -0
- data/app/assets/stylesheets/biovision/components/buttons.scss +130 -0
- data/app/assets/stylesheets/biovision/components/filters.scss +39 -0
- data/app/assets/stylesheets/biovision/components/forms.scss +208 -1
- data/app/assets/stylesheets/biovision/components/lists.scss +6 -7
- data/app/assets/stylesheets/biovision/{biovision → components}/messages.scss +9 -0
- data/app/assets/stylesheets/biovision/components/pagination.scss +34 -0
- data/app/assets/stylesheets/biovision/components/quick_search.scss +24 -0
- data/app/assets/stylesheets/biovision/components/simple_image.scss +112 -0
- data/app/assets/stylesheets/biovision/components/toggleable.scss +71 -0
- data/app/assets/stylesheets/biovision/components.scss +7 -0
- data/app/assets/stylesheets/biovision/default.scss +4 -4
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users/dashboard.scss +4 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users/form_tabs.scss +101 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users/profile.scss +77 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/components/users.scss +3 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/components.scss +2 -3
- data/app/assets/stylesheets/biovision/themes/default_theme/layout/footer.scss +3 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/layout/header.scss +12 -0
- data/app/assets/stylesheets/biovision/themes/default_theme/layout.scss +8 -19
- data/app/assets/stylesheets/biovision/themes/default_theme.scss +0 -1
- data/app/assets/stylesheets/biovision/vars.scss +5 -0
- data/app/controllers/admin/biovision_components_controller.rb +10 -0
- data/app/controllers/admin/components_controller.rb +37 -97
- data/app/controllers/admin/dynamic_blocks_controller.rb +15 -0
- data/app/controllers/admin/dynamic_pages_controller.rb +15 -0
- data/app/controllers/admin/index_controller.rb +8 -2
- data/app/controllers/admin/navigation_groups_controller.rb +45 -0
- data/app/controllers/admin/tokens_controller.rb +15 -0
- data/app/controllers/admin/users_controller.rb +101 -0
- data/app/controllers/admin_controller.rb +2 -8
- data/app/controllers/authentication_controller.rb +6 -34
- data/app/controllers/concerns/authentication.rb +12 -12
- data/app/controllers/concerns/component_stories.rb +22 -0
- data/app/controllers/concerns/crud_entities.rb +140 -0
- data/app/controllers/concerns/entity_priority.rb +10 -0
- data/app/controllers/concerns/my_crud_entities.rb +146 -0
- data/app/controllers/concerns/processed_forms.rb +28 -0
- data/app/controllers/concerns/restricted_access.rb +37 -0
- data/app/controllers/concerns/toggleable_entity.rb +31 -0
- data/app/controllers/contact_controller.rb +49 -0
- data/app/controllers/errors_controller.rb +37 -0
- data/app/controllers/fallback_controller.rb +12 -0
- data/app/controllers/index_controller.rb +1 -0
- data/app/controllers/legal_controller.rb +14 -0
- data/app/controllers/my/components_controller.rb +26 -0
- data/app/controllers/my/confirmations_controller.rb +44 -0
- data/app/controllers/my/index_controller.rb +7 -1
- data/app/controllers/my/profiles_controller.rb +33 -16
- data/app/controllers/oembed_controller.rb +12 -0
- data/app/controllers/profile_controller.rb +14 -0
- data/app/controllers/users_controller.rb +63 -0
- data/app/helpers/biovision_components_helper.rb +7 -3
- data/app/helpers/biovision_helper.rb +170 -0
- data/app/helpers/entity_helper.rb +77 -0
- data/app/helpers/my_helper.rb +34 -0
- data/app/helpers/simple_image_helper.rb +125 -0
- data/app/jobs/application_job.rb +7 -0
- data/app/jobs/send_phone_confirmation_job.rb +16 -0
- data/app/lib/biovision/components/base/component_parameters.rb +55 -0
- data/app/lib/biovision/components/base/component_privileges.rb +75 -0
- data/app/lib/biovision/components/base/component_settings.rb +40 -0
- data/app/lib/biovision/components/base/component_stories.rb +30 -0
- data/app/lib/biovision/components/base/entity_links.rb +38 -0
- data/app/lib/biovision/components/base/image_handling.rb +33 -0
- data/app/lib/biovision/components/base_component.rb +63 -95
- data/app/lib/biovision/components/contact_component.rb +26 -0
- data/app/lib/biovision/components/content/oembed/receiver.rb +98 -0
- data/app/lib/biovision/components/content/oembed/twitter_receiver.rb +20 -0
- data/app/lib/biovision/components/content/oembed/vimeo_receiver.rb +20 -0
- data/app/lib/biovision/components/content/oembed/youtube_receiver.rb +20 -0
- data/app/lib/biovision/components/content_component.rb +65 -0
- data/app/lib/biovision/components/track_component.rb +3 -0
- data/app/lib/biovision/components/users/authentication.rb +15 -7
- data/app/lib/biovision/components/users/codes.rb +104 -0
- data/app/lib/biovision/components/users/flag_helpers.rb +72 -0
- data/app/lib/biovision/components/users/profile_handler.rb +111 -1
- data/app/lib/biovision/components/users/registration_handler.rb +40 -52
- data/app/lib/biovision/components/users/validation.rb +83 -0
- data/app/lib/biovision/components/users_component.rb +114 -19
- data/app/lib/biovision/helpers/data_helper.rb +70 -0
- data/app/lib/biovision/helpers/export_helper.rb +97 -0
- data/app/lib/biovision/migrations/component_migration.rb +56 -0
- data/app/lib/biovision/notifiers/base_notifier.rb +2 -2
- data/app/lib/biovision/notifiers/contact_notifier.rb +15 -0
- data/app/lib/biovision/stories/component_story.rb +55 -0
- data/app/lib/canonizer.rb +38 -0
- data/app/lib/carrier_wave/image_optim.rb +32 -0
- data/app/mailers/code_sender.rb +29 -0
- data/app/mailers/feedback_mailer.rb +14 -0
- data/app/models/agent.rb +4 -0
- data/app/models/biovision_component.rb +39 -3
- data/app/models/code.rb +31 -8
- data/app/models/concerns/checkable.rb +2 -1
- data/app/models/concerns/has_simple_image.rb +9 -0
- data/app/models/concerns/has_uploaded_file.rb +26 -0
- data/app/models/concerns/meta_texts.rb +25 -5
- data/app/models/concerns/simple_tag.rb +30 -0
- data/app/models/concerns/toggleable.rb +2 -1
- data/app/models/concerns/tree_structure.rb +75 -0
- data/app/models/contact_method.rb +47 -0
- data/app/models/contact_type.rb +27 -0
- data/app/models/dynamic_block.rb +43 -0
- data/app/models/dynamic_page.rb +73 -0
- data/app/models/feedback_message.rb +65 -0
- data/app/models/feedback_response.rb +50 -0
- data/app/models/group.rb +48 -0
- data/app/models/language.rb +4 -0
- data/app/models/metric.rb +4 -0
- data/app/models/navigation_group.rb +43 -0
- data/app/models/navigation_group_page.rb +23 -0
- data/app/models/oembed_domain.rb +25 -0
- data/app/models/oembed_link.rb +19 -0
- data/app/models/oembed_receiver.rb +15 -0
- data/app/models/role.rb +86 -0
- data/app/models/role_group.rb +13 -0
- data/app/models/simple_image.rb +49 -8
- data/app/models/simple_image_tag.rb +1 -16
- data/app/models/token.rb +6 -2
- data/app/models/uploaded_file.rb +62 -0
- data/app/models/uploaded_file_tag.rb +15 -0
- data/app/models/uploaded_file_tag_file.rb +13 -0
- data/app/models/user.rb +122 -29
- data/app/models/user_group.rb +20 -0
- data/app/models/user_role.rb +18 -0
- data/app/uploaders/simple_file_uploader.rb +23 -0
- data/app/uploaders/simple_image_uploader.rb +29 -20
- data/app/uploaders/uploaders/path_slug.rb +22 -0
- data/app/views/admin/agents/index.html.erb +1 -3
- data/app/views/admin/biovision_components/_nav_item.html.erb +6 -0
- data/app/views/admin/biovision_components/entity/_in_list.html.erb +12 -0
- data/app/views/admin/biovision_components/index.html.erb +11 -0
- data/app/views/admin/components/_image.jbuilder +18 -0
- data/app/views/admin/components/_list.html.erb +1 -1
- data/app/views/admin/components/entity/_links.html.erb +31 -21
- data/app/views/admin/components/image.jbuilder +1 -0
- data/app/views/admin/components/images.jbuilder +4 -0
- data/app/views/admin/components/links/_base.html.erb +1 -0
- data/app/views/admin/components/settings/_new_parameter.html.erb +4 -2
- data/app/views/admin/components/settings/_parameters.html.erb +8 -2
- data/app/views/admin/components/settings/_settings.html.erb +4 -4
- data/app/views/admin/components/settings.html.erb +2 -1
- data/app/views/admin/components/update_privileges.jbuilder +21 -0
- data/app/views/admin/dynamic_blocks/_form.html.erb +16 -0
- data/app/views/admin/dynamic_blocks/_nav_item.html.erb +6 -0
- data/app/views/admin/dynamic_blocks/entity/_in_list.html.erb +12 -0
- data/app/views/admin/dynamic_blocks/index.html.erb +17 -0
- data/app/views/admin/dynamic_blocks/show.html.erb +25 -0
- data/app/views/admin/dynamic_pages/_dynamic_page.jbuilder +18 -0
- data/app/views/admin/dynamic_pages/_form.html.erb +21 -0
- data/app/views/admin/dynamic_pages/_nav_item.html.erb +6 -0
- data/app/views/admin/dynamic_pages/entity/_in_list.html.erb +17 -0
- data/app/views/admin/dynamic_pages/entity/_in_search.html.erb +7 -0
- data/app/views/admin/dynamic_pages/index.html.erb +17 -0
- data/app/views/admin/dynamic_pages/search.jbuilder +4 -0
- data/app/views/admin/dynamic_pages/show.html.erb +28 -0
- data/app/views/admin/index/index.html.erb +7 -5
- data/app/views/admin/ip_addresses/index.html.erb +2 -4
- data/app/views/admin/navigation_group_pages/entity/_in_list.html.erb +26 -0
- data/app/views/admin/navigation_groups/_form.html.erb +15 -0
- data/app/views/admin/navigation_groups/_nav_item.html.erb +6 -0
- data/app/views/admin/navigation_groups/entity/_dynamic_pages.html.erb +38 -0
- data/app/views/admin/navigation_groups/entity/_in_list.html.erb +14 -0
- data/app/views/admin/navigation_groups/index.html.erb +17 -0
- data/app/views/admin/navigation_groups/show.html.erb +33 -0
- data/app/views/admin/tokens/_form.html.erb +31 -0
- data/app/views/admin/tokens/_nav_item.html.erb +6 -0
- data/app/views/admin/tokens/entity/_in_list.html.erb +27 -0
- data/app/views/admin/tokens/index.html.erb +11 -0
- data/app/views/admin/tokens/show.html.erb +26 -0
- data/app/views/admin/unauthorized.html.erb +2 -5
- data/app/views/admin/users/_form.html.erb +81 -0
- data/app/views/admin/users/_nav_item.html.erb +6 -0
- data/app/views/admin/users/_user.jbuilder +18 -0
- data/app/views/admin/users/entity/_fields.html.erb +53 -0
- data/app/views/admin/users/entity/_in_list.html.erb +38 -0
- data/app/views/admin/users/entity/_in_search.html.erb +18 -0
- data/app/views/admin/users/entity/_profile.html.erb +26 -0
- data/app/views/admin/users/entity/in_list/_additional_data.html.erb +0 -0
- data/app/views/admin/users/index.html.erb +24 -0
- data/app/views/admin/users/roles/_component.html.erb +22 -0
- data/app/views/admin/users/roles.html.erb +23 -0
- data/app/views/admin/users/search.jbuilder +4 -0
- data/app/views/admin/users/show.html.erb +62 -0
- data/app/views/admin/widgets/_filters.html.erb +20 -0
- data/app/views/admin/widgets/_quick_search.html.erb +13 -0
- data/app/views/admin/widgets/filters/_flag.html.erb +15 -0
- data/app/views/admin/widgets/filters/_text.html.erb +7 -0
- data/app/views/application/forbidden.html.erb +9 -0
- data/app/views/application/forbidden.jbuilder +4 -0
- data/app/views/application/not_found.html.erb +9 -0
- data/app/views/application/not_found.jbuilder +4 -0
- data/app/views/application/unauthorized.html.erb +19 -0
- data/app/views/application/unauthorized.jbuilder +4 -0
- data/app/views/authentication/new.html.erb +2 -8
- data/app/views/components/content/_dynamic_page.html.erb +17 -0
- data/app/views/components/content/_dynamic_page_content.html.erb +14 -0
- data/app/views/components/users/_form_tabs.html.erb +31 -0
- data/app/views/components/users/_join_form.html.erb +192 -0
- data/app/views/components/users/_login_form.html.erb +46 -0
- data/app/views/components/users/form/_image.html.erb +17 -0
- data/app/views/components/users/form/_profile_data.html.erb +54 -0
- data/app/views/contact/_form.html.erb +108 -0
- data/app/views/contact/create_feedback_message.js.erb +1 -0
- data/app/views/contact/feedback.html.erb +13 -0
- data/app/views/contact/index.html.erb +16 -0
- data/app/views/errors/error.html.erb +1 -0
- data/app/views/fallback/show.html.erb +6 -0
- data/app/views/feedback_mailer/new_feedback_request.html.erb +11 -0
- data/app/views/feedback_mailer/new_feedback_request.text.erb +6 -0
- data/app/views/index/index.html.erb +14 -0
- data/app/views/layouts/admin/_footer.html.erb +1 -1
- data/app/views/layouts/admin/_header.html.erb +7 -2
- data/app/views/layouts/admin.html.erb +0 -1
- data/app/views/layouts/application/_footer.html.erb +1 -1
- data/app/views/layouts/application/header/_authentication.html.erb +4 -1
- data/app/views/legal/privacy.html.erb +5 -0
- data/app/views/legal/tos.html.erb +5 -0
- data/app/views/my/components/index.html.erb +25 -0
- data/app/views/my/components/show.html.erb +21 -0
- data/app/views/my/confirmations/show.html.erb +62 -0
- data/app/views/my/index/_cards.html.erb +15 -0
- data/app/views/my/index/_email.html.erb +14 -0
- data/app/views/my/index/_navigation.html.erb +33 -0
- data/app/views/my/index/index.html.erb +12 -0
- data/app/views/my/profiles/_form.html.erb +10 -0
- data/app/views/my/profiles/check.jbuilder +4 -0
- data/app/views/my/profiles/edit.html.erb +14 -0
- data/app/views/my/profiles/form/_basic_parameters.html.erb +9 -0
- data/app/views/my/profiles/form/_sensitive_parameters.html.erb +68 -0
- data/app/views/my/profiles/new.html.erb +6 -8
- data/app/views/my/profiles/show.html.erb +36 -0
- data/app/views/my/recoveries/show.html.erb +0 -0
- data/app/views/shared/_flash_messages.html.erb +1 -1
- data/app/views/shared/_list_of_errors.html.erb +7 -0
- data/app/views/shared/admin/_breadcrumbs.html.erb +8 -0
- data/app/views/shared/admin/_list.html.erb +10 -19
- data/app/views/shared/admin/_list_with_priority.html.erb +10 -19
- data/app/views/shared/admin/_priority.html.erb +6 -0
- data/app/views/shared/admin/_toggle.html.erb +6 -0
- data/app/views/shared/entity/_date_field.html.erb +6 -0
- data/app/views/shared/entity/_formatted_text_field.html.erb +10 -0
- data/app/views/shared/entity/_image.html.erb +31 -0
- data/app/views/shared/entity/_language.html.erb +6 -0
- data/app/views/shared/entity/_linked_entity.html.erb +6 -0
- data/app/views/shared/entity/_list.html.erb +22 -0
- data/app/views/shared/entity/_list_with_priority.html.erb +22 -0
- data/app/views/shared/entity/_meta_texts.html.erb +16 -0
- data/app/views/shared/entity/_metadata.html.erb +18 -0
- data/app/views/shared/entity/_parent.html.erb +6 -0
- data/app/views/shared/entity/_priority.html.erb +4 -0
- data/app/views/shared/entity/_priority_icons.html.erb +8 -0
- data/app/views/shared/entity/_raw_text_field.html.erb +10 -0
- data/app/views/shared/entity/_simple_image.html.erb +10 -0
- data/app/views/shared/entity/_slug.html.erb +6 -0
- data/app/views/shared/entity/_text_field.html.erb +6 -0
- data/app/views/shared/entity/_text_fields.html.erb +9 -0
- data/app/views/shared/entity/_time_field.html.erb +6 -0
- data/app/views/shared/entity/_timestamps.html.erb +13 -0
- data/app/views/shared/entity/_toggle.html.erb +12 -0
- data/app/views/shared/entity/_track.html.erb +12 -0
- data/app/views/shared/entity/_tree_caches.html.erb +19 -0
- data/app/views/shared/entity/_uuid.html.erb +4 -0
- data/app/views/shared/entity/edit.html.erb +23 -0
- data/app/views/shared/entity/new.html.erb +16 -0
- data/app/views/shared/forms/_entity_flags.html.erb +15 -0
- data/app/views/shared/forms/_field.html.erb +50 -0
- data/app/views/shared/forms/_field_with_search.html.erb +17 -0
- data/app/views/shared/forms/_fields.html.erb +3 -0
- data/app/views/shared/forms/_language.html.erb +40 -0
- data/app/views/shared/forms/_meta_texts.html.erb +27 -0
- data/app/views/shared/forms/_priority.html.erb +13 -0
- data/app/views/shared/forms/_simple_entity_link.html.erb +14 -0
- data/app/views/shared/forms/_simple_image.html.erb +47 -0
- data/app/views/shared/forms/_state_container.html.erb +7 -0
- data/app/views/shared/forms/_text_area.html.erb +25 -0
- data/app/views/shared/forms/_text_field.html.erb +24 -0
- data/app/views/shared/forms/_text_fields.html.erb +3 -0
- data/app/views/shared/forms/check.jbuilder +4 -0
- data/app/views/shared/forms/errors.jbuilder +3 -0
- data/app/views/shared/forms/simple_image/_browse.html.erb +14 -0
- data/app/views/shared/forms/simple_image/_load_image.html.erb +38 -0
- data/app/views/shared/my/_list.html.erb +10 -0
- data/app/views/shared/my/_list_with_priority.html.erb +10 -0
- data/app/views/shared/my/entity/edit.html.erb +25 -0
- data/app/views/shared/my/entity/new.html.erb +18 -0
- data/app/views/simple_images/_simple_image.jbuilder +13 -0
- data/app/views/users/_profile.html.erb +30 -0
- data/app/views/users/profile/_data.html.erb +20 -0
- data/app/views/users/show.html.erb +21 -0
- data/config/locales/biovision-ru.yml +76 -1
- data/config/locales/components-ru.yml +55 -4
- data/config/locales/contact-ru.yml +110 -0
- data/config/locales/content-ru.yml +115 -0
- data/config/locales/users-ru.yml +142 -3
- data/config/routes.rb +99 -48
- data/db/migrate/20191228000000_create_biovision_components.rb +6 -5
- data/db/migrate/20200224000000_create_track_component.rb +9 -14
- data/db/migrate/20200224000010_create_users_component.rb +14 -83
- data/db/migrate/20200404000000_create_simple_images.rb +4 -3
- data/db/migrate/20210405000000_create_acl.rb +88 -0
- data/db/migrate/20210421000000_create_content_component.rb +80 -0
- data/db/migrate/20210421000010_create_contact_component.rb +74 -0
- data/db/migrate/20210616000000_create_uploaded_files.rb +52 -0
- data/db/migrate/amends/20210816060606_create_oembed_receivers.rb +21 -0
- data/db/migrate/amends/20210907070707_add_checksum_to_simple_images.rb +13 -0
- data/lib/biovision/base_methods.rb +17 -29
- data/lib/biovision/engine.rb +8 -13
- data/lib/biovision/version.rb +1 -1
- data/lib/tasks/components.rake +51 -0
- metadata +266 -27
- data/app/assets/images/biovision/placeholders/user.svg +0 -15
- data/app/helpers/users_helper.rb +0 -11
- data/app/lib/biovision/components/component_settings.rb +0 -30
- data/app/lib/biovision/components/privilege_handler.rb +0 -77
- data/app/lib/biovision/components/users/code_handler.rb +0 -23
- data/app/models/biovision_component_user.rb +0 -21
- data/app/models/foreign_site.rb +0 -34
- data/app/models/foreign_user.rb +0 -21
- data/app/uploaders/user_image_uploader.rb +0 -58
- data/app/views/admin/components/links/_track.html.erb +0 -2
- data/app/views/admin/components/links/_users.html.erb +0 -11
- data/app/views/admin/components/privileges/_component_user.html.erb +0 -17
- data/app/views/admin/components/privileges/_links.html.erb +0 -35
- data/app/views/admin/components/privileges/_privilege_flag.html.erb +0 -28
- data/app/views/admin/components/privileges/_users.html.erb +0 -23
- data/app/views/admin/components/privileges.html.erb +0 -20
- data/app/views/authentication/_form.html.erb +0 -40
- data/app/views/authentication/failed.js.erb +0 -3
- data/app/views/my/profiles/new/_form.html.erb +0 -147
- data/app/views/shared/admin/_toggleable.html.erb +0 -8
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Helpers for displaying common entity-related blocks
|
4
|
+
module EntityHelper
|
5
|
+
# @param [Enumerable] collection
|
6
|
+
# @param [Symbol|String|nil] scope
|
7
|
+
# @param [Biovision::Components::BaseComponent|nil] handler
|
8
|
+
# @param [TrueClass|FalseClass] with_priority
|
9
|
+
def entity_list(collection, scope: nil, handler: component_handler, with_priority: false)
|
10
|
+
scope = controller.class.module_parent_name.to_s.downcase if scope.nil?
|
11
|
+
suffix = with_priority ? '_with_priority' : ''
|
12
|
+
|
13
|
+
render(
|
14
|
+
partial: "shared/entity/list#{suffix}",
|
15
|
+
locals: { collection: collection, handler: handler, scope: scope.to_sym }
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [ApplicationRecord] entity
|
20
|
+
# @param [Symbol|String|nil] scope
|
21
|
+
def entity_toggle(entity, scope: nil)
|
22
|
+
scope = controller.class.module_parent_name.to_s.downcase if scope.nil?
|
23
|
+
|
24
|
+
render(
|
25
|
+
partial: 'shared/entity/toggle',
|
26
|
+
locals: { entity: entity, scope: scope.to_sym }
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @param [ApplicationRecord] entity
|
31
|
+
# @param [Symbol|String|nil] scope
|
32
|
+
def entity_priority_icons(entity, scope: nil)
|
33
|
+
scope = controller.class.module_parent_name.to_s.downcase if scope.nil?
|
34
|
+
|
35
|
+
render(
|
36
|
+
partial: 'shared/entity/priority_icons',
|
37
|
+
locals: { entity: entity, scope: scope.to_sym }
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
# @param [ApplicationRecord] entity
|
42
|
+
# @param [String] text
|
43
|
+
def linked_entity_block(entity, text: nil)
|
44
|
+
return '' if entity.blank?
|
45
|
+
|
46
|
+
render(
|
47
|
+
partial: 'shared/entity/linked_entity',
|
48
|
+
locals: { entity: entity, text: text }
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
# @param [ApplicationRecord] entity
|
53
|
+
# @param [String|Symbol] types
|
54
|
+
def entity_partial_block(entity, *types)
|
55
|
+
permitted = %i[
|
56
|
+
priority uuid slug timestamps language simple_image meta_texts track
|
57
|
+
]
|
58
|
+
|
59
|
+
buffer = ''
|
60
|
+
types.select { |i| permitted.include?(i.to_sym)}.each do |type|
|
61
|
+
buffer += render(partial: "shared/entity/#{type}", locals: { entity: entity })
|
62
|
+
end
|
63
|
+
|
64
|
+
raw buffer
|
65
|
+
end
|
66
|
+
|
67
|
+
def entity_form_block(f, *types)
|
68
|
+
permitted = %i[priority entity_flags simple_image]
|
69
|
+
|
70
|
+
buffer = ''
|
71
|
+
types.select { |i| permitted.include?(i.to_sym)}.each do |type|
|
72
|
+
buffer += render partial: "shared/forms/#{type}", locals: { f: f }
|
73
|
+
end
|
74
|
+
|
75
|
+
raw buffer
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Helper methods for user context
|
4
|
+
module MyHelper
|
5
|
+
# @param [ApplicationRecord] entity
|
6
|
+
# @param [Hash] options
|
7
|
+
def my_edit_icon(entity, options = {})
|
8
|
+
title = options.delete(:title) { t(:edit) }
|
9
|
+
key = entity.respond_to?(:uuid) ? entity.uuid : entity.id
|
10
|
+
path = "/my/#{entity.class.table_name}/#{key}/edit"
|
11
|
+
my_icon_with_link('biovision/icons/edit.svg', path, title.to_s, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param [ApplicationRecord] entity
|
15
|
+
# @param [Hash] options
|
16
|
+
def my_destroy_icon(entity, options = {})
|
17
|
+
title = options.delete(:title) { t(:edit) }
|
18
|
+
key = entity.respond_to?(:uuid) ? entity.uuid : entity.id
|
19
|
+
path = "/my/#{entity.class.table_name}/#{key}"
|
20
|
+
default = {
|
21
|
+
class: 'danger',
|
22
|
+
data: { confirm: t(:are_you_sure) },
|
23
|
+
method: :delete,
|
24
|
+
}
|
25
|
+
my_icon_with_link('biovision/icons/destroy.svg', path, title.to_s, default.merge(options))
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param [String|ApplicationRecord] path
|
29
|
+
# @param [String] title
|
30
|
+
# @param [Hash] options
|
31
|
+
def my_icon_with_link(source, path, title = '', options = {})
|
32
|
+
link_to(image_tag(source, alt: title), path, options)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Helper methods for displaying versions for SimpleImageUploader
|
4
|
+
module SimpleImageHelper
|
5
|
+
# Tiny (48x48) version of simple image
|
6
|
+
#
|
7
|
+
# @param [ApplicationRecord|SimpleImageUploader] entity
|
8
|
+
# @param [Hash] options
|
9
|
+
def simple_image_tiny(entity, options = {})
|
10
|
+
return '' if entity.nil?
|
11
|
+
|
12
|
+
image = entity.is_a?(SimpleImageUploader) ? entity : entity.image
|
13
|
+
default_image = options.delete(:default_image).to_s
|
14
|
+
|
15
|
+
return default_image if image.blank?
|
16
|
+
|
17
|
+
default = {
|
18
|
+
alt: image.alt_text,
|
19
|
+
load: 'lazy'
|
20
|
+
}
|
21
|
+
image_tag(image.tiny_url, default.merge(options))
|
22
|
+
end
|
23
|
+
|
24
|
+
# Preview (160x160) version of simple image
|
25
|
+
#
|
26
|
+
# @param [ApplicationRecord|SimpleImageUploader] entity
|
27
|
+
# @param [Hash] options
|
28
|
+
def simple_image_preview(entity, options = {})
|
29
|
+
return '' if entity.nil?
|
30
|
+
|
31
|
+
image = entity.is_a?(SimpleImageUploader) ? entity : entity.image
|
32
|
+
default_image = options.delete(:default_image).to_s
|
33
|
+
|
34
|
+
return default_image if image.blank?
|
35
|
+
|
36
|
+
default = {
|
37
|
+
alt: image.alt_text,
|
38
|
+
load: 'lazy'
|
39
|
+
}
|
40
|
+
image_tag(image.preview_url, default.merge(options))
|
41
|
+
end
|
42
|
+
|
43
|
+
# Small (320x320) version of simple image
|
44
|
+
#
|
45
|
+
# @param [ApplicationRecord|SimpleImageUploader] entity
|
46
|
+
# @param [Hash] options
|
47
|
+
def simple_image_small(entity, options = {})
|
48
|
+
return '' if entity.nil?
|
49
|
+
|
50
|
+
image = entity.is_a?(SimpleImageUploader) ? entity : entity.image
|
51
|
+
default_image = options.delete(:default_image).to_s
|
52
|
+
|
53
|
+
return default_image if image.blank?
|
54
|
+
|
55
|
+
default = {
|
56
|
+
alt: image.alt_text,
|
57
|
+
load: 'lazy'
|
58
|
+
}
|
59
|
+
default[:srcset] = "#{image.medium.url} 2x" if image.raster?
|
60
|
+
|
61
|
+
image_tag(image.small_url, default.merge(options))
|
62
|
+
end
|
63
|
+
|
64
|
+
# Medium (640x640) version of simple image
|
65
|
+
#
|
66
|
+
# @param [ApplicationRecord|SimpleImageUploader] entity
|
67
|
+
# @param [Hash] options
|
68
|
+
def simple_image_medium(entity, options = {})
|
69
|
+
return '' if entity.nil?
|
70
|
+
|
71
|
+
image = entity.is_a?(SimpleImageUploader) ? entity : entity.image
|
72
|
+
default_image = options.delete(:default_image).to_s
|
73
|
+
|
74
|
+
return default_image if image.blank?
|
75
|
+
|
76
|
+
default = {
|
77
|
+
alt: image.alt_text,
|
78
|
+
load: 'lazy'
|
79
|
+
}
|
80
|
+
default[:srcset] = "#{image.large.url} 2x" if image.raster?
|
81
|
+
|
82
|
+
image_tag(image.medium_url, default.merge(options))
|
83
|
+
end
|
84
|
+
|
85
|
+
# Large (1280x1280) version of simple image
|
86
|
+
#
|
87
|
+
# @param [ApplicationRecord|SimpleImageUploader] entity
|
88
|
+
# @param [Hash] options
|
89
|
+
def simple_image_large(entity, options = {})
|
90
|
+
return '' if entity.nil?
|
91
|
+
|
92
|
+
image = entity.is_a?(SimpleImageUploader) ? entity : entity.image
|
93
|
+
default_image = options.delete(:default_image).to_s
|
94
|
+
|
95
|
+
return default_image if image.blank?
|
96
|
+
|
97
|
+
default = {
|
98
|
+
alt: image.alt_text,
|
99
|
+
load: 'lazy'
|
100
|
+
}
|
101
|
+
default[:srcset] = "#{image.hd.url} 2x" if image.raster?
|
102
|
+
|
103
|
+
image_tag(image.large_url, default.merge(options))
|
104
|
+
end
|
105
|
+
|
106
|
+
# HD (1920x1920) version of simple image
|
107
|
+
#
|
108
|
+
# @param [ApplicationRecord|SimpleImageUploader] entity
|
109
|
+
# @param [Hash] options
|
110
|
+
def simple_image_hd(entity, options = {})
|
111
|
+
return '' if entity.nil?
|
112
|
+
|
113
|
+
image = entity.is_a?(SimpleImageUploader) ? entity : entity.image
|
114
|
+
default_image = options.delete(:default_image).to_s
|
115
|
+
|
116
|
+
return default_image if image.blank?
|
117
|
+
|
118
|
+
default = {
|
119
|
+
alt: image.alt_text,
|
120
|
+
load: 'lazy'
|
121
|
+
}
|
122
|
+
|
123
|
+
image_tag(image.hd_url, default.merge(options))
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class ApplicationJob < ActiveJob::Base
|
2
|
+
# Automatically retry jobs that encountered a deadlock
|
3
|
+
# retry_on ActiveRecord::Deadlocked
|
4
|
+
|
5
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
6
|
+
# discard_on ActiveJob::DeserializationError
|
7
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Send phone confirmation code via SMS gateway
|
4
|
+
class SendPhoneConfirmationJob < ApplicationJob
|
5
|
+
queue_as :default
|
6
|
+
|
7
|
+
# @param [Integer] id
|
8
|
+
def perform(id)
|
9
|
+
code = Code.find_by(id: id)
|
10
|
+
|
11
|
+
return if code.nil?
|
12
|
+
|
13
|
+
# To be implemented: use actual gateway
|
14
|
+
code.user.phone
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Biovision
|
4
|
+
module Components
|
5
|
+
module Base
|
6
|
+
# Getting and setting component parameters
|
7
|
+
module ComponentParameters
|
8
|
+
def use_parameters?
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
def use_files?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def manage_settings?
|
17
|
+
use_parameters? || component.settings.any?
|
18
|
+
end
|
19
|
+
|
20
|
+
# Receive parameter value with default
|
21
|
+
#
|
22
|
+
# Returns value of component's parameter or default value
|
23
|
+
# when it's not found
|
24
|
+
#
|
25
|
+
# @param [String] key
|
26
|
+
# @param [String] default
|
27
|
+
# @return [String]
|
28
|
+
def receive(key, default = '')
|
29
|
+
@component.get(key, default)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Receive parameter value or nil
|
33
|
+
#
|
34
|
+
# Returns value of component's parameter of nil when it's not found
|
35
|
+
#
|
36
|
+
# @param [String] key
|
37
|
+
# @return [String]
|
38
|
+
def [](key)
|
39
|
+
@component.get(key, nil)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Set parameter
|
43
|
+
#
|
44
|
+
# @param [String] key
|
45
|
+
# @param [String] value
|
46
|
+
def []=(key, value)
|
47
|
+
return if key.blank?
|
48
|
+
|
49
|
+
@component.parameters[key.to_s] = value
|
50
|
+
@component.save!
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Biovision
|
4
|
+
module Components
|
5
|
+
module Base
|
6
|
+
# Handling component privileges
|
7
|
+
module ComponentPrivileges
|
8
|
+
# @param [String] action
|
9
|
+
# @param [Object] context
|
10
|
+
def permit?(action = 'default', context = nil)
|
11
|
+
return false if user.nil?
|
12
|
+
|
13
|
+
parts = [slug]
|
14
|
+
model = model_from_context(context)
|
15
|
+
parts << model.table_name if model.respond_to?(:table_name)
|
16
|
+
parts << action
|
17
|
+
owner?(context) || role?(parts.join('.')) || role?("#{slug}.all")
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param [ApplicationRecord|nil] entity
|
21
|
+
def owner?(entity)
|
22
|
+
return false unless entity.respond_to?(:owned_by?)
|
23
|
+
|
24
|
+
entity.owned_by?(user)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param [String] role_name
|
28
|
+
def role?(role_name)
|
29
|
+
return false if user.nil?
|
30
|
+
return true if user.super_user?
|
31
|
+
|
32
|
+
role = Role[role_name]
|
33
|
+
return false if role.nil?
|
34
|
+
|
35
|
+
user.role_ids.include?(role.id)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param [Class|Object] context
|
39
|
+
# @return Class
|
40
|
+
def model_from_context(context)
|
41
|
+
context.is_a?(Class) ? context : context.class
|
42
|
+
end
|
43
|
+
|
44
|
+
def crud_table_names
|
45
|
+
tables = administrative_parts
|
46
|
+
tables << 'simple_images' if use_images?
|
47
|
+
tables << 'uploaded_files' if use_files?
|
48
|
+
tables
|
49
|
+
end
|
50
|
+
|
51
|
+
def role_tree
|
52
|
+
tree = { nil => %w[all default view] }
|
53
|
+
tree['settings'] = %w[view edit] if use_settings?
|
54
|
+
crud_table_names.each do |table_name|
|
55
|
+
tree[table_name] = %w[view edit]
|
56
|
+
end
|
57
|
+
tree
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_roles
|
61
|
+
role_tree.each do |prefix, postfixes|
|
62
|
+
postfixes.each do |postfix|
|
63
|
+
slug = prefix.blank? ? postfix : "#{prefix}.#{postfix}"
|
64
|
+
Role.create(biovision_component: component, slug: slug)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def administrative_parts
|
70
|
+
self.class.dependent_models.map(&:table_name)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Biovision
|
4
|
+
module Components
|
5
|
+
module Base
|
6
|
+
# Normalizing component settings
|
7
|
+
module ComponentSettings
|
8
|
+
def settings_flags
|
9
|
+
[]
|
10
|
+
end
|
11
|
+
|
12
|
+
def settings_numbers
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
|
16
|
+
def settings_strings
|
17
|
+
[]
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_settings
|
21
|
+
{}
|
22
|
+
end
|
23
|
+
|
24
|
+
def reset_settings
|
25
|
+
BiovisionComponent[slug]&.update(settings: default_settings)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param [Hash] data
|
29
|
+
def normalize_settings(data)
|
30
|
+
result = {}
|
31
|
+
settings_flags.each { |f| result[f] = data[f].to_i == 1 }
|
32
|
+
settings_numbers.each { |n| result[n] = data[n].to_i }
|
33
|
+
settings_strings.each { |s| result[s] = data[s].to_s }
|
34
|
+
|
35
|
+
result
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Biovision
|
4
|
+
module Components
|
5
|
+
module Base
|
6
|
+
# Methods for handling component stories
|
7
|
+
module ComponentStories
|
8
|
+
# @param [String] story_slug
|
9
|
+
def story_class(story_slug)
|
10
|
+
namespace = "biovision/components/#{self.class.slug}"
|
11
|
+
handler_name = "#{namespace}/stories/#{story_slug}_story".classify
|
12
|
+
handler_name.safe_constantize || Biovision::Stories::ComponentStory
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param [String] story_slug
|
16
|
+
# @param [ApplicationRecord|nil] entity
|
17
|
+
def story(story_slug, entity = nil)
|
18
|
+
story_class(story_slug).new(self, entity)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param [String] story_slug
|
22
|
+
# @param [Hash] story_parameters
|
23
|
+
# @param [ApplicationRecord|String|nli] entity
|
24
|
+
def perform_story(story_slug, story_parameters, entity = nil)
|
25
|
+
story(story_slug, entity).perform(story_parameters)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Biovision
|
4
|
+
module Components
|
5
|
+
module Base
|
6
|
+
# Links for entities in context of current user
|
7
|
+
module EntityLinks
|
8
|
+
# @param [ApplicationRecord] entity
|
9
|
+
def text_for_link(entity)
|
10
|
+
entity.respond_to?(:text_for_link) ? entity.text_for_link : entity.id
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param [ApplicationRecord] entity
|
14
|
+
# @param [Symbol|String] scope
|
15
|
+
def entity_link(entity, scope = '')
|
16
|
+
prefix = %i[admin my].include?(scope.to_sym) ? scope : 'world'
|
17
|
+
message = "#{prefix}_url".to_sym
|
18
|
+
if entity.respond_to?(message)
|
19
|
+
entity.send(message)
|
20
|
+
else
|
21
|
+
rest_entity_link(entity, scope.to_sym)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [ApplicationRecord] entity
|
26
|
+
# @param [Symbol] scope
|
27
|
+
def rest_entity_link(entity, scope)
|
28
|
+
collection = "/#{scope}/#{entity.class.table_name}".gsub('//', '/')
|
29
|
+
if entity.attributes.key?('uuid') && scope != :admin
|
30
|
+
"#{collection}/#{entity.uuid}"
|
31
|
+
else
|
32
|
+
"#{collection}/#{entity.id}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Biovision
|
4
|
+
module Components
|
5
|
+
module Base
|
6
|
+
# Handling simple images
|
7
|
+
module ImageHandling
|
8
|
+
def use_images?
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
# @param [Hash] parameters
|
13
|
+
def upload_image(parameters)
|
14
|
+
return if parameters[:image].blank?
|
15
|
+
|
16
|
+
checksum = Digest::SHA256.file(parameters[:image].path).hexdigest
|
17
|
+
SimpleImage[checksum] || create_image(parameters, checksum)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# @param [Hash] parameters
|
23
|
+
# @param [String] checksum
|
24
|
+
def create_image(parameters, checksum)
|
25
|
+
image = component.simple_images.new(parameters)
|
26
|
+
image.data[SimpleImage::ORIGINAL_CHECKSUM] = checksum
|
27
|
+
image.save
|
28
|
+
image
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|