decidim-core 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/config/decidim_core_manifest.js +3 -0
- data/app/assets/fonts/decidim/Roboto-Regular.svg +1 -10520
- data/app/assets/fonts/decidim/Source_Sans_Pro_400.svg +1 -345
- data/app/assets/fonts/decidim/Source_Sans_Pro_600.svg +1 -339
- data/app/assets/fonts/decidim/Source_Sans_Pro_900.svg +1 -342
- data/app/assets/images/decidim/avatar-multiuser.png +0 -0
- data/app/assets/images/decidim/brands/google.svg +1 -1
- data/app/assets/images/decidim/decidim-logo.svg +1 -71
- data/app/assets/images/decidim/default-avatar.svg +1 -14
- data/app/assets/images/decidim/gamification/badges/followers.svg +1 -115
- data/app/assets/images/decidim/gamification/badges/invitations.svg +1 -117
- data/app/assets/images/decidim/icons.svg +1 -259
- data/app/assets/images/decidim/placeholder.jpg +0 -0
- data/app/assets/javascripts/decidim.js.es6 +23 -1
- data/app/assets/javascripts/decidim/ajax_modals.js.es6 +3 -0
- data/app/assets/javascripts/decidim/assets.js.erb +5 -0
- data/app/assets/javascripts/decidim/callout.js.es6 +18 -0
- data/app/assets/javascripts/decidim/configuration.js.es6 +23 -0
- data/app/assets/javascripts/decidim/confirm.js.es6 +178 -0
- data/app/assets/javascripts/decidim/conversations.js.es6 +17 -0
- data/app/assets/javascripts/decidim/core/bundle.js +1 -1
- data/app/assets/javascripts/decidim/core/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/core/extrapoly.js +6 -0
- data/app/assets/javascripts/decidim/data_picker.js.es6 +128 -50
- data/app/assets/javascripts/decidim/diff_mode_dropdown.js.es6 +5 -7
- data/app/assets/javascripts/decidim/dropdowns_menus.js.es6 +32 -0
- data/app/assets/javascripts/decidim/external_link.js.es6 +69 -0
- data/app/assets/javascripts/decidim/floating_help.js.es6 +7 -0
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +1 -1
- data/app/assets/javascripts/decidim/form_filter.component.test.js +4 -4
- data/app/assets/javascripts/decidim/form_validator.es6 +61 -0
- data/app/assets/javascripts/decidim/foundation.js.es6 +28 -28
- data/app/assets/javascripts/decidim/icon.js.es6 +42 -0
- data/app/assets/javascripts/decidim/identity_selector_dialog.js.es6 +61 -0
- data/app/assets/javascripts/decidim/input_character_counter.js.es6 +115 -0
- data/app/assets/javascripts/decidim/input_mentions.js.es6 +34 -9
- data/app/assets/javascripts/decidim/input_multiple_mentions.js.es6 +195 -0
- data/app/assets/javascripts/decidim/map.js.es6 +40 -3
- data/app/assets/javascripts/decidim/orders.js.es6 +9 -28
- data/app/assets/javascripts/decidim/responsive_horizontal_tabs.js.es6 +12 -0
- data/app/assets/javascripts/decidim/results_listing.js.es6 +44 -0
- data/app/assets/javascripts/decidim/start_conversation_dialog.js +13 -0
- data/app/assets/javascripts/decidim/vizzs.js.es6 +1 -0
- data/app/assets/stylesheets/decidim/_decidim-settings.scss +5 -0
- data/app/assets/stylesheets/decidim/_decidim.scss +13 -11
- data/app/assets/stylesheets/decidim/_properties.scss +25 -0
- data/app/assets/stylesheets/decidim/_variables.scss +6 -24
- data/app/assets/stylesheets/decidim/application.scss.erb +2 -2
- data/app/assets/stylesheets/decidim/editor.scss +2 -2
- data/app/assets/stylesheets/decidim/email.scss +1771 -0
- data/app/assets/stylesheets/decidim/extras/_external-links.scss +29 -0
- data/app/assets/stylesheets/decidim/extras/_extras.scss +17 -0
- data/app/assets/stylesheets/decidim/extras/_label-required.scss +9 -0
- data/app/assets/stylesheets/decidim/extras/_process_stats.scss +1 -1
- data/app/assets/stylesheets/decidim/extras/_quill.scss +5 -0
- data/app/assets/stylesheets/decidim/extras/_results-per-page.scss +8 -0
- data/app/assets/stylesheets/decidim/layouts/_home.scss +31 -7
- data/app/assets/stylesheets/decidim/layouts/_layouts.scss +5 -0
- data/app/assets/stylesheets/decidim/layouts/_logo.scss +26 -0
- data/app/assets/stylesheets/decidim/layouts/_user.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +9 -13
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +198 -26
- data/app/assets/stylesheets/decidim/modules/_cards.scss +174 -23
- data/app/assets/stylesheets/decidim/modules/_collapsible-list.scss +21 -0
- data/app/assets/stylesheets/decidim/modules/_comments.scss +25 -1
- data/app/assets/stylesheets/decidim/modules/_conference-programme.scss +0 -1
- data/app/assets/stylesheets/decidim/modules/_confirm.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_conversation.scss +50 -0
- data/app/assets/stylesheets/decidim/modules/_data-picker.scss +9 -11
- data/app/assets/stylesheets/decidim/modules/_definition-data.scss +6 -1
- data/app/assets/stylesheets/decidim/modules/_docs-manager.scss +0 -1
- data/app/assets/stylesheets/decidim/modules/_extra.scss +0 -2
- data/app/assets/stylesheets/decidim/modules/_filters.scss +25 -1
- data/app/assets/stylesheets/decidim/modules/_floating-helper.scss +20 -8
- data/app/assets/stylesheets/decidim/modules/_footer.scss +8 -4
- data/app/assets/stylesheets/decidim/modules/_forms.scss +63 -4
- data/app/assets/stylesheets/decidim/modules/_horizontal-tabs.scss +64 -1
- data/app/assets/stylesheets/decidim/modules/_inline-filters.scss +6 -3
- data/app/assets/stylesheets/decidim/modules/_input-gallery.scss +10 -0
- data/app/assets/stylesheets/decidim/modules/_input-mentions.scss +25 -7
- data/app/assets/stylesheets/decidim/modules/_input-multiple-mentions.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_map.scss +11 -0
- data/app/assets/stylesheets/decidim/modules/_margins.scss +8 -7
- data/app/assets/stylesheets/decidim/modules/_messages.scss +18 -18
- data/app/assets/stylesheets/decidim/modules/_modules.scss +75 -72
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +176 -26
- data/app/assets/stylesheets/decidim/modules/_notification.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_order-by.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_process-nav.scss +5 -2
- data/app/assets/stylesheets/decidim/modules/_process-phase.scss +2 -4
- data/app/assets/stylesheets/decidim/modules/_process-stats.scss +2 -2
- data/app/assets/stylesheets/decidim/modules/_progress-bar.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_reveal.scss +6 -0
- data/app/assets/stylesheets/decidim/modules/_signup.scss +6 -5
- data/app/assets/stylesheets/decidim/modules/_static-pages.scss +0 -1
- data/app/assets/stylesheets/decidim/modules/_sticky.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_tags.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_timeline.scss +1 -2
- data/app/assets/stylesheets/decidim/modules/_typography.scss +47 -8
- data/app/assets/stylesheets/decidim/modules/_versions.scss +0 -1
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +8 -0
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +86 -7
- data/app/assets/stylesheets/decidim/utils/_settings.scss +81 -69
- data/app/assets/stylesheets/decidim/vizzs.scss +8 -0
- data/app/assets/stylesheets/decidim/vizzs/_areachart.scss +0 -1
- data/app/assets/stylesheets/decidim/vizzs/_linechart.scss +0 -1
- data/app/assets/stylesheets/decidim/vizzs/_rowchart.scss +0 -1
- data/app/assets/stylesheets/decidim/vizzs/_vizzs.scss +5 -0
- data/app/assets/stylesheets/foundation-overrides/components/_button-group.scss +319 -0
- data/app/cells/decidim/activity/show.erb +24 -21
- data/app/cells/decidim/activity_cell.rb +2 -0
- data/app/cells/decidim/address_cell.rb +1 -1
- data/app/cells/decidim/amendable/amend_button_card_cell.rb +1 -5
- data/app/cells/decidim/amendable/promote_button_card_cell.rb +1 -1
- data/app/cells/decidim/announcement/show.erb +1 -1
- data/app/cells/decidim/author/comments.erb +1 -1
- data/app/cells/decidim/author/endorsements.erb +6 -0
- data/app/cells/decidim/author/flag.erb +5 -2
- data/app/cells/decidim/author/profile_inline.erb +0 -1
- data/app/cells/decidim/author/show.erb +2 -0
- data/app/cells/decidim/author/withdraw.erb +2 -2
- data/app/cells/decidim/author_cell.rb +9 -13
- data/app/cells/decidim/badge/show.erb +6 -6
- data/app/cells/decidim/badge/small.erb +2 -1
- data/app/cells/decidim/card/show.erb +4 -4
- data/app/cells/decidim/card_m/comments_counter.erb +1 -1
- data/app/cells/decidim/card_m/header.erb +4 -4
- data/app/cells/decidim/card_m/image.erb +1 -1
- data/app/cells/decidim/card_m/show.erb +2 -2
- data/app/cells/decidim/card_m_cell.rb +3 -2
- data/app/cells/decidim/collapsible_list/show.erb +3 -3
- data/app/cells/decidim/content_blocks/footer_sub_hero/show.erb +4 -4
- data/app/cells/decidim/content_blocks/hero_settings_form/show.erb +2 -2
- data/app/cells/decidim/content_blocks/how_to_participate/show.erb +8 -8
- data/app/cells/decidim/content_blocks/last_activity_cell.rb +1 -1
- data/app/cells/decidim/content_blocks/stats/show.erb +1 -1
- data/app/cells/decidim/content_blocks/sub_hero/show.erb +3 -3
- data/app/cells/decidim/diff/attribute.erb +10 -10
- data/app/cells/decidim/diff_cell.rb +11 -1
- data/app/cells/decidim/endorsement_buttons/select_identity_button.erb +10 -0
- data/app/cells/decidim/endorsement_buttons/show.erb +4 -0
- data/app/cells/decidim/endorsement_buttons_cell.rb +208 -0
- data/app/cells/decidim/endorsers_list/show.erb +16 -0
- data/app/cells/decidim/endorsers_list_cell.rb +29 -0
- data/app/cells/decidim/fingerprint_cell.rb +1 -0
- data/app/cells/decidim/follow_button/show.erb +13 -5
- data/app/cells/decidim/follow_button_cell.rb +29 -5
- data/app/cells/decidim/navbar_admin_link/show.erb +1 -1
- data/app/cells/decidim/navbar_admin_link_cell.rb +6 -0
- data/app/cells/decidim/newsletter_templates/base_cell.rb +30 -0
- data/app/cells/decidim/newsletter_templates/base_settings_form_cell.rb +13 -0
- data/app/cells/decidim/newsletter_templates/basic_only_text/show.erb +86 -0
- data/app/cells/decidim/newsletter_templates/basic_only_text_cell.rb +21 -0
- data/app/cells/decidim/newsletter_templates/basic_only_text_settings_form/show.erb +7 -0
- data/app/cells/decidim/newsletter_templates/basic_only_text_settings_form_cell.rb +8 -0
- data/app/cells/decidim/newsletter_templates/image_text_cta/show.erb +125 -0
- data/app/cells/decidim/newsletter_templates/image_text_cta_cell.rb +61 -0
- data/app/cells/decidim/newsletter_templates/image_text_cta_settings_form/show.erb +17 -0
- data/app/cells/decidim/newsletter_templates/image_text_cta_settings_form_cell.rb +8 -0
- data/app/cells/decidim/notifications/show.erb +1 -1
- data/app/cells/decidim/profile/show.erb +2 -2
- data/app/cells/decidim/profile/user_group_tabs.erb +10 -5
- data/app/cells/decidim/profile/user_tabs.erb +16 -14
- data/app/cells/decidim/profile_cell.rb +18 -0
- data/app/cells/decidim/profile_sidebar/show.erb +16 -16
- data/app/cells/decidim/profile_sidebar_cell.rb +1 -0
- data/app/cells/decidim/search_results_section/show.erb +1 -1
- data/app/cells/decidim/tags_cell.rb +32 -2
- data/app/cells/decidim/user_activity/show.erb +19 -1
- data/app/cells/decidim/user_activity_cell.rb +6 -0
- data/app/cells/decidim/user_conversation/conversation_header.erb +14 -0
- data/app/cells/decidim/user_conversation/messages.erb +15 -0
- data/app/cells/decidim/user_conversation/new.erb +15 -0
- data/app/cells/decidim/user_conversation/reply.erb +17 -0
- data/app/cells/decidim/user_conversation/show.erb +20 -0
- data/app/cells/decidim/user_conversation_cell.rb +75 -0
- data/app/cells/decidim/user_conversations/add_conversation_users.erb +25 -0
- data/app/cells/decidim/user_conversations/conversation_item.erb +38 -0
- data/app/cells/decidim/user_conversations/show.erb +58 -0
- data/app/cells/decidim/user_conversations_cell.rb +40 -0
- data/app/cells/decidim/user_group_admin_membership_profile/footer.erb +3 -3
- data/app/cells/decidim/user_profile/footer.erb +1 -1
- data/app/cells/decidim/user_profile/unlinked_user_data.erb +16 -0
- data/app/cells/decidim/user_profile/user_data.erb +1 -1
- data/app/cells/decidim/user_profile_cell.rb +7 -1
- data/app/cells/decidim/user_timeline_cell.rb +4 -0
- data/app/cells/decidim/version/show.erb +31 -0
- data/app/{views/decidim/shared/_version_author.html.erb → cells/decidim/version_author/show.erb} +1 -1
- data/app/cells/decidim/version_author_cell.rb +9 -0
- data/app/cells/decidim/version_cell.rb +83 -0
- data/app/cells/decidim/versions_list/show.erb +32 -0
- data/app/cells/decidim/versions_list_cell.rb +64 -0
- data/app/cells/decidim/versions_list_item/show.erb +20 -0
- data/app/cells/decidim/versions_list_item_cell.rb +51 -0
- data/app/cells/decidim/wizard_step_form/wizard_aside.erb +1 -1
- data/app/cells/decidim/wizard_step_form/wizard_header.erb +2 -2
- data/app/cells/decidim/wizard_step_form_cell.rb +4 -1
- data/app/commands/decidim/attachment_methods.rb +40 -0
- data/app/commands/decidim/create_registration.rb +2 -1
- data/app/commands/decidim/create_user_group.rb +12 -0
- data/app/commands/decidim/destroy_account.rb +12 -0
- data/app/commands/decidim/endorse_resource.rb +64 -0
- data/app/commands/decidim/gallery_methods.rb +64 -0
- data/app/commands/decidim/invite_user_again.rb +2 -4
- data/app/commands/decidim/messaging/reply_to_conversation.rb +34 -3
- data/app/commands/decidim/messaging/start_conversation.rb +36 -5
- data/app/commands/decidim/unendorse_resource.rb +38 -0
- data/app/commands/decidim/update_notifications_settings.rb +1 -0
- data/app/commands/decidim/update_user_group.rb +14 -1
- data/app/controllers/concerns/decidim/impersonate_users.rb +13 -0
- data/app/controllers/concerns/decidim/resource_versions_concern.rb +28 -0
- data/app/controllers/decidim/devise/registrations_controller.rb +2 -4
- data/app/controllers/decidim/devise/sessions_controller.rb +5 -0
- data/app/controllers/decidim/endorsements_controller.rb +71 -0
- data/app/controllers/decidim/messaging/conversations_controller.rb +52 -12
- data/app/controllers/decidim/newsletters_controller.rb +2 -2
- data/app/controllers/decidim/profiles_controller.rb +6 -0
- data/app/controllers/decidim/scopes_controller.rb +1 -0
- data/app/controllers/decidim/user_activities_controller.rb +19 -2
- data/app/controllers/decidim/user_conversations_controller.rb +142 -0
- data/app/controllers/decidim/user_timeline_controller.rb +19 -2
- data/app/events/decidim/resource_endorsed_event.rb +35 -0
- data/app/events/decidim/user_group_admin_event.rb +37 -0
- data/app/events/decidim/user_group_created_event.rb +6 -0
- data/app/events/decidim/user_group_updated_event.rb +6 -0
- data/app/forms/decidim/attachment_form.rb +1 -0
- data/app/forms/decidim/messaging/conversation_form.rb +10 -4
- data/app/forms/decidim/notifications_settings_form.rb +6 -0
- data/app/forms/decidim/registration_form.rb +1 -0
- data/app/functions/decidim/core/component_finder_base.rb +10 -3
- data/app/functions/decidim/core/component_list_base.rb +8 -2
- data/app/functions/decidim/core/user_entity_finder.rb +33 -0
- data/app/functions/decidim/core/user_entity_list.rb +31 -0
- data/app/helpers/concerns/decidim/flash_helper_extensions.rb +47 -0
- data/app/helpers/decidim/action_authorization_helper.rb +24 -2
- data/app/helpers/decidim/amendments_helper.rb +5 -3
- data/app/helpers/decidim/application_helper.rb +7 -1
- data/app/helpers/decidim/check_boxes_tree_helper.rb +4 -5
- data/app/helpers/decidim/cta_button_helper.rb +1 -1
- data/app/helpers/decidim/decidim_form_helper.rb +23 -0
- data/app/helpers/decidim/endorsable_helper.rb +93 -0
- data/app/helpers/decidim/filters_helper.rb +15 -5
- data/app/helpers/decidim/followable_helper.rb +11 -0
- data/app/helpers/decidim/layout_helper.rb +23 -5
- data/app/helpers/decidim/map_helper.rb +15 -2
- data/app/helpers/decidim/markup_helper.rb +9 -0
- data/app/helpers/decidim/messaging/conversation_helper.rb +61 -7
- data/app/helpers/decidim/orders_helper.rb +10 -1
- data/app/helpers/decidim/participatory_space_helpers.rb +1 -1
- data/app/helpers/decidim/resource_versions_helper.rb +24 -7
- data/app/helpers/decidim/rich_text_editor_helper.rb +1 -0
- data/app/helpers/decidim/sanitize_helper.rb +10 -2
- data/app/helpers/decidim/tooltip_helper.rb +1 -1
- data/app/helpers/decidim/traceability_helper.rb +2 -8
- data/app/helpers/decidim/user_profile_helper.rb +1 -1
- data/app/helpers/decidim/widget_urls_helper.rb +4 -2
- data/app/jobs/decidim/event_publisher_job.rb +1 -1
- data/app/mailers/concerns/decidim/multitenant_asset_host.rb +33 -0
- data/app/mailers/decidim/application_mailer.rb +1 -0
- data/app/mailers/decidim/messaging/conversation_mailer.rb +53 -4
- data/app/mailers/decidim/newsletter_mailer.rb +22 -4
- data/app/middleware/decidim/strip_x_forwarded_host.rb +14 -0
- data/app/models/decidim/action_log.rb +1 -1
- data/app/models/decidim/amendment.rb +0 -18
- data/app/models/decidim/authorization.rb +24 -0
- data/app/models/decidim/component.rb +7 -0
- data/app/models/decidim/content_block.rb +5 -3
- data/app/models/decidim/endorsement.rb +30 -0
- data/app/models/decidim/messaging/conversation.rb +39 -11
- data/app/models/decidim/messaging/message.rb +31 -5
- data/app/models/decidim/messaging/participation.rb +1 -1
- data/app/models/decidim/messaging/receipt.rb +8 -0
- data/app/models/decidim/newsletter.rb +7 -1
- data/app/models/decidim/organization.rb +16 -7
- data/app/models/decidim/user.rb +32 -0
- data/app/models/decidim/user_group.rb +23 -0
- data/app/permissions/decidim/permissions.rb +19 -6
- data/app/presenters/decidim/admin_log/user_presenter.rb +1 -1
- data/app/presenters/decidim/metric_charts_presenter.rb +33 -13
- data/app/presenters/decidim/nil_presenter.rb +29 -0
- data/app/presenters/decidim/resource_locator_presenter.rb +2 -1
- data/app/presenters/decidim/user_group_presenter.rb +1 -1
- data/app/presenters/decidim/user_presenter.rb +6 -0
- data/app/queries/decidim/metric_manage.rb +5 -0
- data/app/queries/decidim/metrics/followers_metric_manage.rb +1 -6
- data/app/queries/decidim/user_groups/admin_memberships.rb +3 -3
- data/app/services/decidim/activity_search.rb +1 -0
- data/app/services/decidim/base_diff_renderer.rb +25 -3
- data/app/services/decidim/events_manager.rb +4 -1
- data/app/types/decidim/core/decidim_type.rb +0 -4
- data/app/types/decidim/core/has_endorsable_input_sort.rb +17 -0
- data/app/types/decidim/core/has_timestamp_input_filter.rb +52 -0
- data/app/types/decidim/core/has_timestamp_input_sort.rb +12 -0
- data/app/types/decidim/core/user_entity_input_filter.rb +81 -0
- data/app/types/decidim/core/user_entity_input_sort.rb +24 -0
- data/app/types/decidim/core/user_group_type.rb +17 -5
- data/app/types/decidim/core/user_type.rb +17 -6
- data/app/uploaders/decidim/attachment_uploader.rb +1 -1
- data/app/uploaders/decidim/avatar_uploader.rb +4 -0
- data/app/uploaders/decidim/image_uploader.rb +28 -4
- data/app/uploaders/decidim/newsletter_template_image_uploader.rb +36 -0
- data/app/views/decidim/account/delete.html.erb +6 -3
- data/app/views/decidim/account/show.html.erb +17 -10
- data/app/views/decidim/amendments/_edit_form_fields.html.erb +2 -0
- data/app/views/decidim/amendments/_similar_emendation.html.erb +4 -4
- data/app/views/decidim/amendments/compare_draft.html.erb +2 -2
- data/app/views/decidim/amendments/edit_draft.html.erb +2 -2
- data/app/views/decidim/amendments/new.html.erb +2 -2
- data/app/views/decidim/amendments/preview_draft.html.erb +2 -2
- data/app/views/decidim/amendments/review.html.erb +3 -3
- data/app/views/decidim/application/_collection.html.erb +2 -2
- data/app/views/decidim/application/_document.html.erb +4 -4
- data/app/views/decidim/application/_documents.html.erb +1 -1
- data/app/views/decidim/application/_photos.html.erb +1 -1
- data/app/views/decidim/authorization_modals/show.html.erb +1 -1
- data/app/views/decidim/data_portability/show.html.erb +3 -0
- data/app/views/decidim/devise/confirmations/new.html.erb +3 -3
- data/app/views/decidim/devise/invitations/edit.html.erb +13 -13
- data/app/views/decidim/devise/omniauth_registrations/new.html.erb +5 -3
- data/app/views/decidim/devise/passwords/edit.html.erb +5 -3
- data/app/views/decidim/devise/passwords/new.html.erb +3 -3
- data/app/views/decidim/devise/registrations/edit.html.erb +2 -1
- data/app/views/decidim/devise/registrations/new.html.erb +7 -8
- data/app/views/decidim/devise/sessions/new.html.erb +4 -6
- data/app/views/decidim/devise/shared/_newsletter_modal.html.erb +3 -3
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +3 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +4 -1
- data/app/views/decidim/devise/unlocks/new.html.erb +3 -3
- data/app/views/decidim/doorkeeper/authorizations/new.html.erb +2 -2
- data/app/views/decidim/endorsements/_identity.html.erb +9 -0
- data/app/views/decidim/endorsements/identities.html.erb +12 -0
- data/app/views/decidim/endorsements/update_buttons_and_counters.js.erb +20 -0
- data/app/views/decidim/errors/internal_server_error.html.erb +2 -2
- data/app/views/decidim/errors/not_found.html.erb +2 -2
- data/app/views/decidim/gamification/badges/index.html.erb +4 -4
- data/app/views/decidim/group_admins/index.html.erb +6 -4
- data/app/views/decidim/group_invites/index.html.erb +5 -2
- data/app/views/decidim/group_members/index.html.erb +6 -4
- data/app/views/decidim/groups/_form.html.erb +2 -0
- data/app/views/decidim/groups/edit.html.erb +4 -2
- data/app/views/decidim/groups/new.html.erb +2 -2
- data/app/views/decidim/last_activities/index.html.erb +2 -0
- data/app/views/decidim/messaging/conversation_mailer/comanagers_new_conversation.html.erb +17 -0
- data/app/views/decidim/messaging/conversation_mailer/comanagers_new_message.html.erb +17 -0
- data/app/views/decidim/messaging/conversation_mailer/new_conversation.html.erb +2 -2
- data/app/views/decidim/messaging/conversation_mailer/new_group_conversation.html.erb +17 -0
- data/app/views/decidim/messaging/conversation_mailer/new_group_message.html.erb +17 -0
- data/app/views/decidim/messaging/conversation_mailer/new_message.html.erb +2 -2
- data/app/views/decidim/messaging/conversations/_add_conversation_users.html.erb +24 -0
- data/app/views/decidim/messaging/conversations/_conversation.html.erb +54 -0
- data/app/views/decidim/messaging/conversations/_messages.html.erb +15 -0
- data/app/views/decidim/messaging/conversations/_new_conversation_button.html.erb +33 -0
- data/app/views/decidim/messaging/conversations/_reply.html.erb +3 -3
- data/app/views/decidim/messaging/conversations/_show.html.erb +34 -15
- data/app/views/decidim/messaging/conversations/_start.html.erb +7 -1
- data/app/views/decidim/messaging/conversations/create.js.erb +1 -1
- data/app/views/decidim/messaging/conversations/index.html.erb +34 -29
- data/app/views/decidim/messaging/conversations/new.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/show.html.erb +8 -4
- data/app/views/decidim/messaging/conversations/update.js.erb +1 -1
- data/app/views/decidim/newsletter_mailer/newsletter.html.erb +2 -2
- data/app/views/decidim/newsletters/show.html.erb +8 -1
- data/app/views/decidim/notifications/index.html.erb +4 -2
- data/app/views/decidim/notifications_settings/show.html.erb +14 -1
- data/app/views/decidim/own_user_groups/index.html.erb +4 -0
- data/app/views/decidim/pages/_standalone.html.erb +1 -1
- data/app/views/decidim/pages/_tabbed.html.erb +5 -5
- data/app/views/decidim/pages/index.html.erb +22 -13
- data/app/views/decidim/profiles/_user_follow.erb +3 -3
- data/app/views/decidim/profiles/show.html.erb +2 -0
- data/app/views/decidim/scopes/_scopes_picker_input.html.erb +11 -4
- data/app/views/decidim/scopes/picker.html.erb +26 -16
- data/app/views/decidim/searches/_count.html.erb +14 -11
- data/app/views/decidim/searches/_filters.html.erb +2 -2
- data/app/views/decidim/searches/index.html.erb +5 -3
- data/app/views/decidim/shared/_check_boxes_tree.html.erb +5 -3
- data/app/views/decidim/shared/_confirm_modal.html.erb +18 -0
- data/app/views/decidim/shared/_embed_modal.html.erb +4 -1
- data/app/views/decidim/shared/_extended_navigation_bar.html.erb +2 -2
- data/app/views/decidim/shared/_filter_form_help.erb +8 -0
- data/app/views/decidim/shared/_floating_help.html.erb +7 -7
- data/app/views/decidim/shared/_login_modal.html.erb +4 -4
- data/app/views/decidim/shared/_orders.html.erb +16 -5
- data/app/views/decidim/shared/_results_per_page.html.erb +16 -6
- data/app/views/decidim/shared/_share_modal.html.erb +8 -4
- data/app/views/decidim/shared/_static_map.html.erb +1 -1
- data/app/views/decidim/shared/participatory_space_filters/_filters.html.erb +1 -1
- data/app/views/decidim/user_activities/index.html.erb +4 -0
- data/app/views/decidim/user_activities/index.js.erb +14 -0
- data/app/views/decidim/user_conversations/index.html.erb +4 -0
- data/app/views/decidim/user_conversations/show.html.erb +4 -0
- data/app/views/decidim/user_conversations/update.js.erb +8 -0
- data/app/views/decidim/user_interests/_scopes.html.erb +12 -10
- data/app/views/decidim/user_interests/show.html.erb +4 -1
- data/app/views/decidim/user_timeline/index.html.erb +5 -1
- data/app/views/decidim/user_timeline/index.js.erb +14 -0
- data/app/views/kaminari/decidim/_first_page.html.erb +5 -1
- data/app/views/kaminari/decidim/_last_page.html.erb +5 -1
- data/app/views/kaminari/decidim/_next_page.html.erb +6 -1
- data/app/views/kaminari/decidim/_page.html.erb +2 -2
- data/app/views/kaminari/decidim/_paginator.html.erb +16 -14
- data/app/views/kaminari/decidim/_prev_page.html.erb +6 -1
- data/app/views/layouts/decidim/_application.html.erb +4 -2
- data/app/views/layouts/decidim/_cookie_warning.html.erb +1 -1
- data/app/views/layouts/decidim/_edit_link.html.erb +0 -0
- data/app/views/layouts/decidim/_head.html.erb +2 -0
- data/app/views/layouts/decidim/_js_configuration.html.erb +28 -0
- data/app/views/layouts/decidim/_language_chooser.html.erb +10 -5
- data/app/views/layouts/decidim/_logo.html.erb +2 -22
- data/app/views/layouts/decidim/_mailer_logo.html.erb +2 -22
- data/app/views/layouts/decidim/_main_footer.html.erb +3 -1
- data/app/views/layouts/decidim/_mini_footer.html.erb +7 -7
- data/app/views/layouts/decidim/_omnipresent_banner.html.erb +1 -1
- data/app/views/layouts/decidim/_organization_colors.html.erb +4 -3
- data/app/views/layouts/decidim/_social_media_links.html.erb +15 -10
- data/app/views/layouts/decidim/_topbar_search.html.erb +12 -2
- data/app/views/layouts/decidim/_user_menu.html.erb +6 -6
- data/app/views/layouts/decidim/_wrapper.html.erb +21 -16
- data/app/views/layouts/decidim/newsletter_base.html.erb +46 -0
- data/app/views/layouts/decidim/user_profile.html.erb +8 -3
- data/app/views/layouts/decidim/widget.html.erb +1 -0
- data/config/initializers/devise.rb +11 -3
- data/config/initializers/invisible_captcha.rb +1 -0
- data/config/initializers/omniauth.rb +7 -1
- data/config/initializers/rack_attack.rb +25 -16
- data/config/locales/ar.yml +7 -5
- data/config/locales/bg-BG.yml +1512 -0
- data/config/locales/ca.yml +258 -6
- data/config/locales/cs.yml +297 -37
- data/config/locales/da-DK.yml +9 -0
- data/config/locales/de.yml +279 -5
- data/config/locales/el.yml +1443 -5
- data/config/locales/en.yml +263 -11
- data/config/locales/es-MX.yml +257 -5
- data/config/locales/es-PY.yml +257 -5
- data/config/locales/es.yml +257 -5
- data/config/locales/et-EE.yml +9 -0
- data/config/locales/eu.yml +7 -2
- data/config/locales/fi-plain.yml +258 -6
- data/config/locales/fi.yml +319 -67
- data/config/locales/fr-CA.yml +1585 -0
- data/config/locales/fr.yml +263 -5
- data/config/locales/ga-IE.yml +9 -0
- data/config/locales/gl.yml +7 -2
- data/config/locales/hr-HR.yml +9 -0
- data/config/locales/hu.yml +87 -5
- data/config/locales/id-ID.yml +7 -2
- data/config/locales/is-IS.yml +1 -0
- data/config/locales/it.yml +279 -27
- data/config/locales/ja-JP.yml +1578 -0
- data/config/locales/lt-LT.yml +9 -0
- data/config/locales/lv-LV.yml +1485 -0
- data/config/locales/mt-MT.yml +9 -0
- data/config/locales/nl.yml +261 -6
- data/config/locales/no.yml +117 -41
- data/config/locales/pl.yml +755 -406
- data/config/locales/pt-BR.yml +8 -4
- data/config/locales/pt.yml +875 -536
- data/config/locales/ro-RO.yml +1603 -0
- data/config/locales/ru.yml +6 -1
- data/config/locales/sk-SK.yml +1426 -0
- data/config/locales/sk.yml +1441 -0
- data/config/locales/sl.yml +71 -0
- data/config/locales/sr-CS.yml +129 -0
- data/config/locales/sv.yml +323 -24
- data/config/locales/tr-TR.yml +7 -2
- data/config/locales/uk.yml +6 -1
- data/config/routes.rb +5 -0
- data/db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb +2 -2
- data/db/migrate/20191130151925_create_decidim_endorsements.rb +13 -0
- data/db/migrate/20191204075509_add_session_token_to_users.rb +7 -0
- data/db/migrate/20200211173227_add_direct_message_types_to_users.rb +12 -0
- data/db/migrate/20200320105904_index_foreign_keys_in_decidim_action_logs.rb +9 -0
- data/db/migrate/20200320105905_index_foreign_keys_in_decidim_amendments.rb +7 -0
- data/db/migrate/20200320105909_index_foreign_keys_in_decidim_authorizations.rb +7 -0
- data/db/migrate/20200320105917_index_foreign_keys_in_decidim_contextual_help_sections.rb +7 -0
- data/db/migrate/20200320105919_index_foreign_keys_in_decidim_endorsements.rb +7 -0
- data/db/migrate/20200320105923_index_foreign_keys_in_decidim_notifications.rb +7 -0
- data/db/migrate/20200320105927_index_foreign_keys_in_oauth_access_grants.rb +7 -0
- data/db/migrate/20200323094443_add_id_to_content_blocks_scope.rb +7 -0
- data/db/migrate/20200326102407_rename_scope_column.rb +7 -0
- data/db/migrate/20200327082257_migrate_newsletters_to_templates.rb +33 -0
- data/db/migrate/20200327082954_remove_newsletter_body.rb +7 -0
- data/db/migrate/20200401073419_add_index_on_content_block_scope_id.rb +11 -0
- data/db/seeds.rb +1 -1
- data/{app/controllers/concerns → lib}/decidim/action_authorization.rb +0 -0
- data/lib/decidim/api/author_interface.rb +4 -0
- data/lib/decidim/api/endorsable_interface.rb +22 -0
- data/lib/decidim/api/participatory_space_interface.rb +2 -0
- data/lib/decidim/api/timestamps_interface.rb +2 -2
- data/lib/decidim/coauthorable.rb +1 -1
- data/lib/decidim/component_manifest.rb +14 -0
- data/lib/decidim/content_parsers.rb +1 -0
- data/lib/decidim/content_parsers/user_group_parser.rb +61 -0
- data/lib/decidim/content_parsers/user_parser.rb +3 -5
- data/lib/decidim/content_renderers.rb +1 -0
- data/lib/decidim/content_renderers/user_group_renderer.rb +30 -0
- data/lib/decidim/core.rb +65 -21
- data/lib/decidim/core/api.rb +1 -0
- data/lib/decidim/core/engine.rb +88 -6
- data/lib/decidim/core/test.rb +8 -0
- data/lib/decidim/core/test/factories.rb +103 -3
- data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +79 -0
- data/lib/decidim/core/test/shared_examples/back_to_list_button_examples.rb +17 -0
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +17 -2
- data/lib/decidim/core/test/shared_examples/edit_link_shared_examples.rb +5 -1
- data/lib/decidim/core/test/shared_examples/endorsable_interface_examples.rb +22 -0
- data/lib/decidim/core/test/shared_examples/endorsements_controller_shared_context.rb +22 -0
- data/lib/decidim/core/test/shared_examples/follows_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/input_sort_examples.rb +21 -0
- data/lib/decidim/core/test/shared_examples/logo_email.rb +20 -0
- data/lib/decidim/core/test/shared_examples/metric_manage_shared_context.rb +9 -0
- data/lib/decidim/core/test/shared_examples/permissions.rb +143 -0
- data/lib/decidim/core/test/shared_examples/reports_examples.rb +4 -4
- data/lib/decidim/core/test/shared_examples/rich_text_editor_examples.rb +3 -3
- data/lib/decidim/core/test/shared_examples/simple_event.rb +1 -0
- data/lib/decidim/core/test/shared_examples/system_endorse_resource_examples.rb +165 -0
- data/lib/decidim/core/test/shared_examples/traceable_interface_examples.rb +3 -3
- data/lib/decidim/core/test/shared_examples/with_endorsable_permissions_examples.rb +89 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/endorsable.rb +25 -0
- data/lib/decidim/events.rb +1 -0
- data/lib/decidim/events/user_group_event.rb +45 -0
- data/lib/decidim/exporters/csv.rb +1 -1
- data/lib/decidim/filter_form_builder.rb +15 -6
- data/lib/decidim/form_builder.rb +209 -23
- data/lib/decidim/has_attachments.rb +1 -1
- data/lib/decidim/participable.rb +6 -0
- data/lib/decidim/participatory_space_manifest.rb +15 -0
- data/lib/decidim/query_extensions.rb +9 -15
- data/lib/decidim/settings_manifest.rb +15 -1
- data/lib/decidim/view_model.rb +4 -0
- data/lib/tasks/decidim_tasks.rake +1 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ro.js +15 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.sk.js +14 -0
- data/vendor/assets/javascripts/svg4everybody.min.js +1 -2
- data/vendor/assets/javascripts/tribute.js +11 -4
- metadata +187 -31
- data/app/assets/javascripts/decidim/vizzs/orgchart.js.es6 +0 -699
- data/app/assets/stylesheets/decidim/email.css +0 -1403
- data/app/assets/stylesheets/decidim/modules/_input-hashtags.scss +0 -124
- data/app/resolvers/decidim/core/user_resolver.rb +0 -61
- data/app/views/decidim/messaging/conversations/_message.html.erb +0 -14
@@ -29,6 +29,7 @@ shared_context "when a simple event" do
|
|
29
29
|
let(:resource_path) { resource_locator(resource).path }
|
30
30
|
let(:resource_url) { resource_locator(resource).url }
|
31
31
|
let(:resource_title) { resource.title["en"] }
|
32
|
+
# to be used when resource is a component resource, not a participatory space, in which case should be overriden
|
32
33
|
let(:participatory_space) { resource.participatory_space }
|
33
34
|
let(:participatory_space_title) { participatory_space.title["en"] }
|
34
35
|
let(:participatory_space_path) { Decidim::ResourceLocatorPresenter.new(participatory_space).path }
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
shared_context "with resources to be endorsed or not" do
|
6
|
+
include_context "with a component"
|
7
|
+
|
8
|
+
# Should be overriden and create one main resource
|
9
|
+
let!(:resource) {}
|
10
|
+
# the name of the resource to be clicked from the component view
|
11
|
+
let(:resource_name) {}
|
12
|
+
# Should be overriden and create 3 extra resources in the current component
|
13
|
+
let!(:resources) {}
|
14
|
+
end
|
15
|
+
shared_examples "Endorse resource system specs" do
|
16
|
+
def expect_page_not_to_include_endorsements
|
17
|
+
expect(page).to have_no_button("Endorse")
|
18
|
+
expect(page).to have_no_css("#resource-#{resource.id}-endorsements-count")
|
19
|
+
end
|
20
|
+
|
21
|
+
def visit_resource
|
22
|
+
visit_component
|
23
|
+
click_link resource_name
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when endorsements are not enabled" do
|
27
|
+
let(:component_traits) { [:with_votes_enabled, :with_endorsements_disabled] }
|
28
|
+
|
29
|
+
context "when the user is not logged in" do
|
30
|
+
it "doesn't show the endorse resource button and counts" do
|
31
|
+
visit_resource
|
32
|
+
expect_page_not_to_include_endorsements
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when the user is logged in" do
|
37
|
+
before do
|
38
|
+
login_as user, scope: :user
|
39
|
+
end
|
40
|
+
|
41
|
+
it "doesn't show the endorse resource button and counts" do
|
42
|
+
visit_resource
|
43
|
+
expect_page_not_to_include_endorsements
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when endorsements are enabled but blocked" do
|
49
|
+
let(:component_traits) { [:with_endorsements_enabled, :with_endorsements_blocked] }
|
50
|
+
|
51
|
+
it "shows the endorsements count and the endorse button is disabled" do
|
52
|
+
visit_resource
|
53
|
+
expect(page).to have_css(".buttons__row span[disabled]")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when endorsements are enabled" do
|
58
|
+
let(:component_traits) { [:with_votes_enabled, :with_endorsements_enabled] }
|
59
|
+
|
60
|
+
context "when the user is not logged in" do
|
61
|
+
it "is given the option to sign in" do
|
62
|
+
visit_resource
|
63
|
+
within ".buttons__row", match: :first do
|
64
|
+
click_button "Endorse"
|
65
|
+
end
|
66
|
+
|
67
|
+
expect(page).to have_css("#loginModal", visible: :visible)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when the user is logged in" do
|
72
|
+
before do
|
73
|
+
login_as user, scope: :user
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when the resource is not endorsed yet" do
|
77
|
+
it "is able to endorse the resource" do
|
78
|
+
visit_resource
|
79
|
+
within ".buttons__row" do
|
80
|
+
click_button "Endorse"
|
81
|
+
expect(page).to have_button("Endorsed")
|
82
|
+
end
|
83
|
+
|
84
|
+
within "#resource-#{resource.id}-endorsements-count" do
|
85
|
+
expect(page).to have_content("1")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when the resource is already endorsed" do
|
91
|
+
let!(:endorsement) { create(:endorsement, resource: resource, author: user) }
|
92
|
+
|
93
|
+
it "is not able to endorse it again" do
|
94
|
+
visit_resource
|
95
|
+
within ".buttons__row" do
|
96
|
+
expect(page).to have_button("Endorsed")
|
97
|
+
expect(page).to have_no_button("Endorse ")
|
98
|
+
end
|
99
|
+
|
100
|
+
within "#resource-#{resource.id}-endorsements-count" do
|
101
|
+
expect(page).to have_content("1")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it "is able to undo the endorsement" do
|
106
|
+
visit_resource
|
107
|
+
within ".buttons__row" do
|
108
|
+
click_button "Endorsed"
|
109
|
+
expect(page).to have_button("Endorse")
|
110
|
+
end
|
111
|
+
|
112
|
+
within "#resource-#{resource.id}-endorsements-count" do
|
113
|
+
expect(page).to have_content("0")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "when verification is required" do
|
119
|
+
let(:permissions) do
|
120
|
+
{
|
121
|
+
endorse: {
|
122
|
+
authorization_handlers: {
|
123
|
+
"dummy_authorization_handler" => { "options" => {} }
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
before do
|
130
|
+
organization.available_authorizations = ["dummy_authorization_handler"]
|
131
|
+
organization.save!
|
132
|
+
component.update(permissions: permissions)
|
133
|
+
end
|
134
|
+
|
135
|
+
context "when user is NOT verified" do
|
136
|
+
it "is NOT able to endorse" do
|
137
|
+
visit_resource
|
138
|
+
within ".buttons__row", match: :first do
|
139
|
+
click_button "Endorse"
|
140
|
+
end
|
141
|
+
expect(page).to have_css("#authorizationModal", visible: :visible)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "when user IS verified" do
|
146
|
+
before do
|
147
|
+
handler_params = { user: user }
|
148
|
+
handler_name = "dummy_authorization_handler"
|
149
|
+
handler = Decidim::AuthorizationHandler.handler_for(handler_name, handler_params)
|
150
|
+
|
151
|
+
Decidim::Authorization.create_or_update_from(handler)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "IS able to endorse", :slow do
|
155
|
+
visit_resource
|
156
|
+
within ".buttons__row", match: :first do
|
157
|
+
click_button "Endorse"
|
158
|
+
end
|
159
|
+
expect(page).to have_button("Endorsed")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -4,9 +4,9 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
shared_examples_for "traceable interface" do
|
6
6
|
describe "traceable", versioning: true do
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
let(:version_author) { try(:author) || model.try(:creator_identity) || model.try(:normalized_author) }
|
8
|
+
|
9
|
+
before { Decidim.traceability.update!(model, version_author, title: "test") }
|
10
10
|
|
11
11
|
context "when field createdAt" do
|
12
12
|
let(:query) { "{ versions { createdAt } }" }
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
# users of this test should delare the `subject` variable.
|
6
|
+
shared_examples "with endorsable permissions can perform actions related to endorsable" do
|
7
|
+
let(:action_subject) { :endorsement }
|
8
|
+
let(:resource) { create :dummy_resource }
|
9
|
+
before do
|
10
|
+
context[:current_settings] = double(current_settings)
|
11
|
+
context[:resource] = resource
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "endorsing" do
|
15
|
+
describe "when endorsing" do
|
16
|
+
let(:action_name) { :create }
|
17
|
+
|
18
|
+
context "when endorsements are disabled" do
|
19
|
+
let(:current_settings) do
|
20
|
+
{
|
21
|
+
endorsements_enabled: false,
|
22
|
+
endorsements_blocked: false
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
it { is_expected.to eq false }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when endorsements are blocked" do
|
30
|
+
let(:current_settings) do
|
31
|
+
{
|
32
|
+
endorsements_enabled: true,
|
33
|
+
endorsements_blocked: true
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
it { is_expected.to eq false }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when user is authorized" do
|
41
|
+
let(:current_settings) do
|
42
|
+
{
|
43
|
+
endorsements_enabled: true,
|
44
|
+
endorsements_blocked: false
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
it { is_expected.to eq true }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "unendorsing" do
|
54
|
+
let(:action_name) { :unendorse }
|
55
|
+
|
56
|
+
context "when endorsements are disabled" do
|
57
|
+
let(:current_settings) do
|
58
|
+
{
|
59
|
+
endorsements_enabled: false,
|
60
|
+
endorsements_blocked: false
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
it { is_expected.to eq false }
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when endorsements are blocked" do
|
68
|
+
let(:current_settings) do
|
69
|
+
{
|
70
|
+
endorsements_enabled: true,
|
71
|
+
endorsements_blocked: true
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
it { is_expected.to eq false }
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when user is authorized" do
|
79
|
+
let(:current_settings) do
|
80
|
+
{
|
81
|
+
endorsements_enabled: true,
|
82
|
+
endorsements_blocked: false
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
it { is_expected.to eq true }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/decidim/core/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This concern contains the logic related with resources that can be endorsed.
|
5
|
+
# Thus, it is expected to be included into a resource that is wanted to be endorsable.
|
6
|
+
# This resource will have many `Decidim::Endorsement`s.
|
7
|
+
module Endorsable
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
has_many :endorsements,
|
12
|
+
as: :resource,
|
13
|
+
dependent: :destroy,
|
14
|
+
counter_cache: "endorsements_count"
|
15
|
+
|
16
|
+
# Public: Check if the user has endorsed the resource.
|
17
|
+
# - user_group: may be nil if user is not representing any user_group.
|
18
|
+
#
|
19
|
+
# Returns Boolean.
|
20
|
+
def endorsed_by?(user, user_group = nil)
|
21
|
+
endorsements.where(author: user, user_group: user_group).any?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/decidim/events.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Events
|
5
|
+
# This module is used to be included in event classes inheriting from SimpleEvent
|
6
|
+
# whose resource has an in the "extra" options a user_group in the keyword :group.
|
7
|
+
#
|
8
|
+
# It adds the group_name, group_nickname, group_path and group_url to the i18n interpolations.
|
9
|
+
module UserGroupEvent
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
i18n_attributes :group_name, :group_nickname, :group_path, :group_url
|
14
|
+
|
15
|
+
def group_nickname
|
16
|
+
group_presenter&.nickname.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def group_name
|
20
|
+
group_presenter&.name.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def group_path
|
24
|
+
group_presenter&.profile_path.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def group_url
|
28
|
+
group_presenter&.profile_url.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def group_presenter
|
32
|
+
return unless group
|
33
|
+
|
34
|
+
@group_presenter ||= Decidim::UserGroupPresenter.new(group)
|
35
|
+
end
|
36
|
+
|
37
|
+
def group
|
38
|
+
return unless extra[:group].is_a?(Decidim::UserGroup)
|
39
|
+
|
40
|
+
extra[:group]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -36,7 +36,7 @@ module Decidim
|
|
36
36
|
# Wrap the dependant check_boxes in a custom fieldset.
|
37
37
|
# checked parent checks its children
|
38
38
|
def check_boxes_tree(method, collection, options = {})
|
39
|
-
fieldset_wrapper(options
|
39
|
+
fieldset_wrapper(options.delete(:legend_title), "#{method}_check_boxes_tree_filter") do
|
40
40
|
@template.render("decidim/shared/check_boxes_tree",
|
41
41
|
form: self,
|
42
42
|
attribute: method,
|
@@ -48,9 +48,9 @@ module Decidim
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# Wrap the category select in a custom fieldset.
|
51
|
-
def categories_select(method, collection, options = {})
|
52
|
-
fieldset_wrapper(options
|
53
|
-
super(method, collection, options)
|
51
|
+
def categories_select(method, collection, options = {}, html_options = {})
|
52
|
+
fieldset_wrapper(options.delete(:legend_title), "#{method}_categories_select_filter") do
|
53
|
+
super(method, collection, options, html_options)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -61,6 +61,15 @@ module Decidim
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
# Wrap the custom select in a custom fieldset.
|
65
|
+
# Any *_select can be used as a custom_select; what changes is the superclass method,
|
66
|
+
# and this one knows which one has to be called, depending on the `name` provided.
|
67
|
+
def custom_select(name, method, collection, options = {})
|
68
|
+
fieldset_wrapper(options[:legend_title], "#{method}_#{name}_select_filter") do
|
69
|
+
send(:"#{name}_select", method, collection, options)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
64
73
|
# Wrap the scopes picker in a custom fieldset.
|
65
74
|
def scopes_picker(method, options = { checkboxes_on_top: true })
|
66
75
|
fieldset_wrapper(options[:legend_title], "#{method}_scopes_picker_filter") do
|
@@ -74,8 +83,8 @@ module Decidim
|
|
74
83
|
def fieldset_wrapper(legend_title, extra_class)
|
75
84
|
@template.content_tag(:div, "", class: "filters__section #{extra_class}") do
|
76
85
|
@template.content_tag(:fieldset) do
|
77
|
-
@template.content_tag(:legend) do
|
78
|
-
|
86
|
+
@template.content_tag(:legend, class: "mini-title") do
|
87
|
+
legend_title
|
79
88
|
end + yield
|
80
89
|
end
|
81
90
|
end
|
data/lib/decidim/form_builder.rb
CHANGED
@@ -78,12 +78,15 @@ module Decidim
|
|
78
78
|
safe_join [field_label, tabs_panels]
|
79
79
|
end
|
80
80
|
|
81
|
+
hashtaggable = options.delete(:hashtaggable)
|
81
82
|
tabs_content = content_tag(:div, class: "tabs-content", data: { tabs_content: tabs_id }) do
|
82
83
|
locales.each_with_index.inject("".html_safe) do |string, (locale, index)|
|
83
84
|
tab_content_id = "#{tabs_id}-#{name}-panel-#{index}"
|
84
85
|
string + content_tag(:div, class: tab_element_class_for("panel", index), id: tab_content_id) do
|
85
|
-
if
|
86
|
+
if hashtaggable
|
86
87
|
hashtaggable_text_field(type, name, locale, options.merge(label: false))
|
88
|
+
elsif type.to_sym == :editor
|
89
|
+
send(type, name_with_locale(name, locale), options.merge(label: false, hashtaggable: hashtaggable))
|
87
90
|
else
|
88
91
|
send(type, name_with_locale(name, locale), options.merge(label: false))
|
89
92
|
end
|
@@ -95,7 +98,7 @@ module Decidim
|
|
95
98
|
end
|
96
99
|
|
97
100
|
def translated_one_locale(type, name, locale, options = {})
|
98
|
-
return hashtaggable_text_field(type, name, locale, options) if options
|
101
|
+
return hashtaggable_text_field(type, name, locale, options) if options.delete(:hashtaggable)
|
99
102
|
|
100
103
|
send(
|
101
104
|
type,
|
@@ -112,6 +115,8 @@ module Decidim
|
|
112
115
|
#
|
113
116
|
# Renders form fields for each locale.
|
114
117
|
def hashtaggable_text_field(type, name, locale, options = {})
|
118
|
+
options[:hashtaggable] = true if type.to_sym == :editor
|
119
|
+
|
115
120
|
content_tag(:div, class: "hashtags__container") do
|
116
121
|
if options[:value]
|
117
122
|
send(type, name_with_locale(name, locale), options.merge(label: options[:label], value: options[:value][locale]))
|
@@ -175,18 +180,23 @@ module Decidim
|
|
175
180
|
#
|
176
181
|
# Renders a container with both hidden field and editor container
|
177
182
|
def editor(name, options = {})
|
178
|
-
options[:toolbar] ||= "basic"
|
179
|
-
options[:lines] ||= 10
|
180
183
|
options[:disabled] ||= false
|
181
|
-
|
182
|
-
|
184
|
+
toolbar = options.delete(:toolbar) || "basic"
|
185
|
+
lines = options.delete(:lines) || 10
|
186
|
+
label_text = options[:label].to_s
|
187
|
+
label_text = label_for(name) if label_text.blank?
|
188
|
+
options.delete(:required)
|
189
|
+
hashtaggable = options.delete(:hashtaggable)
|
190
|
+
hidden_options = extract_validations(name, options).merge(options)
|
191
|
+
|
192
|
+
content_tag(:div, class: "editor #{"hashtags__container" if hashtaggable}") do
|
183
193
|
template = ""
|
184
|
-
template += label(name,
|
185
|
-
template += hidden_field(name,
|
186
|
-
template += content_tag(:div, nil, class: "editor-container #{"js-hashtags" if
|
187
|
-
toolbar:
|
194
|
+
template += label(name, label_text + required_for_attribute(name)) if options.fetch(:label, true)
|
195
|
+
template += hidden_field(name, hidden_options)
|
196
|
+
template += content_tag(:div, nil, class: "editor-container #{"js-hashtags" if hashtaggable}", data: {
|
197
|
+
toolbar: toolbar,
|
188
198
|
disabled: options[:disabled]
|
189
|
-
}, style: "height: #{
|
199
|
+
}, style: "height: #{lines}rem")
|
190
200
|
template += error_for(name, options) if error?(name)
|
191
201
|
template.html_safe
|
192
202
|
end
|
@@ -199,9 +209,10 @@ module Decidim
|
|
199
209
|
# options - An optional Hash with options:
|
200
210
|
# - prompt - An optional String with the text to display as prompt.
|
201
211
|
# - disable_parents - A Boolean to disable parent categories. Defaults to `true`.
|
212
|
+
# html_options - HTML options for the select
|
202
213
|
#
|
203
214
|
# Returns a String.
|
204
|
-
def categories_select(name, collection, options = {})
|
215
|
+
def categories_select(name, collection, options = {}, html_options = {})
|
205
216
|
options = {
|
206
217
|
disable_parents: true
|
207
218
|
}.merge(options)
|
@@ -209,13 +220,14 @@ module Decidim
|
|
209
220
|
disable_parents = options[:disable_parents]
|
210
221
|
|
211
222
|
selected = object.send(name)
|
223
|
+
selected = selected.first if selected.is_a?(Array) && selected.length > 1
|
212
224
|
categories = categories_for_select(collection)
|
213
225
|
disabled = if disable_parents
|
214
226
|
disabled_categories_for(collection)
|
215
227
|
else
|
216
228
|
[]
|
217
229
|
end
|
218
|
-
|
230
|
+
|
219
231
|
select(name, @template.options_for_select(categories, selected: selected, disabled: disabled), options, html_options)
|
220
232
|
end
|
221
233
|
|
@@ -226,7 +238,7 @@ module Decidim
|
|
226
238
|
# If it's areas, we sort the selectable options alphabetically.
|
227
239
|
#
|
228
240
|
# Returns a String.
|
229
|
-
def areas_select(name, collection, options = {})
|
241
|
+
def areas_select(name, collection, options = {}, html_options = {})
|
230
242
|
selectables = if collection.first.is_a?(Decidim::Area)
|
231
243
|
assemblies = collection
|
232
244
|
.map { |a| [a.name[I18n.locale.to_s], a.id] }
|
@@ -247,7 +259,23 @@ module Decidim
|
|
247
259
|
)
|
248
260
|
end
|
249
261
|
|
250
|
-
select(name, selectables, options)
|
262
|
+
select(name, selectables, options, html_options)
|
263
|
+
end
|
264
|
+
|
265
|
+
# Public: Generates a select field for resource types.
|
266
|
+
#
|
267
|
+
# name - The name of the field (usually resource_type)
|
268
|
+
# collection - A collection of resource types.
|
269
|
+
# The options are sorted alphabetically.
|
270
|
+
#
|
271
|
+
# Returns a String.
|
272
|
+
def resources_select(name, collection, options = {})
|
273
|
+
resources =
|
274
|
+
collection
|
275
|
+
.map { |r| [I18n.t(r.split("::").last.underscore, scope: "decidim.components.component_order_selector.order"), r] }
|
276
|
+
.sort
|
277
|
+
|
278
|
+
select(name, @template.options_for_select(resources, selected: options[:selected]), options)
|
251
279
|
end
|
252
280
|
|
253
281
|
# Public: Generates a picker field for scope selection.
|
@@ -262,8 +290,11 @@ module Decidim
|
|
262
290
|
#
|
263
291
|
# Returns a String.
|
264
292
|
def scopes_picker(attribute, options = {})
|
293
|
+
id = "#{@object_name}_#{attribute}"
|
294
|
+
id = "#{self.options[:namespace]}_#{id}" if self.options.has_key?(:namespace)
|
295
|
+
|
265
296
|
picker_options = {
|
266
|
-
id:
|
297
|
+
id: id,
|
267
298
|
class: "picker-#{options[:multiple] ? "multiple" : "single"}",
|
268
299
|
name: "#{@object_name}[#{attribute}]"
|
269
300
|
}
|
@@ -273,7 +304,7 @@ module Decidim
|
|
273
304
|
prompt_params = yield(nil)
|
274
305
|
scopes = selected_scopes(attribute).map { |scope| [scope, yield(scope)] }
|
275
306
|
template = ""
|
276
|
-
template += label
|
307
|
+
template += "<label>#{label_for(attribute) + required_for_attribute(attribute)}</label>" unless options[:label] == false
|
277
308
|
template += @template.render("decidim/scopes/scopes_picker_input",
|
278
309
|
picker_options: picker_options,
|
279
310
|
prompt_params: prompt_params,
|
@@ -304,6 +335,7 @@ module Decidim
|
|
304
335
|
name: options[:name] || "#{@object_name}[#{attribute}]"
|
305
336
|
}
|
306
337
|
picker_options[:class] += " is-invalid-input" if error?(attribute)
|
338
|
+
picker_options[:class] += " picker-autosort" if options[:autosort]
|
307
339
|
|
308
340
|
items = object.send(attribute).collect { |item| [item, yield(item)] }
|
309
341
|
|
@@ -367,22 +399,29 @@ module Decidim
|
|
367
399
|
# attribute - The String name of the attribute to buidl the field.
|
368
400
|
# options - A Hash with options to build the field.
|
369
401
|
# * optional: Whether the file can be optional or not.
|
402
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
403
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
370
404
|
def upload(attribute, options = {})
|
371
405
|
self.multipart = true
|
372
406
|
options[:optional] = options[:optional].nil? ? true : options[:optional]
|
407
|
+
alt_text = label_for(attribute)
|
373
408
|
|
374
409
|
file = object.send attribute
|
375
410
|
template = ""
|
376
411
|
template += label(attribute, label_for(attribute) + required_for_attribute(attribute))
|
412
|
+
template += upload_help(attribute, options)
|
377
413
|
template += @template.file_field @object_name, attribute
|
378
414
|
|
415
|
+
template += extension_whitelist_help(options[:extension_whitelist]) if options[:extension_whitelist].present?
|
416
|
+
template += image_dimensions_help(options[:dimensions_info]) if options[:dimensions_info].present?
|
417
|
+
|
379
418
|
if file_is_image?(file)
|
380
419
|
template += if file.present?
|
381
420
|
@template.content_tag :label, I18n.t("current_image", scope: "decidim.forms")
|
382
421
|
else
|
383
422
|
@template.content_tag :label, I18n.t("default_image", scope: "decidim.forms")
|
384
423
|
end
|
385
|
-
template += @template.link_to @template.image_tag(file.url), file.url, target: "_blank", rel: "noopener"
|
424
|
+
template += @template.link_to @template.image_tag(file.url, alt: alt_text), file.url, target: "_blank", rel: "noopener"
|
386
425
|
elsif file_is_present?(file)
|
387
426
|
template += @template.label_tag I18n.t("current_file", scope: "decidim.forms")
|
388
427
|
template += @template.link_to file.file.filename, file.url, target: "_blank", rel: "noopener"
|
@@ -407,6 +446,56 @@ module Decidim
|
|
407
446
|
|
408
447
|
template.html_safe
|
409
448
|
end
|
449
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
450
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
451
|
+
|
452
|
+
def upload_help(attribute, _options = {})
|
453
|
+
file = object.send attribute
|
454
|
+
|
455
|
+
content_tag(:div, class: "help-text") do
|
456
|
+
file_size_validator = object.singleton_class.validators_on(
|
457
|
+
attribute
|
458
|
+
).find { |validator| validator.is_a?(::ActiveModel::Validations::FileSizeValidator) }
|
459
|
+
if file_size_validator
|
460
|
+
lte = file_size_validator.options[:less_than_or_equal_to]
|
461
|
+
max_file_size = lte.call(nil) if lte && lte.lambda?
|
462
|
+
end
|
463
|
+
|
464
|
+
help_scope = begin
|
465
|
+
if file.is_a?(Decidim::ImageUploader)
|
466
|
+
"decidim.forms.file_help.image"
|
467
|
+
else
|
468
|
+
"decidim.forms.file_help.file"
|
469
|
+
end
|
470
|
+
end
|
471
|
+
help_messages = %w(message_1 message_2)
|
472
|
+
|
473
|
+
inner = "<p>#{I18n.t("explanation", scope: help_scope)}</p>".html_safe
|
474
|
+
inner + content_tag(:ul) do
|
475
|
+
messages = help_messages.each.map { |msg| I18n.t(msg, scope: help_scope) }
|
476
|
+
|
477
|
+
if max_file_size
|
478
|
+
file_size_mb = (((max_file_size / 1024 / 1024) * 100) / 100).round
|
479
|
+
messages << I18n.t(
|
480
|
+
"max_file_size",
|
481
|
+
megabytes: file_size_mb,
|
482
|
+
scope: "decidim.forms.file_validation"
|
483
|
+
)
|
484
|
+
end
|
485
|
+
|
486
|
+
if file.respond_to?(:extension_whitelist, true)
|
487
|
+
allowed_extensions = file.send(:extension_whitelist)
|
488
|
+
messages << I18n.t(
|
489
|
+
"allowed_file_extensions",
|
490
|
+
extensions: allowed_extensions.join(" "),
|
491
|
+
scope: "decidim.forms.file_validation"
|
492
|
+
)
|
493
|
+
end
|
494
|
+
|
495
|
+
messages.map { |msg| content_tag(:li, msg) }.join("\n").html_safe
|
496
|
+
end.html_safe
|
497
|
+
end
|
498
|
+
end
|
410
499
|
|
411
500
|
# Public: Returns the translated name for the given attribute.
|
412
501
|
#
|
@@ -427,6 +516,19 @@ module Decidim
|
|
427
516
|
end
|
428
517
|
end
|
429
518
|
|
519
|
+
# Discard the pattern attribute which is not allowed for textarea elements.
|
520
|
+
def text_area(attribute, options = {})
|
521
|
+
field(attribute, options) do |opts|
|
522
|
+
opts.delete(:pattern)
|
523
|
+
@template.send(
|
524
|
+
:text_area,
|
525
|
+
@object_name,
|
526
|
+
attribute,
|
527
|
+
objectify_options(opts)
|
528
|
+
)
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
430
532
|
private
|
431
533
|
|
432
534
|
# Private: Override from FoundationRailsHelper in order to render
|
@@ -490,6 +592,7 @@ module Decidim
|
|
490
592
|
validation_options = {}
|
491
593
|
validation_options[:pattern] = "^(.|[\n\r]){#{min_length},#{max_length}}$" if min_length.to_i.positive? || max_length.to_i.positive?
|
492
594
|
validation_options[:required] = options[:required] || attribute_required?(attribute)
|
595
|
+
validation_options[:minlength] ||= min_length if min_length.to_i.positive?
|
493
596
|
validation_options[:maxlength] ||= max_length if max_length.to_i.positive?
|
494
597
|
validation_options
|
495
598
|
end
|
@@ -528,9 +631,17 @@ module Decidim
|
|
528
631
|
# Returns an Integer or Nil.
|
529
632
|
def length_for_attribute(attribute, type)
|
530
633
|
length_validator = find_validator(attribute, ActiveModel::Validations::LengthValidator)
|
531
|
-
return
|
634
|
+
return length_validator.options[type] if length_validator
|
635
|
+
|
636
|
+
length_validator = find_validator(attribute, ProposalLengthValidator)
|
637
|
+
if length_validator
|
638
|
+
length = length_validator.options[type]
|
639
|
+
return length.call(object) if length.respond_to?(:call)
|
532
640
|
|
533
|
-
|
641
|
+
return length
|
642
|
+
end
|
643
|
+
|
644
|
+
nil
|
534
645
|
end
|
535
646
|
|
536
647
|
# Private: Finds a validator.
|
@@ -663,9 +774,20 @@ module Decidim
|
|
663
774
|
|
664
775
|
def required_for_attribute(attribute)
|
665
776
|
if attribute_required?(attribute)
|
666
|
-
|
667
|
-
|
668
|
-
|
777
|
+
visible_title = content_tag(:span, "*", "aria-hidden": true)
|
778
|
+
screenreader_title = content_tag(
|
779
|
+
:span,
|
780
|
+
I18n.t("required", scope: "forms"),
|
781
|
+
class: "show-for-sr"
|
782
|
+
)
|
783
|
+
return content_tag(
|
784
|
+
:span,
|
785
|
+
visible_title + screenreader_title,
|
786
|
+
title: I18n.t("required", scope: "forms"),
|
787
|
+
data: { tooltip: true, disable_hover: false, keep_on_hover: true },
|
788
|
+
"aria-haspopup": true,
|
789
|
+
class: "label-required"
|
790
|
+
).html_safe
|
669
791
|
end
|
670
792
|
"".html_safe
|
671
793
|
end
|
@@ -679,6 +801,15 @@ module Decidim
|
|
679
801
|
selected
|
680
802
|
end
|
681
803
|
|
804
|
+
# Private: Returns the help text and error tags at the end of the field.
|
805
|
+
# Modified to change the tag to a valid HTML tag inside the <label> element.
|
806
|
+
def error_and_help_text(attribute, options = {})
|
807
|
+
html = ""
|
808
|
+
html += content_tag(:span, options[:help_text], class: "help-text") if options[:help_text]
|
809
|
+
html += error_for(attribute, options) || ""
|
810
|
+
html.html_safe
|
811
|
+
end
|
812
|
+
|
682
813
|
def ruby_format_to_datepicker(ruby_date_format)
|
683
814
|
ruby_date_format.gsub("%d", "dd").gsub("%m", "mm").gsub("%Y", "yyyy").gsub("%H", "hh").gsub("%M", "ii")
|
684
815
|
end
|
@@ -686,5 +817,60 @@ module Decidim
|
|
686
817
|
def sanitize_tabs_selector(id)
|
687
818
|
id.tr("[", "-").tr("]", "-")
|
688
819
|
end
|
820
|
+
|
821
|
+
def extension_whitelist_help(extension_whitelist)
|
822
|
+
content_tag :p, class: "extensions-help help-text" do
|
823
|
+
safe_join([
|
824
|
+
content_tag(:span, I18n.t("extension_whitelist", scope: "decidim.forms.files")),
|
825
|
+
" ",
|
826
|
+
safe_join(extension_whitelist.map { |ext| content_tag(:b, ext) }, ", ")
|
827
|
+
])
|
828
|
+
end
|
829
|
+
end
|
830
|
+
|
831
|
+
def image_dimensions_help(dimensions_info)
|
832
|
+
content_tag :p, class: "image-dimensions-help help-text" do
|
833
|
+
safe_join([
|
834
|
+
content_tag(:span, I18n.t("dimensions_info", scope: "decidim.forms.images")),
|
835
|
+
" ",
|
836
|
+
content_tag(:span) do
|
837
|
+
safe_join(dimensions_info.map do |_version, info|
|
838
|
+
processor = @template.content_tag(:span, I18n.t("processors.#{info[:processor]}", scope: "decidim.forms.images"))
|
839
|
+
dimensions = @template.content_tag(:b, I18n.t("dimensions", scope: "decidim.forms.images", width: info[:dimensions].first, height: info[:dimensions].last))
|
840
|
+
safe_join([processor, " ", dimensions, ". ".html_safe])
|
841
|
+
end)
|
842
|
+
end
|
843
|
+
])
|
844
|
+
end
|
845
|
+
end
|
846
|
+
|
847
|
+
# Private: Creates a tag from the given options for the field prefix and
|
848
|
+
# suffix. Overridden from Foundation Rails helper to make the generated HTML
|
849
|
+
# valid since these elements are printed within <label> elements and <div>'s
|
850
|
+
# are not allowed there.
|
851
|
+
def tag_from_options(name, options)
|
852
|
+
return "".html_safe unless options && options[:value].present?
|
853
|
+
|
854
|
+
content_tag(:span,
|
855
|
+
content_tag(:span, options[:value], class: name),
|
856
|
+
class: column_classes(options).to_s)
|
857
|
+
end
|
858
|
+
|
859
|
+
# Private: Wraps the prefix and postfix for the field. Overridden from
|
860
|
+
# Foundation Rails helper to make the generated HTML valid since these
|
861
|
+
# elements are printed within <label> elements and <div>'s are not allowed
|
862
|
+
# there.
|
863
|
+
def wrap_prefix_and_postfix(block, prefix_options, postfix_options)
|
864
|
+
prefix = tag_from_options("prefix", prefix_options)
|
865
|
+
postfix = tag_from_options("postfix", postfix_options)
|
866
|
+
|
867
|
+
input_size = calculate_input_size(prefix_options, postfix_options)
|
868
|
+
klass = column_classes(input_size.marshal_dump).to_s
|
869
|
+
input = content_tag(:span, block, class: klass)
|
870
|
+
|
871
|
+
return block unless input_size.changed?
|
872
|
+
|
873
|
+
content_tag(:span, prefix + input + postfix, class: "row collapse")
|
874
|
+
end
|
689
875
|
end
|
690
876
|
end
|