decidim-core 0.11.2 → 0.12.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/notifications.js.es6 +8 -6
- data/app/assets/javascripts/decidim/user_registrations.js.es6 +25 -1
- data/app/assets/stylesheets/decidim/application.scss.erb +4 -0
- data/app/assets/stylesheets/decidim/layouts/_home.scss +79 -0
- data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_cards.scss +82 -38
- data/app/assets/stylesheets/decidim/modules/_collapsible-list.scss +16 -0
- data/app/assets/stylesheets/decidim/modules/_definition-data.scss +27 -0
- data/app/assets/stylesheets/decidim/modules/_fingerprint.scss +8 -0
- data/app/assets/stylesheets/decidim/modules/_horizontal-tabs.scss +51 -0
- data/app/assets/stylesheets/decidim/modules/_inline-filters.scss +5 -3
- data/app/assets/stylesheets/decidim/modules/_margins.scss +6 -4
- data/app/assets/stylesheets/decidim/modules/_modules.scss +3 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +113 -7
- data/app/assets/stylesheets/decidim/modules/_signup.scss +22 -5
- data/app/assets/stylesheets/decidim/modules/_toggle.scss +9 -0
- data/app/assets/stylesheets/decidim/modules/_typography.scss +5 -1
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +42 -0
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +6 -0
- data/app/assets/stylesheets/decidim/utils/_settings.scss +3 -2
- data/app/cells/decidim/announcement/show.erb +11 -0
- data/app/cells/decidim/announcement_cell.rb +32 -0
- data/app/cells/decidim/author/comments.erb +6 -0
- data/app/cells/decidim/author/contact.erb +3 -0
- data/app/cells/decidim/author/date.erb +5 -0
- data/app/cells/decidim/author/flag.erb +5 -0
- data/app/cells/decidim/author/profile.erb +9 -0
- data/app/cells/decidim/{profile → author}/profile_inline.erb +1 -1
- data/app/cells/decidim/author/show.erb +18 -0
- data/app/cells/decidim/author/withdraw.erb +6 -0
- data/app/cells/decidim/author_cell.rb +109 -0
- data/app/cells/decidim/card/show.erb +18 -16
- data/app/cells/decidim/card_cell.rb +17 -4
- data/app/cells/decidim/card_m/author.erb +3 -0
- data/app/cells/decidim/card_m/badge.erb +1 -0
- data/app/cells/decidim/card_m/comments_counter.erb +3 -0
- data/app/cells/decidim/card_m/data.erb +0 -0
- data/app/cells/decidim/card_m/footer.erb +0 -0
- data/app/cells/decidim/card_m/header.erb +17 -0
- data/app/cells/decidim/card_m/image.erb +5 -0
- data/app/cells/decidim/card_m/label.erb +3 -0
- data/app/cells/decidim/card_m/show.erb +24 -0
- data/app/cells/decidim/card_m/status.erb +9 -0
- data/app/cells/decidim/card_m/tags.erb +0 -0
- data/app/cells/decidim/card_m_cell.rb +136 -0
- data/app/cells/decidim/collapsible_list/show.erb +20 -0
- data/app/cells/decidim/collapsible_list_cell.rb +66 -0
- data/app/cells/decidim/fingerprint/show.erb +22 -0
- data/app/cells/decidim/fingerprint_cell.rb +17 -0
- data/app/cells/decidim/follow_button/show.erb +34 -0
- data/app/cells/decidim/follow_button_cell.rb +40 -0
- data/app/cells/decidim/followers/show.erb +9 -0
- data/app/cells/decidim/followers_cell.rb +18 -0
- data/app/cells/decidim/following/show.erb +9 -0
- data/app/cells/decidim/following_cell.rb +24 -0
- data/app/cells/decidim/notifications/show.erb +48 -0
- data/app/cells/decidim/notifications_cell.rb +21 -0
- data/app/cells/decidim/progress_bar/show.erb +17 -0
- data/app/cells/decidim/progress_bar_cell.rb +68 -0
- data/app/cells/decidim/tags/category.erb +1 -0
- data/app/cells/decidim/tags/scope.erb +1 -0
- data/app/cells/decidim/tags/show.erb +5 -0
- data/app/cells/decidim/tags_cell.rb +62 -0
- data/app/cells/decidim/tos_page/announcement.erb +2 -0
- data/app/cells/decidim/tos_page/refuse_btn_modal.erb +23 -0
- data/app/cells/decidim/tos_page/sticky_form.erb +29 -0
- data/app/cells/decidim/tos_page_cell.rb +39 -0
- data/app/cells/decidim/user_profile/footer.erb +5 -0
- data/app/cells/decidim/user_profile/header.erb +20 -0
- data/app/cells/decidim/user_profile_cell.rb +26 -0
- data/app/commands/decidim/create_omniauth_registration.rb +1 -1
- data/app/commands/decidim/create_registration.rb +2 -1
- data/app/commands/decidim/search.rb +45 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +15 -12
- data/app/controllers/concerns/decidim/http_caching_disabler.rb +21 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +1 -6
- data/app/controllers/concerns/decidim/locale_switcher.rb +1 -1
- data/app/controllers/concerns/decidim/needs_permission.rb +70 -0
- data/app/controllers/concerns/decidim/needs_tos_accepted.rb +42 -0
- data/app/controllers/concerns/decidim/participatory_space_context.rb +1 -7
- data/app/controllers/concerns/decidim/user_profile.rb +3 -1
- data/app/controllers/decidim/account_controller.rb +4 -4
- data/app/controllers/decidim/application_controller.rb +17 -8
- data/app/controllers/decidim/components/base_controller.rb +14 -9
- data/app/controllers/decidim/cookie_policy_controller.rb +0 -2
- data/app/controllers/decidim/devise/confirmations_controller.rb +13 -0
- data/app/controllers/decidim/devise/invitations_controller.rb +3 -1
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +9 -3
- data/app/controllers/decidim/devise/passwords_controller.rb +1 -1
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -7
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +0 -2
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +0 -1
- data/app/controllers/decidim/errors_controller.rb +0 -2
- data/app/controllers/decidim/follows_controller.rb +4 -2
- data/app/controllers/decidim/locales_controller.rb +1 -1
- data/app/controllers/decidim/messaging/conversations_controller.rb +5 -5
- data/app/controllers/decidim/newsletters_controller.rb +0 -2
- data/app/controllers/decidim/notifications_controller.rb +3 -19
- data/app/controllers/decidim/notifications_settings_controller.rb +2 -2
- data/app/controllers/decidim/pages_controller.rb +12 -10
- data/app/controllers/decidim/profiles_controller.rb +10 -4
- data/app/controllers/decidim/reports_controller.rb +14 -1
- data/app/controllers/decidim/scopes_controller.rb +3 -3
- data/app/controllers/decidim/searches_controller.rb +39 -0
- data/app/controllers/decidim/static_map_controller.rb +0 -2
- data/app/controllers/decidim/tos_controller.rb +20 -0
- data/app/controllers/decidim/widgets_controller.rb +0 -1
- data/app/forms/decidim/follow_form.rb +1 -0
- data/app/forms/decidim/registration_form.rb +2 -1
- data/app/helpers/decidim/card_helper.rb +2 -0
- data/app/helpers/decidim/cells_paginate_helper.rb +16 -0
- data/app/helpers/decidim/cta_button_helper.rb +1 -1
- data/app/helpers/decidim/decidim_form_helper.rb +4 -0
- data/app/helpers/decidim/icon_helper.rb +2 -0
- data/app/helpers/decidim/resource_helper.rb +1 -2
- data/app/helpers/decidim/scopes_helper.rb +17 -10
- data/app/helpers/decidim/searches_helper.rb +16 -0
- data/app/helpers/decidim/tooltip_helper.rb +12 -0
- data/app/models/decidim/organization.rb +10 -0
- data/app/models/decidim/permission_action.rb +40 -0
- data/app/models/decidim/searchable_resource.rb +37 -0
- data/app/models/decidim/static_page.rb +4 -0
- data/app/models/decidim/user.rb +39 -3
- data/app/permissions/decidim/default_permissions.rb +61 -0
- data/app/permissions/decidim/permissions.rb +106 -0
- data/app/permissions/decidim/user_manager_permissions.rb +24 -0
- data/app/presenters/decidim/admin_log/organization_presenter.rb +2 -1
- data/app/presenters/decidim/home_stats_presenter.rb +2 -8
- data/app/presenters/decidim/user_presenter.rb +8 -0
- data/app/services/decidim/traceability.rb +6 -9
- data/app/types/decidim/core/user_type.rb +1 -1
- data/app/views/decidim/devise/invitations/edit.html.erb +56 -10
- data/app/views/decidim/devise/registrations/new.html.erb +36 -14
- data/app/views/decidim/devise/shared/_newsletter_modal.html.erb +25 -0
- data/app/views/decidim/follows/update_button.js.erb +2 -2
- data/app/views/decidim/messaging/conversations/_message.html.erb +1 -1
- data/app/views/{pages → decidim/pages}/decidim_page.html.erb +5 -0
- data/app/views/decidim/pages/home.html.erb +17 -0
- data/app/views/{pages → decidim/pages}/home/_extended.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_footer_sub_hero.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_hero.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_highlighted_content_banner.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_highlighted_processes.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_statistics.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_sub_hero.html.erb +0 -0
- data/app/views/decidim/profiles/_followers.html.erb +5 -0
- data/app/views/decidim/profiles/_following.html.erb +5 -0
- data/app/views/decidim/profiles/_notifications.html.erb +0 -0
- data/app/views/decidim/profiles/_user.html.erb +59 -0
- data/app/views/decidim/profiles/_user_follow.erb +32 -0
- data/app/views/decidim/profiles/show.html.erb +32 -59
- data/app/views/decidim/searches/_count.html.erb +1 -0
- data/app/views/decidim/searches/_filters.html.erb +20 -0
- data/app/views/decidim/searches/_filters_small_view.html.erb +18 -0
- data/app/views/decidim/searches/_results.html.erb +5 -0
- data/app/views/decidim/searches/index.html.erb +20 -0
- data/app/views/decidim/searches/index.js.erb +5 -0
- data/app/views/decidim/shared/_address_details.html.erb +7 -9
- data/app/views/decidim/shared/_announcement.html.erb +1 -6
- data/app/views/decidim/shared/_author_reference.html.erb +1 -1
- data/app/views/decidim/shared/_follow_button.html.erb +1 -34
- data/app/views/decidim/shared/_static_map.html.erb +3 -1
- data/app/views/decidim/shared/_tags.html.erb +1 -11
- data/app/views/kaminari/decidim/_paginator.html.erb +16 -15
- data/app/views/layouts/decidim/_head.html.erb +1 -0
- data/app/views/layouts/decidim/_topbar_search.html.erb +8 -0
- data/app/views/layouts/decidim/_user_menu.html.erb +2 -2
- data/app/views/layouts/decidim/_wrapper.html.erb +3 -2
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/rack_attack.rb +28 -0
- data/config/locales/ca.yml +136 -55
- data/config/locales/en.yml +135 -54
- data/config/locales/es.yml +136 -55
- data/config/locales/eu.yml +136 -54
- data/config/locales/fi.yml +135 -54
- data/config/locales/fr.yml +136 -54
- data/config/locales/gl.yml +136 -54
- data/config/locales/it.yml +136 -54
- data/config/locales/nl.yml +136 -54
- data/config/locales/pl.yml +144 -54
- data/config/locales/pt-BR.yml +136 -54
- data/config/locales/pt.yml +136 -54
- data/config/locales/ru.yml +150 -60
- data/config/locales/sv.yml +136 -54
- data/config/locales/uk.yml +146 -57
- data/config/routes.rb +11 -1
- data/db/migrate/20180209122819_create_decidim_searchable_resource.rb +21 -0
- data/db/migrate/20180508111640_add_tos_version_to_organization.rb +19 -0
- data/db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb +25 -0
- data/db/seeds.rb +33 -26
- data/lib/decidim/component_manifest.rb +35 -27
- data/lib/decidim/content_processor.rb +21 -3
- data/lib/decidim/core.rb +27 -16
- data/lib/decidim/core/engine.rb +8 -19
- data/lib/decidim/core/test.rb +2 -0
- data/lib/decidim/core/test/factories.rb +34 -4
- data/lib/decidim/core/test/shared_examples/fingerprint_examples.rb +15 -0
- data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +27 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/events/base_event.rb +5 -1
- data/lib/decidim/fingerprint_calculator.rb +42 -0
- data/lib/decidim/fingerprintable.rb +63 -0
- data/lib/decidim/form_builder.rb +1 -0
- data/lib/decidim/manifest_registry.rb +4 -10
- data/lib/decidim/participable.rb +4 -0
- data/lib/decidim/participatory_space_manifest.rb +36 -0
- data/lib/decidim/participatory_space_resourceable.rb +11 -0
- data/lib/decidim/resource_manifest.rb +10 -11
- data/lib/decidim/resourceable.rb +3 -2
- data/lib/decidim/search_resource_fields_mapper.rb +93 -0
- data/lib/decidim/searchable.rb +85 -0
- data/lib/decidim/settings_manifest.rb +3 -2
- data/lib/decidim/traceable.rb +2 -0
- data/lib/decidim/view_model.rb +9 -0
- data/lib/tasks/decidim_tasks.rake +79 -1
- metadata +149 -76
- data/app/assets/stylesheets/decidim/extras/_register_form.scss +0 -9
- data/app/cells/decidim/author_box/show.erb +0 -10
- data/app/cells/decidim/author_box_cell.rb +0 -21
- data/app/cells/decidim/profile/show.erb +0 -13
- data/app/cells/decidim/profile_cell.rb +0 -17
- data/app/controllers/concerns/decidim/needs_authorization.rb +0 -46
- data/app/models/decidim/abilities/admin_ability.rb +0 -29
- data/app/models/decidim/abilities/base_ability.rb +0 -56
- data/app/models/decidim/abilities/everyone_ability.rb +0 -25
- data/app/models/decidim/abilities/participatory_process_admin_ability.rb +0 -28
- data/app/models/decidim/abilities/participatory_process_collaborator_ability.rb +0 -28
- data/app/models/decidim/abilities/participatory_process_moderator_ability.rb +0 -15
- data/app/models/decidim/abilities/user_manager_ability.rb +0 -35
- data/app/views/decidim/notifications/_notification.html.erb +0 -20
- data/app/views/decidim/notifications/index.html.erb +0 -36
- data/app/views/decidim/shared/_author.html.erb +0 -21
- data/app/views/pages/home.html.erb +0 -17
- data/db/migrate/20180613080638_rename_missing_features_to_components.rb +0 -15
- data/lib/decidim/abilities.rb +0 -7
- data/lib/decidim/abilities/participatory_process_role_ability.rb +0 -60
- data/lib/decidim/page_finder.rb +0 -49
@@ -0,0 +1,6 @@
|
|
1
|
+
<% if commentable? %>
|
2
|
+
<%= link_to "#{resource_locator(from_context).path}#comments", title: t("decidim.author.comments", count: :many) do %>
|
3
|
+
<%= icon "comment-square", class: "icon--small", aria_label: t("decidim.author.comments", count: :many), role: "img" %>
|
4
|
+
<%= from_context.comments.count %> <%= t("decidim.author.comments", count: from_context.comments.count) %>
|
5
|
+
<% end %>
|
6
|
+
<% end %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<% if flagable? %>
|
2
|
+
<button type="button" data-open="<%= current_user.present? ? "flagModal" : "loginModal" %>" title="<%= t("report", scope: "decidim.proposals.proposals.show") %>" aria-controls="<%= current_user.present? ? "flagModal" : "loginModal" %>" aria-haspopup="true" tabindex="0">
|
3
|
+
<%= icon "flag", aria_label: t("report", scope: "decidim.proposals.proposals.show"), class: "icon--small" %>
|
4
|
+
</button>
|
5
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="<%= author_classes %>">
|
2
|
+
<div class="author-data__main">
|
3
|
+
<%= render :profile %>
|
4
|
+
<%= render :contact %>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<% if actionable? %>
|
8
|
+
<div class="author-data__extra">
|
9
|
+
<%= render :date %>
|
10
|
+
|
11
|
+
<%= render :comments %>
|
12
|
+
|
13
|
+
<%= render :flag %>
|
14
|
+
|
15
|
+
<%= render :withdraw %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<% if withdrawable? %>
|
2
|
+
<%= action_authorized_link_to :withdraw, withdraw_path, method: :put, class: "title-action__action button small hollow", title: t("withdraw_btn_hint", scope: "decidim.proposals.proposals.show"), data: {confirm: t("withdraw_confirmation", scope: "decidim.proposals.proposals.show")} do %>
|
3
|
+
<%= t("withdraw_proposal", scope: "decidim.proposals.proposals.show") %>
|
4
|
+
<%= icon "x" %>
|
5
|
+
<% end %>
|
6
|
+
<% end %>
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This cell renders the author of a resource. It is intended to be used
|
5
|
+
# below resource titles to indicate its authorship & such, and is intended
|
6
|
+
# for resources that have a single author.
|
7
|
+
class AuthorCell < Decidim::ViewModel
|
8
|
+
include LayoutHelper
|
9
|
+
include ::Devise::Controllers::Helpers
|
10
|
+
include ::Devise::Controllers::UrlHelpers
|
11
|
+
include Messaging::ConversationHelper
|
12
|
+
|
13
|
+
property :profile_path
|
14
|
+
|
15
|
+
delegate :current_user, to: :controller, prefix: false
|
16
|
+
|
17
|
+
def show
|
18
|
+
render
|
19
|
+
end
|
20
|
+
|
21
|
+
def profile
|
22
|
+
render
|
23
|
+
end
|
24
|
+
|
25
|
+
def profile_inline
|
26
|
+
render
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def from_context
|
32
|
+
options[:from].presence || context[:from].presence
|
33
|
+
end
|
34
|
+
|
35
|
+
def from_context_path
|
36
|
+
resource_locator(from_context).path
|
37
|
+
end
|
38
|
+
|
39
|
+
def withdraw_path
|
40
|
+
from_context_path + "/withdraw"
|
41
|
+
end
|
42
|
+
|
43
|
+
def withdrawable?
|
44
|
+
return unless from_context
|
45
|
+
return unless proposals_controller?
|
46
|
+
return if index_action?
|
47
|
+
from_context.withdrawable_by?(current_user)
|
48
|
+
end
|
49
|
+
|
50
|
+
def flagable?
|
51
|
+
return unless from_context
|
52
|
+
return unless proposals_controller?
|
53
|
+
return if index_action?
|
54
|
+
return if from_context.official?
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
def creation_date?
|
59
|
+
return true if posts_controller?
|
60
|
+
return unless from_context
|
61
|
+
return unless proposals_controller?
|
62
|
+
return unless show_action?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
def commentable?
|
67
|
+
return unless posts_controller?
|
68
|
+
true
|
69
|
+
end
|
70
|
+
|
71
|
+
def author_classes
|
72
|
+
(["author-data"] + options[:extra_classes].to_a).join(" ")
|
73
|
+
end
|
74
|
+
|
75
|
+
def actionable?
|
76
|
+
return false if options[:has_actions] == false
|
77
|
+
return true if user_author? && posts_controller?
|
78
|
+
true if withdrawable? || flagable?
|
79
|
+
end
|
80
|
+
|
81
|
+
def user_author?
|
82
|
+
true if "Decidim::UserPresenter".include? model.class.to_s
|
83
|
+
end
|
84
|
+
|
85
|
+
def proposals_controller?
|
86
|
+
context[:controller].class.to_s == "Decidim::Proposals::ProposalsController"
|
87
|
+
end
|
88
|
+
|
89
|
+
def posts_controller?
|
90
|
+
context[:controller].class.to_s == "Decidim::Blogs::PostsController"
|
91
|
+
end
|
92
|
+
|
93
|
+
def index_action?
|
94
|
+
context[:controller].action_name == "index"
|
95
|
+
end
|
96
|
+
|
97
|
+
def show_action?
|
98
|
+
context[:controller].action_name == "show"
|
99
|
+
end
|
100
|
+
|
101
|
+
def current_component
|
102
|
+
from_context.component
|
103
|
+
end
|
104
|
+
|
105
|
+
def profile_path?
|
106
|
+
profile_path.present?
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -1,17 +1,19 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
<div class="column">
|
2
|
+
<article class="card">
|
3
|
+
<div class="card__content">
|
4
|
+
<% if title.present? %>
|
5
|
+
<div class="card__header">
|
6
|
+
<h5 class="card__title">
|
7
|
+
<%= title %>
|
8
|
+
</h5>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
</article>
|
12
|
+
<% if body.present? %>
|
13
|
+
<p>
|
14
|
+
<%= body %>
|
15
|
+
</p>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
</article>
|
19
|
+
</div>
|
@@ -5,9 +5,6 @@ module Decidim
|
|
5
5
|
# delegated to the components' cell if specified in the manifest
|
6
6
|
# otherwise a primary cell wil be shown.
|
7
7
|
class CardCell < Decidim::ViewModel
|
8
|
-
property :body
|
9
|
-
property :title
|
10
|
-
|
11
8
|
def show
|
12
9
|
if resource_cell?
|
13
10
|
cell(resource_cell, model, options)
|
@@ -23,7 +20,23 @@ module Decidim
|
|
23
20
|
end
|
24
21
|
|
25
22
|
def resource_cell
|
26
|
-
|
23
|
+
if model.respond_to?(:resource_manifest) && model.resource_manifest.card.present?
|
24
|
+
@resource_cell ||= model.resource_manifest.card
|
25
|
+
elsif ["Decidim::Proposals::OfficialAuthorPresenter", "Decidim::Debates::OfficialAuthorPresenter"].include? model.class.to_s
|
26
|
+
@resource_cell ||= "decidim/author"
|
27
|
+
elsif ["Decidim::User", "Decidim::UserGroup"].include? model.model_name.name
|
28
|
+
@resource_cell ||= "decidim/author"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def title
|
33
|
+
return if model.respond_to? :title
|
34
|
+
model.name
|
35
|
+
end
|
36
|
+
|
37
|
+
def body
|
38
|
+
return if model.respond_to? :body
|
39
|
+
model.about
|
27
40
|
end
|
28
41
|
end
|
29
42
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= content_tag :span, badge_name, class: badge_classes %>
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="card__header">
|
2
|
+
<% if has_link_to_resource? %>
|
3
|
+
<%= link_to resource_path, class: "card__link" do %>
|
4
|
+
<h5 class="card__title">
|
5
|
+
<%= title %>
|
6
|
+
</h5>
|
7
|
+
<% end %>
|
8
|
+
<% else %>
|
9
|
+
<div class="card__link">
|
10
|
+
<h5 class="card__title">
|
11
|
+
<%= title %>
|
12
|
+
</h5>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= render :author if has_author? %>
|
17
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="column" id="<%= dom_id(model) %>">
|
2
|
+
<article class="card <%= card_classes %>">
|
3
|
+
<%= render :label if has_label? %>
|
4
|
+
|
5
|
+
<%= render :image if has_image? %>
|
6
|
+
|
7
|
+
<div class="card__content">
|
8
|
+
<%= render :header %>
|
9
|
+
|
10
|
+
<div class="card__text">
|
11
|
+
<div class="card__text--paragraph">
|
12
|
+
<%= render :badge if has_badge? %>
|
13
|
+
<%= description %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<%= render :tags %>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<%= render :data %>
|
21
|
+
<%= render :status %>
|
22
|
+
<%= render :footer %>
|
23
|
+
</article>
|
24
|
+
</div>
|
File without changes
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This cell is used a based for all M-sized cards. It holds the basic layout
|
5
|
+
# so other cells only have to customize a few methods or overwrite views.
|
6
|
+
class CardMCell < Decidim::ViewModel
|
7
|
+
include Cell::ViewModel::Partial
|
8
|
+
include Decidim::ApplicationHelper
|
9
|
+
include Decidim::TooltipHelper
|
10
|
+
include Decidim::SanitizeHelper
|
11
|
+
include Decidim::CardHelper
|
12
|
+
include Decidim::LayoutHelper
|
13
|
+
|
14
|
+
def show
|
15
|
+
render
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def resource_path
|
21
|
+
resource_locator(model).path
|
22
|
+
end
|
23
|
+
|
24
|
+
def resource_image_path
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def has_image?
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
def has_link_to_resource?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def has_label?
|
37
|
+
context[:label].presence
|
38
|
+
end
|
39
|
+
|
40
|
+
def label
|
41
|
+
return if [false, "false"].include? context[:label]
|
42
|
+
return @label ||= t(model.class.model_name.i18n_key, scope: "activerecord.models", count: 1) if [true, "true"].include? context[:label]
|
43
|
+
context[:label]
|
44
|
+
end
|
45
|
+
|
46
|
+
def title
|
47
|
+
translated_attribute model.title
|
48
|
+
end
|
49
|
+
|
50
|
+
def description
|
51
|
+
attribute = model.try(:short_description) || model.try(:body) || model.description
|
52
|
+
text = translated_attribute(attribute)
|
53
|
+
|
54
|
+
decidim_sanitize(html_truncate(text, length: 100))
|
55
|
+
end
|
56
|
+
|
57
|
+
def decidim
|
58
|
+
Decidim::Core::Engine.routes.url_helpers
|
59
|
+
end
|
60
|
+
|
61
|
+
def has_author?
|
62
|
+
model.is_a?(Decidim::Authorable)
|
63
|
+
end
|
64
|
+
|
65
|
+
def author
|
66
|
+
present(model).author
|
67
|
+
end
|
68
|
+
|
69
|
+
def has_actions?
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
73
|
+
def has_state?
|
74
|
+
false
|
75
|
+
end
|
76
|
+
|
77
|
+
def has_badge?
|
78
|
+
has_state?
|
79
|
+
end
|
80
|
+
|
81
|
+
def badge_name
|
82
|
+
model.state
|
83
|
+
end
|
84
|
+
|
85
|
+
def base_card_class
|
86
|
+
"card--#{dom_class(model)}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def card_classes
|
90
|
+
classes = [base_card_class]
|
91
|
+
return classes unless has_state?
|
92
|
+
classes.concat(state_classes).join(" ")
|
93
|
+
end
|
94
|
+
|
95
|
+
def badge_classes
|
96
|
+
state_classes.concat(["card__text--status"]).join(" ")
|
97
|
+
end
|
98
|
+
|
99
|
+
def state_classes
|
100
|
+
["muted"]
|
101
|
+
end
|
102
|
+
|
103
|
+
def comments_count
|
104
|
+
model.comments.count
|
105
|
+
end
|
106
|
+
|
107
|
+
def statuses
|
108
|
+
collection = [:creation_date]
|
109
|
+
collection << :follow if model.is_a?(Decidim::Followable) && model != try(:current_user)
|
110
|
+
collection << :comments_count if model.is_a?(Decidim::Comments::Commentable)
|
111
|
+
collection
|
112
|
+
end
|
113
|
+
|
114
|
+
def creation_date_status
|
115
|
+
l(model.created_at.to_date, format: :decidim_short)
|
116
|
+
end
|
117
|
+
|
118
|
+
def follow_status
|
119
|
+
cell "decidim/follow_button", model, inline: true
|
120
|
+
end
|
121
|
+
|
122
|
+
def comments_count_status
|
123
|
+
return render_comments_count unless has_link_to_resource?
|
124
|
+
|
125
|
+
link_to resource_path do
|
126
|
+
render_comments_count
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def render_comments_count
|
131
|
+
with_tooltip t("decidim.comments.comments") do
|
132
|
+
render :comments_counter
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|