decidim-core 0.13.1 → 0.14.1
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 +1 -1
- data/app/assets/images/decidim/gamification/badges/invitations.svg +117 -0
- data/app/assets/javascripts/decidim.js.es6 +4 -1
- data/app/assets/javascripts/decidim/ajax_modals.js.es6 +17 -0
- data/app/assets/javascripts/decidim/conferences.js.es6 +16 -0
- data/app/assets/javascripts/decidim/input_hashtags.js.es6 +115 -0
- data/app/assets/javascripts/decidim/input_mentions.js.es6 +2 -3
- data/app/assets/javascripts/decidim/vizzs/areachart.js.es6 +226 -0
- data/app/assets/javascripts/decidim/vizzs/metrics.js.es6 +26 -0
- data/app/assets/javascripts/decidim/vizzs/orgchart.js.es6 +701 -0
- data/app/assets/javascripts/decidim/vizzs/renders.js.es6 +11 -0
- data/app/assets/stylesheets/decidim/extras/_proposal_form.scss +3 -1
- data/app/assets/stylesheets/decidim/layouts/_home.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_areachart.scss +74 -0
- data/app/assets/stylesheets/decidim/modules/_badges.scss +116 -0
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_cards.scss +21 -4
- data/app/assets/stylesheets/decidim/modules/_chart-tooltip.scss +42 -0
- data/app/assets/stylesheets/decidim/modules/_collapsible-list.scss +12 -8
- data/app/assets/stylesheets/decidim/modules/_conference-nav.scss +31 -0
- data/app/assets/stylesheets/decidim/modules/_conference-programme.scss +110 -0
- data/app/assets/stylesheets/decidim/modules/_conference-speaker.scss +86 -0
- data/app/assets/stylesheets/decidim/modules/_conversation.scss +58 -0
- data/app/assets/stylesheets/decidim/modules/_help.scss +38 -0
- data/app/assets/stylesheets/decidim/modules/_hover-section.scss +29 -0
- data/app/assets/stylesheets/decidim/modules/_icons.scss +10 -4
- data/app/assets/stylesheets/decidim/modules/_input-hashtags.scss +124 -0
- data/app/assets/stylesheets/decidim/modules/_loading-spinner.scss +12 -0
- data/app/assets/stylesheets/decidim/modules/_margins.scss +2 -2
- data/app/assets/stylesheets/decidim/modules/_modules.scss +15 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +9 -0
- data/app/assets/stylesheets/decidim/modules/_orgchart.scss +62 -0
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_typography.scss +9 -0
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +28 -0
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +63 -0
- data/app/cells/decidim/author/withdraw.erb +1 -1
- data/app/cells/decidim/author_cell.rb +1 -1
- data/app/cells/decidim/badge/show.erb +36 -0
- data/app/cells/decidim/badge_cell.rb +53 -0
- data/app/cells/decidim/badges/show.erb +6 -0
- data/app/cells/decidim/badges_cell.rb +14 -0
- data/app/cells/decidim/card_m/header.erb +1 -1
- data/app/cells/decidim/card_m/show.erb +1 -2
- data/app/cells/decidim/card_m/top.erb +7 -0
- data/app/cells/decidim/card_m_cell.rb +14 -17
- data/app/cells/decidim/coauthorships_cell.rb +77 -0
- data/app/cells/decidim/collapsible_authors/show.erb +0 -1
- data/app/cells/decidim/collapsible_authors_cell.rb +4 -4
- data/app/cells/decidim/collapsible_list/show.erb +12 -4
- data/app/cells/decidim/collapsible_list_cell.rb +14 -12
- data/app/cells/decidim/content_blocks/footer_sub_hero/show.erb +14 -0
- data/app/cells/decidim/content_blocks/footer_sub_hero_cell.rb +12 -0
- data/app/{views/decidim/pages/home/_hero.html.erb → cells/decidim/content_blocks/hero/show.erb} +4 -4
- data/app/cells/decidim/content_blocks/hero_cell.rb +25 -0
- data/app/cells/decidim/content_blocks/hero_settings_form/show.erb +7 -0
- data/app/cells/decidim/content_blocks/hero_settings_form_cell.rb +13 -0
- data/app/cells/decidim/content_blocks/highlighted_content_banner/show.erb +24 -0
- data/app/cells/decidim/content_blocks/highlighted_content_banner_cell.rb +16 -0
- data/app/{views/decidim/pages/home/_extended.html.erb → cells/decidim/content_blocks/how_to_participate/show.erb} +10 -10
- data/app/cells/decidim/content_blocks/how_to_participate_cell.rb +9 -0
- data/app/{views/decidim/pages/home/_statistics.html.erb → cells/decidim/content_blocks/stats/show.erb} +2 -2
- data/app/cells/decidim/content_blocks/stats_cell.rb +18 -0
- data/app/{views/decidim/pages/home/_sub_hero.html.erb → cells/decidim/content_blocks/sub_hero/show.erb} +2 -2
- data/app/cells/decidim/content_blocks/sub_hero_cell.rb +17 -0
- data/app/cells/decidim/conversation/show.erb +18 -0
- data/app/cells/decidim/conversation_cell.rb +23 -0
- data/app/cells/decidim/conversation_header/show.erb +17 -0
- data/app/cells/decidim/conversation_header_cell.rb +16 -0
- data/app/cells/decidim/conversations/show.erb +45 -0
- data/app/cells/decidim/conversations_cell.rb +24 -0
- data/app/cells/decidim/follow_button/show.erb +3 -3
- data/app/cells/decidim/follow_button_cell.rb +1 -5
- data/app/cells/decidim/following_cell.rb +1 -7
- data/app/cells/decidim/message/show.erb +15 -0
- data/app/cells/decidim/message_cell.rb +23 -0
- data/app/cells/decidim/new_conversation/show.erb +19 -0
- data/app/cells/decidim/new_conversation_cell.rb +19 -0
- data/app/cells/decidim/notifications/show.erb +1 -1
- data/app/cells/decidim/profile/show.erb +27 -0
- data/app/cells/decidim/profile_cell.rb +33 -0
- data/app/cells/decidim/profile_sidebar/show.erb +57 -0
- data/app/cells/decidim/profile_sidebar_cell.rb +31 -0
- data/app/cells/decidim/tos_page_cell.rb +0 -4
- data/app/cells/decidim/user_profile/header.erb +1 -1
- data/app/controllers/concerns/decidim/action_authorization.rb +13 -38
- data/app/controllers/concerns/decidim/needs_permission.rb +15 -6
- data/app/controllers/decidim/application_controller.rb +1 -0
- data/app/controllers/decidim/authorization_modals_controller.rb +35 -0
- data/app/controllers/decidim/components/base_controller.rb +0 -1
- data/app/controllers/decidim/devise/invitations_controller.rb +2 -1
- data/app/controllers/decidim/messaging/conversations_controller.rb +2 -11
- data/app/controllers/decidim/newsletters_controller.rb +4 -6
- data/app/controllers/decidim/notifications_controller.rb +4 -0
- data/app/controllers/decidim/pages_controller.rb +3 -7
- data/app/controllers/decidim/profiles_controller.rb +17 -7
- data/app/forms/decidim/notifications_settings_form.rb +1 -1
- data/app/forms/decidim/registration_form.rb +1 -1
- data/app/helpers/decidim/action_authorization_helper.rb +51 -46
- data/app/helpers/decidim/application_helper.rb +18 -0
- data/app/helpers/decidim/card_helper.rb +1 -1
- data/app/helpers/decidim/cells_helper.rb +6 -2
- data/app/helpers/decidim/resource_helper.rb +8 -1
- data/app/helpers/decidim/searches_helper.rb +5 -4
- data/app/helpers/decidim/traceability_helper.rb +5 -1
- data/app/models/decidim/authorization.rb +2 -2
- data/app/models/decidim/content_block.rb +144 -0
- data/app/models/decidim/gamification/badge_score.rb +13 -0
- data/app/models/decidim/messaging/message.rb +1 -1
- data/app/models/decidim/messaging/receipt.rb +1 -1
- data/app/models/decidim/organization.rb +1 -5
- data/app/models/decidim/resource_permission.rb +8 -0
- data/app/models/decidim/searchable_resource.rb +1 -1
- data/app/models/decidim/user.rb +17 -1
- data/app/permissions/decidim/default_permissions.rb +4 -3
- data/app/permissions/decidim/permissions.rb +33 -1
- data/app/presenters/decidim/hashtag_presenter.rb +32 -0
- data/app/presenters/decidim/resource_locator_presenter.rb +13 -0
- data/app/presenters/decidim/user_presenter.rb +1 -1
- data/app/queries/decidim/messaging/user_conversations.rb +1 -1
- data/app/resolvers/decidim/hashtags_resolver.rb +15 -0
- data/app/services/decidim/action_authorizer.rb +9 -8
- data/app/types/decidim/core/date_time_type.rb +1 -1
- data/app/types/decidim/core/hashtag_type.rb +13 -0
- data/app/uploaders/decidim/homepage_image_uploader.rb +1 -1
- data/app/uploaders/decidim/image_uploader.rb +1 -0
- data/app/views/decidim/authorization_modals/show.html.erb +32 -0
- data/app/views/decidim/messaging/conversations/create.js.erb +1 -1
- data/app/views/decidim/messaging/conversations/index.html.erb +1 -51
- data/app/views/decidim/messaging/conversations/new.html.erb +1 -5
- data/app/views/decidim/messaging/conversations/show.html.erb +1 -9
- data/app/views/decidim/messaging/conversations/update.js.erb +1 -1
- data/app/views/decidim/notifications/index.html.erb +1 -0
- data/app/views/decidim/pages/decidim_page.html.erb +9 -0
- data/app/views/decidim/pages/home.html.erb +12 -16
- data/app/views/decidim/pages/index.html.erb +8 -0
- data/app/views/decidim/profiles/_user_follow.erb +2 -2
- data/app/views/decidim/profiles/show.html.erb +1 -37
- data/app/views/decidim/searches/_results.html.erb +1 -1
- data/app/views/decidim/shared/_author_reference.html.erb +1 -1
- data/app/views/decidim/shared/_authorization_modal.html.erb +1 -0
- data/app/views/decidim/shared/_tags.html.erb +1 -1
- data/app/views/kaminari/decidim/_page.html.erb +1 -1
- data/app/views/layouts/decidim/_application.html.erb +6 -1
- data/app/views/layouts/decidim/_edit_link.html.erb +8 -0
- data/app/views/layouts/decidim/_impersonation_warning.html.erb +1 -1
- data/app/views/layouts/decidim/_user_menu.html.erb +2 -2
- data/app/views/layouts/decidim/_wrapper.html.erb +14 -1
- data/config/initializers/carrierwave.rb +15 -0
- data/config/locales/ca.yml +78 -30
- data/config/locales/en.yml +78 -30
- data/config/locales/es-PY.yml +78 -30
- data/config/locales/es.yml +78 -30
- data/config/locales/eu.yml +78 -30
- data/config/locales/fi.yml +262 -214
- data/config/locales/fr.yml +78 -30
- data/config/locales/gl.yml +78 -30
- data/config/locales/hu.yml +781 -0
- data/config/locales/it.yml +78 -30
- data/config/locales/nl.yml +78 -30
- data/config/locales/pl.yml +78 -30
- data/config/locales/pt-BR.yml +106 -58
- data/config/locales/pt.yml +78 -30
- data/config/locales/ru.yml +52 -32
- data/config/locales/sv.yml +183 -135
- data/config/locales/uk.yml +60 -40
- data/config/routes.rb +8 -6
- data/db/migrate/20180705091019_create_decidim_resource_permissions.rb +12 -0
- data/db/migrate/20180706104107_add_nickname_to_managed_users.rb +14 -0
- data/db/migrate/20180706111847_fix_result_follows.rb +9 -0
- data/db/migrate/20180724103814_add_content_blocks.rb +22 -0
- data/db/migrate/20180726112510_create_decidim_hashtags.rb +17 -0
- data/db/migrate/20180730071851_add_core_content_blocks.rb +28 -0
- data/db/migrate/20180802132147_rename_content_block_options_to_settings.rb +7 -0
- data/db/migrate/20180806095628_add_badge_scores.rb +11 -0
- data/db/migrate/20180808135006_add_images_to_content_blocks.rb +7 -0
- data/db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb +23 -0
- data/db/seeds.rb +10 -2
- data/lib/decidim/api/authorable_interface.rb +1 -1
- data/lib/decidim/coauthorable.rb +1 -0
- data/lib/decidim/content_block_manifest.rb +58 -0
- data/lib/decidim/content_block_registry.rb +87 -0
- data/lib/decidim/content_parsers.rb +1 -0
- data/lib/decidim/content_parsers/hashtag_parser.rb +36 -0
- data/lib/decidim/content_processor.rb +11 -0
- data/lib/decidim/content_renderers.rb +1 -0
- data/lib/decidim/content_renderers/hashtag_renderer.rb +43 -0
- data/lib/decidim/core.rb +28 -6
- data/lib/decidim/core/api.rb +1 -0
- data/lib/decidim/core/engine.rb +52 -1
- data/lib/decidim/core/test.rb +3 -0
- data/lib/decidim/core/test/factories.rb +32 -17
- data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +10 -0
- data/lib/decidim/core/test/shared_examples/coauthorable.rb +3 -0
- data/lib/decidim/core/test/shared_examples/edit_link_shared_examples.rb +30 -0
- data/lib/decidim/core/test/shared_examples/has_space_in_mcell_examples.rb +15 -0
- data/lib/decidim/core/test/shared_examples/publicable.rb +1 -1
- data/lib/decidim/core/test/shared_examples/railtie_examples.rb +15 -0
- data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +1 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/events/base_event.rb +2 -1
- data/lib/decidim/form_builder.rb +9 -3
- data/lib/decidim/friendly_dates.rb +1 -1
- data/lib/decidim/gamification.rb +109 -0
- data/lib/decidim/gamification/badge.rb +54 -0
- data/lib/decidim/gamification/badge_earned_event.rb +9 -0
- data/lib/decidim/gamification/badge_registry.rb +63 -0
- data/lib/decidim/gamification/badge_scorer.rb +118 -0
- data/lib/decidim/gamification/badge_status.rb +41 -0
- data/lib/decidim/gamification/base_event.rb +40 -0
- data/lib/decidim/gamification/level_up_event.rb +9 -0
- data/lib/decidim/hashtag.rb +15 -0
- data/lib/decidim/hashtaggable.rb +20 -0
- data/lib/decidim/query_extensions.rb +10 -0
- data/lib/decidim/resource_manifest.rb +10 -0
- data/lib/decidim/resourceable.rb +13 -0
- data/lib/decidim/search_resource_fields_mapper.rb +8 -3
- data/lib/decidim/searchable.rb +8 -0
- data/lib/decidim/translatable_attributes.rb +6 -18
- data/lib/decidim/view_model.rb +6 -0
- data/lib/devise/models/decidim_newsletterable.rb +1 -1
- data/vendor/assets/javascripts/d3.js +17813 -0
- metadata +125 -27
- data/app/cells/decidim/card_m/author.erb +0 -3
- data/app/cells/decidim/card_m/authors.erb +0 -9
- data/app/views/decidim/messaging/conversations/_message.html.erb +0 -14
- data/app/views/decidim/messaging/conversations/_reply.html.erb +0 -11
- data/app/views/decidim/messaging/conversations/_show.html.erb +0 -21
- data/app/views/decidim/messaging/conversations/_start.html.erb +0 -12
- data/app/views/decidim/pages/home/_footer_sub_hero.html.erb +0 -14
- data/app/views/decidim/pages/home/_highlighted_content_banner.html.erb +0 -26
- data/app/views/decidim/pages/home/_highlighted_processes.html.erb +0 -7
- data/app/views/decidim/profiles/_user.html.erb +0 -59
- data/app/views/decidim/shared/_action_authorization_modal.html.erb +0 -39
- data/app/views/layouts/decidim/_component_authorization_modals.html.erb +0 -5
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ConversationHeaderCell < Decidim::ViewModel
|
5
|
+
include Decidim::IconHelper
|
6
|
+
include Decidim::Core::Engine.routes.url_helpers
|
7
|
+
|
8
|
+
def show
|
9
|
+
render :show
|
10
|
+
end
|
11
|
+
|
12
|
+
def recipient
|
13
|
+
@recipient ||= Decidim::UserPresenter.new(model)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<% if conversations.empty? %>
|
2
|
+
<div class="callout secondary">
|
3
|
+
<p><%= t("decidim.messaging.conversations.index.no_conversations") %></p>
|
4
|
+
</div>
|
5
|
+
<% else %>
|
6
|
+
<div class="conversations">
|
7
|
+
<% conversations.each do |conversation| %>
|
8
|
+
<% interlocutor = Decidim::UserPresenter.new(conversation.interlocutors(current_user).first) %>
|
9
|
+
<div class="card card--widget conversation">
|
10
|
+
<ul class="card-data">
|
11
|
+
<li class="card-data__item">
|
12
|
+
<div class="card__link text-center">
|
13
|
+
<%= link_to interlocutor.profile_path, class: "user-header__avatar" do %>
|
14
|
+
<%= image_tag interlocutor.avatar_url %>
|
15
|
+
<% end %>
|
16
|
+
<span class="text-medium mt-xs">
|
17
|
+
<%= conversation.last_message.friendly_created_at %>
|
18
|
+
</span>
|
19
|
+
</div>
|
20
|
+
</li>
|
21
|
+
<%= link_to decidim.conversation_path(conversation), "data-tabs-target": "conversations" do %>
|
22
|
+
<li class="card-data__item card-data__item--expand absolutes">
|
23
|
+
<div class="mr-s">
|
24
|
+
<%= t("decidim.messaging.conversations.index.from") %> <strong><%= interlocutor.name %></strong>
|
25
|
+
<br />
|
26
|
+
<span class="muted">
|
27
|
+
<%= truncate conversation.last_message.body, length: 150 %>
|
28
|
+
</span>
|
29
|
+
<br />
|
30
|
+
<span class="text-small">
|
31
|
+
<%= t("decidim.messaging.conversations.index.last_message_html", time: time_ago_in_words(conversation.last_message.created_at)) %>
|
32
|
+
</span>
|
33
|
+
</div>
|
34
|
+
<div class="right center mr-s">
|
35
|
+
<%= link_to decidim.conversation_path(conversation), class: "user-header__avatar", "data-tabs-target": "conversations" do %>
|
36
|
+
<%= icon "chevron-right", class: "card__link icon--big" %>
|
37
|
+
<% end %>
|
38
|
+
</div>
|
39
|
+
</li>
|
40
|
+
<% end %>
|
41
|
+
</ul>
|
42
|
+
</div>
|
43
|
+
<% end %>
|
44
|
+
</div>
|
45
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ConversationsCell < Decidim::ViewModel
|
5
|
+
include Decidim::CellsPaginateHelper
|
6
|
+
include Decidim::IconHelper
|
7
|
+
include Decidim::Core::Engine.routes.url_helpers
|
8
|
+
include ActionView::Helpers::DateHelper
|
9
|
+
|
10
|
+
helper_method :conversations
|
11
|
+
|
12
|
+
delegate :current_user, to: :controller
|
13
|
+
|
14
|
+
def show
|
15
|
+
render :show
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def conversations
|
21
|
+
@conversations ||= Decidim::Messaging::UserConversations.for(current_user)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<div id="<%= dom_id(model, :follow) %>">
|
2
2
|
<% if current_user %>
|
3
3
|
<% if current_user.follows?(model) %>
|
4
|
-
<%= button_to decidim.follow_path, class: button_classes, params: { follow: { followable_gid: model.to_sgid.to_s, inline: inline? }}, data: { disable: true }, method: :delete, remote: true do %>
|
4
|
+
<%= button_to decidim.follow_path, class: button_classes, params: { follow: { followable_gid: model.to_sgid.to_s, inline: inline? } }, data: { disable: true }, method: :delete, remote: true do %>
|
5
5
|
<%= icon "bell", icon_options %>
|
6
6
|
<span>
|
7
7
|
<%= t("follows.destroy.button", scope: "decidim") %>
|
8
8
|
</span>
|
9
9
|
<% end %>
|
10
10
|
<% else %>
|
11
|
-
<%= button_to decidim.follow_path, class: button_classes, params: { follow: { followable_gid: model.to_sgid.to_s, inline: inline? }}, data: { disable: true }, remote: true do %>
|
11
|
+
<%= button_to decidim.follow_path, class: button_classes, params: { follow: { followable_gid: model.to_sgid.to_s, inline: inline? } }, data: { disable: true }, remote: true do %>
|
12
12
|
<%= icon "bell", icon_options %>
|
13
13
|
<span>
|
14
14
|
<%= t("follows.create.button", scope: "decidim") %>
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<%= button_to(
|
20
20
|
decidim.follow_path,
|
21
21
|
class: button_classes,
|
22
|
-
params: { follow: { followable_gid: model.to_sgid.to_s, inline: inline? }},
|
22
|
+
params: { follow: { followable_gid: model.to_sgid.to_s, inline: inline? } },
|
23
23
|
data: { tooltip: true, disable_hover: false },
|
24
24
|
:'aria-haspopup' => true,
|
25
25
|
title: t("decidim.shared.follow_button.sign_in_before_follow"),
|
@@ -16,12 +16,8 @@ module Decidim
|
|
16
16
|
context[:current_user]
|
17
17
|
end
|
18
18
|
|
19
|
-
def decidim
|
20
|
-
Decidim::Core::Engine.routes.url_helpers
|
21
|
-
end
|
22
|
-
|
23
19
|
def button_classes
|
24
|
-
return "card__button secondary text-uppercase follow-button" if inline?
|
20
|
+
return "card__button secondary text-uppercase follow-button mb-none" if inline?
|
25
21
|
"button secondary hollow expanded small button--icon follow-button"
|
26
22
|
end
|
27
23
|
|
@@ -12,13 +12,7 @@ module Decidim
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def followings
|
15
|
-
@followings ||= Kaminari.paginate_array(following_users).page(params[:page]).per(20)
|
16
|
-
end
|
17
|
-
|
18
|
-
def following_users
|
19
|
-
@following_users ||= model.following.select do |following|
|
20
|
-
following.is_a?(Decidim::User)
|
21
|
-
end
|
15
|
+
@followings ||= Kaminari.paginate_array(model.following_users).page(params[:page]).per(20)
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div class="conversation-chat<%= " conversation-chat--offset" if own_message? %>">
|
2
|
+
<%= link_to sender.profile_path do %>
|
3
|
+
<%= image_tag sender.avatar_url %>
|
4
|
+
<% end %>
|
5
|
+
<div>
|
6
|
+
<article class="card">
|
7
|
+
<div class="p-s">
|
8
|
+
<%= simple_format(message.body) %>
|
9
|
+
</div>
|
10
|
+
</article>
|
11
|
+
<time datetime="<%= message.created_at.utc %>" class="text-small<%= " pull-right" if own_message? %>">
|
12
|
+
<%= message.friendly_created_at %>
|
13
|
+
</time>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class MessageCell < Decidim::ViewModel
|
5
|
+
delegate :current_user, to: :controller
|
6
|
+
|
7
|
+
def show
|
8
|
+
render :show
|
9
|
+
end
|
10
|
+
|
11
|
+
def message
|
12
|
+
@message ||= model
|
13
|
+
end
|
14
|
+
|
15
|
+
def sender
|
16
|
+
@sender ||= Decidim::UserPresenter.new(message.sender)
|
17
|
+
end
|
18
|
+
|
19
|
+
def own_message?
|
20
|
+
message.sender == current_user
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div class="conversation">
|
2
|
+
<%= cell "decidim/conversation_header", form.recipient %>
|
3
|
+
|
4
|
+
<div id="messages">
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="conversation-reply conversation-reply--offset">
|
8
|
+
<h2 class="section-heading">
|
9
|
+
<%= t("decidim.messaging.conversations.start.title") %>
|
10
|
+
</h2>
|
11
|
+
|
12
|
+
<%= form_for form, url: decidim.conversations_path do |f| %>
|
13
|
+
<%= f.hidden_field :recipient_id %>
|
14
|
+
<%= f.text_area :body, label: false, rows: 4, required: true %>
|
15
|
+
|
16
|
+
<%= f.submit t("decidim.messaging.conversations.start.send"), data: { disable: true }, class: "button secondary light pull-right" %>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
19
|
+
</div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class NewConversationCell < Decidim::ViewModel
|
5
|
+
include Decidim::IconHelper
|
6
|
+
include Decidim::Core::Engine.routes.url_helpers
|
7
|
+
include ActionView::Helpers::DateHelper
|
8
|
+
|
9
|
+
delegate :current_organization, to: :controller
|
10
|
+
|
11
|
+
def show
|
12
|
+
render :show
|
13
|
+
end
|
14
|
+
|
15
|
+
def form
|
16
|
+
context[:form]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -21,7 +21,7 @@
|
|
21
21
|
<li class="card-data__item">
|
22
22
|
<div class="card__link text-center">
|
23
23
|
<%= resource_icon notification.resource, class: "icon--large" %>
|
24
|
-
<span class="text-medium mt-xs"><%= notification.created_at
|
24
|
+
<span class="text-medium mt-xs"><%= l notification.created_at, format: :day_of_week_long %></span>
|
25
25
|
</div>
|
26
26
|
</li>
|
27
27
|
<li class="card-data__item card-data__item--expand absolutes">
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<main class="wrapper">
|
2
|
+
<div class="row">
|
3
|
+
<div class="columns medium-9 medium-offset-3">
|
4
|
+
<ul class="tabs" id="profile-tabs">
|
5
|
+
<% if own_profile? %>
|
6
|
+
<%= user_profile_tab t("decidim.profiles.show.notifications"), notifications_path %>
|
7
|
+
<%= user_profile_tab t("decidim.profiles.show.conversations"), conversations_path %>
|
8
|
+
<% end %>
|
9
|
+
<%= user_profile_tab t("decidim.profiles.show.following"), profile_following_path(nickname: user.nickname) %>
|
10
|
+
<%= user_profile_tab t("decidim.profiles.show.followers"), profile_followers_path(nickname: user.nickname) %>
|
11
|
+
<%= user_profile_tab t("decidim.profiles.show.badges"), profile_badges_path(nickname: user.nickname) %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<div class="row">
|
16
|
+
<div class="columns medium-3">
|
17
|
+
<%= cell "decidim/profile_sidebar", user %>
|
18
|
+
</div>
|
19
|
+
<div class="columns medium-9">
|
20
|
+
<div class="tabs-content" data-tabs-content="profile-tabs">
|
21
|
+
<div class="tabs-panel is-active">
|
22
|
+
<%= cell content_cell, user, context %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
</main>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ProfileCell < Decidim::ViewModel
|
5
|
+
include Decidim::ApplicationHelper
|
6
|
+
include Decidim::Core::Engine.routes.url_helpers
|
7
|
+
include Decidim::UserProfileHelper
|
8
|
+
include Decidim::AriaSelectedLinkToHelper
|
9
|
+
include ActiveLinkTo
|
10
|
+
|
11
|
+
delegate :current_organization, :current_user, to: :controller
|
12
|
+
|
13
|
+
def show
|
14
|
+
render :show
|
15
|
+
end
|
16
|
+
|
17
|
+
def user
|
18
|
+
model
|
19
|
+
end
|
20
|
+
|
21
|
+
def content_cell
|
22
|
+
context[:content_cell]
|
23
|
+
end
|
24
|
+
|
25
|
+
def active_content
|
26
|
+
context[:active_content]
|
27
|
+
end
|
28
|
+
|
29
|
+
def own_profile?
|
30
|
+
current_user && current_user == user
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<div class="card">
|
2
|
+
<%= image_tag profile_user.avatar_url(:profile), class: "card__image card__image--larger" %>
|
3
|
+
<div class="card__content">
|
4
|
+
<h5>
|
5
|
+
<div><strong><%= profile_user.name %></strong></div>
|
6
|
+
<span class="text-small"><%= profile_user.nickname %></span>
|
7
|
+
<% if can_contact_user? %>
|
8
|
+
<span class="user-contact_link">
|
9
|
+
<%= link_to_current_or_new_conversation_with(user) %>
|
10
|
+
</span>
|
11
|
+
<% end %>
|
12
|
+
</h5>
|
13
|
+
<p><%= profile_user.about %></p>
|
14
|
+
<% if profile_user.personal_url.present? %>
|
15
|
+
<%= link_to html_truncate(profile_user.personal_url.gsub(%r{https?\:\/\/}, ""), length: 30), profile_user.personal_url %>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
<% if profile_user.badge.present? %>
|
19
|
+
<div class="badge-card__content">
|
20
|
+
<span>
|
21
|
+
<%= icon profile_user.badge, class: "author__verified" %>
|
22
|
+
</span>
|
23
|
+
<span>
|
24
|
+
<%= translated_attribute(profile_user.officialized_as).presence || t("decidim.profiles.default_officialization_text") %>
|
25
|
+
</span>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
<%= render_hook(:user_profile_bottom) %>
|
29
|
+
<div class="card__footer card__footer--transparent">
|
30
|
+
<div class="flex--cc p-s text-center">
|
31
|
+
<div class="mr-s">
|
32
|
+
<%= link_to profile_followers_path(nickname: user.nickname) do %>
|
33
|
+
<%= t("decidim.profiles.show.followers") %>
|
34
|
+
<h1 class="heading1"><%= profile_user.followers_count %></h1>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
<div class="ml-s">
|
38
|
+
<%= link_to profile_following_path(nickname: user.nickname) do %>
|
39
|
+
<%= t("decidim.profiles.show.following") %>
|
40
|
+
<h1 class="heading1"><%= profile_user.following_count %></h1>
|
41
|
+
<% end %>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<% if own_profile? %>
|
48
|
+
<div class="text-center">
|
49
|
+
<%= link_to decidim.account_path, class: "button" do %>
|
50
|
+
<span>
|
51
|
+
<%= t("decidim.profiles.user.edit_profile") %>
|
52
|
+
</span>
|
53
|
+
<% end %>
|
54
|
+
</div>
|
55
|
+
<% elsif logged_in? %>
|
56
|
+
<%= cell "decidim/follow_button", user, inline: false, context: { current_user: current_user } %>
|
57
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ProfileSidebarCell < Decidim::ProfileCell
|
5
|
+
include Decidim::Messaging::ConversationHelper
|
6
|
+
include Decidim::IconHelper
|
7
|
+
include Decidim::ViewHooksHelper
|
8
|
+
|
9
|
+
helper_method :profile_user, :logged_in?, :current_user
|
10
|
+
|
11
|
+
delegate :user_signed_in?, to: :controller
|
12
|
+
|
13
|
+
def show
|
14
|
+
render :show
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def logged_in?
|
20
|
+
current_user.present?
|
21
|
+
end
|
22
|
+
|
23
|
+
def profile_user
|
24
|
+
@profile_user ||= Decidim::UserPresenter.new(model)
|
25
|
+
end
|
26
|
+
|
27
|
+
def can_contact_user?
|
28
|
+
!current_user || (current_user && current_user != model)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -7,51 +7,26 @@ module Decidim
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
helper_method :
|
10
|
+
helper_method :action_authorized_to
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
#
|
15
|
-
# action_name - The action name to authorize. Actions are set up on the
|
16
|
-
# component's permissions panel.
|
17
|
-
# redirect_url - Url to be redirected to when the authorization is finished.
|
18
|
-
def authorize_action!(action_name, redirect_url: nil)
|
19
|
-
status = action_authorization(action_name)
|
13
|
+
private
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
redirect_to authorize_action_path(action_name, redirect_url: redirect_url)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Public: Returns the authorization object for an authorization.
|
28
|
-
#
|
29
|
-
# action_name - The action to authorize against.
|
30
|
-
#
|
31
|
-
# Returns an ActionAuthorizer::AuthorizationStatus
|
32
|
-
def action_authorization(action_name)
|
33
|
-
@action_authorizations ||= {}
|
34
|
-
|
35
|
-
@action_authorizations[action_name] = _action_authorizer(action_name).authorize
|
15
|
+
def action_authorized_to(action, resource: nil)
|
16
|
+
action_authorization_cache[action_authorization_cache_key(action, resource)] ||=
|
17
|
+
::Decidim::ActionAuthorizer.new(current_user, action, resource&.component || current_component, resource).authorize
|
36
18
|
end
|
37
19
|
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
# action_name - The action name to authorize against.
|
42
|
-
# redirect_url - The url to redirect to when finished.
|
43
|
-
#
|
44
|
-
# Returns a String.
|
45
|
-
def authorize_action_path(action_name, redirect_url: nil)
|
46
|
-
redirect_url ||= request.path
|
47
|
-
|
48
|
-
action_authorization(action_name).current_path(redirect_url: redirect_url)
|
20
|
+
def action_authorization_cache
|
21
|
+
request.env["decidim.action_authorization_cache"] ||= {}
|
49
22
|
end
|
50
23
|
|
51
|
-
def
|
52
|
-
|
24
|
+
def action_authorization_cache_key(action, resource)
|
25
|
+
if resource && !resource.permissions.nil?
|
26
|
+
"#{action}-#{resource.component.id}-#{resource.resource_manifest.name}-#{resource.id}"
|
27
|
+
else
|
28
|
+
"#{action}-#{current_component.id}"
|
29
|
+
end
|
53
30
|
end
|
54
|
-
|
55
|
-
class Unauthorized < StandardError; end
|
56
31
|
end
|
57
32
|
end
|