decidim-accountability 0.27.5 → 0.28.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/accountability/content_blocks/highlighted_results_cell.rb +3 -8
- data/app/cells/decidim/accountability/highlighted_results/show.erb +3 -1
- data/app/cells/decidim/accountability/highlighted_results_for_component/show.erb +19 -19
- data/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb +29 -6
- data/app/cells/decidim/accountability/project/show.erb +11 -0
- data/app/cells/decidim/accountability/project/timeline.erb +22 -0
- data/app/cells/decidim/accountability/project_cell.rb +75 -0
- data/app/cells/decidim/accountability/result_activity_cell.rb +1 -4
- data/app/cells/decidim/accountability/result_card_cell.rb +21 -0
- data/app/cells/decidim/accountability/result_cell.rb +2 -2
- data/app/cells/decidim/accountability/result_l/extra_data.erb +3 -0
- data/app/cells/decidim/accountability/result_l_cell.rb +30 -0
- data/app/cells/decidim/accountability/result_metadata/project_aside.erb +6 -0
- data/app/cells/decidim/accountability/result_metadata/show_footer.erb +11 -0
- data/app/cells/decidim/accountability/result_metadata/versions.erb +1 -0
- data/app/cells/decidim/accountability/result_metadata_cell.rb +136 -0
- data/app/cells/decidim/accountability/results/show.erb +7 -0
- data/app/cells/decidim/accountability/results_cell.rb +14 -0
- data/app/cells/decidim/accountability/status/show.erb +9 -0
- data/app/cells/decidim/accountability/status/status.erb +16 -0
- data/app/cells/decidim/accountability/status_cell.rb +91 -0
- data/app/commands/decidim/accountability/admin/import_projects_to_accountability.rb +37 -0
- data/app/controllers/concerns/decidim/accountability/admin/filterable.rb +2 -2
- data/app/controllers/decidim/accountability/admin/import_results_controller.rb +18 -6
- data/app/controllers/decidim/accountability/admin/projects_import_controller.rb +31 -0
- data/app/controllers/decidim/accountability/admin/results_controller.rb +4 -5
- data/app/controllers/decidim/accountability/admin/statuses_controller.rb +3 -3
- data/app/controllers/decidim/accountability/admin/timeline_entries_controller.rb +3 -3
- data/app/controllers/decidim/accountability/results_controller.rb +20 -2
- data/app/forms/decidim/accountability/admin/import_results_form.rb +22 -0
- data/app/forms/decidim/accountability/admin/result_import_projects_form.rb +51 -0
- data/app/helpers/decidim/accountability/admin/application_helper.rb +1 -0
- data/app/helpers/decidim/accountability/application_helper.rb +43 -2
- data/app/helpers/decidim/accountability/breadcrumb_helper.rb +10 -0
- data/app/jobs/decidim/accountability/admin/import_projects_job.rb +72 -0
- data/app/mailers/decidim/accountability/import_projects_mailer.rb +25 -0
- data/app/models/decidim/accountability/result.rb +1 -1
- data/app/packs/entrypoints/decidim_accountability.js +4 -1
- data/app/packs/entrypoints/decidim_accountability_admin_imports.js +3 -0
- data/app/packs/images/decidim/accountability/breadcrumb_arrow.svg +3 -0
- data/app/packs/src/decidim/accountability/admin/imports.js +15 -0
- data/app/packs/stylesheets/accountability.scss +169 -0
- data/app/permissions/decidim/accountability/admin/permissions.rb +17 -6
- data/app/presenters/decidim/accountability/admin_log/result_presenter.rb +2 -2
- data/app/presenters/decidim/accountability/admin_log/status_presenter.rb +2 -2
- data/app/presenters/decidim/accountability/admin_log/timeline_entry_presenter.rb +2 -2
- data/app/queries/decidim/accountability/metrics/results_metric_manage.rb +1 -1
- data/app/services/decidim/accountability/results_calculator.rb +1 -1
- data/app/services/decidim/accountability/results_csv_importer.rb +2 -2
- data/app/views/decidim/accountability/admin/import_results/new.html.erb +27 -23
- data/app/views/decidim/accountability/admin/projects_import/new.html.erb +45 -0
- data/app/views/decidim/accountability/admin/results/_form.html.erb +46 -46
- data/app/views/decidim/accountability/admin/results/edit.html.erb +18 -7
- data/app/views/decidim/accountability/admin/results/index.html.erb +102 -91
- data/app/views/decidim/accountability/admin/results/new.html.erb +18 -8
- data/app/views/decidim/accountability/admin/shared/_subnav.html.erb +1 -1
- data/app/views/decidim/accountability/admin/statuses/_form.html.erb +15 -17
- data/app/views/decidim/accountability/admin/statuses/edit.html.erb +16 -6
- data/app/views/decidim/accountability/admin/statuses/index.html.erb +33 -36
- data/app/views/decidim/accountability/admin/statuses/new.html.erb +16 -6
- data/app/views/decidim/accountability/admin/timeline_entries/_form.html.erb +12 -14
- data/app/views/decidim/accountability/admin/timeline_entries/edit.html.erb +17 -6
- data/app/views/decidim/accountability/admin/timeline_entries/index.html.erb +35 -34
- data/app/views/decidim/accountability/admin/timeline_entries/new.html.erb +17 -6
- data/app/views/decidim/accountability/import_projects_mailer/import.html.erb +2 -0
- data/app/views/decidim/accountability/results/_home_categories.html.erb +28 -73
- data/app/views/decidim/accountability/results/_linked_results.html.erb +3 -12
- data/app/views/decidim/accountability/results/_project.html.erb +29 -0
- data/app/views/decidim/accountability/results/_projects_aside.html.erb +40 -0
- data/app/views/decidim/accountability/results/_scope_filters.html.erb +27 -27
- data/app/views/decidim/accountability/results/_search.html.erb +15 -9
- data/app/views/decidim/accountability/results/_stats_box.html.erb +3 -3
- data/app/views/decidim/accountability/results/home.html.erb +34 -8
- data/app/views/decidim/accountability/results/index.html.erb +15 -15
- data/app/views/decidim/accountability/results/index.js.erb +3 -0
- data/app/views/decidim/accountability/results/show.html.erb +9 -10
- data/app/views/decidim/accountability/versions/show.html.erb +12 -9
- data/app/views/decidim/participatory_spaces/_result.html.erb +2 -2
- data/config/assets.rb +2 -2
- data/config/locales/ar.yml +22 -60
- data/config/locales/bg.yml +0 -36
- data/config/locales/ca.yml +53 -30
- data/config/locales/cs.yml +58 -29
- data/config/locales/da.yml +0 -36
- data/config/locales/de.yml +59 -36
- data/config/locales/el.yml +62 -29
- data/config/locales/en.yml +55 -31
- data/config/locales/es-MX.yml +52 -29
- data/config/locales/es-PY.yml +52 -29
- data/config/locales/es.yml +53 -30
- data/config/locales/eu.yml +53 -30
- data/config/locales/fi-plain.yml +51 -28
- data/config/locales/fi.yml +52 -29
- data/config/locales/fr-CA.yml +51 -28
- data/config/locales/fr.yml +52 -29
- data/config/locales/ga-IE.yml +0 -4
- data/config/locales/gl.yml +0 -41
- data/config/locales/hu.yml +41 -29
- data/config/locales/id-ID.yml +0 -30
- data/config/locales/is-IS.yml +0 -32
- data/config/locales/it.yml +0 -41
- data/config/locales/ja.yml +55 -39
- data/config/locales/kaa.yml +20 -1
- data/config/locales/ko.yml +0 -15
- data/config/locales/lb.yml +0 -41
- data/config/locales/lt.yml +60 -41
- data/config/locales/lv.yml +0 -36
- data/config/locales/nl.yml +0 -41
- data/config/locales/no.yml +8 -49
- data/config/locales/pl.yml +17 -40
- data/config/locales/pt-BR.yml +41 -29
- data/config/locales/pt.yml +0 -41
- data/config/locales/ro-RO.yml +14 -39
- data/config/locales/ru.yml +0 -30
- data/config/locales/si-LK.yml +0 -3
- data/config/locales/sk.yml +0 -40
- data/config/locales/sl.yml +0 -11
- data/config/locales/sq-AL.yml +82 -7
- data/config/locales/sr-CS.yml +0 -30
- data/config/locales/sv.yml +23 -38
- data/config/locales/tr-TR.yml +9 -62
- data/config/locales/uk.yml +0 -28
- data/config/locales/zh-CN.yml +0 -36
- data/config/locales/zh-TW.yml +52 -43
- data/lib/decidim/accountability/admin_engine.rb +3 -2
- data/lib/decidim/accountability/component.rb +4 -99
- data/lib/decidim/accountability/engine.rb +9 -1
- data/lib/decidim/accountability/result_serializer.rb +1 -1
- data/lib/decidim/accountability/seeds.rb +115 -0
- data/lib/decidim/accountability/test/factories.rb +3 -2
- data/lib/decidim/accountability/version.rb +1 -1
- metadata +61 -48
- data/app/cells/decidim/accountability/content_blocks/highlighted_results/elements.erb +0 -5
- data/app/cells/decidim/accountability/content_blocks/highlighted_results/heading.erb +0 -1
- data/app/cells/decidim/accountability/result_m/data.erb +0 -23
- data/app/cells/decidim/accountability/result_m/footer.erb +0 -22
- data/app/cells/decidim/accountability/result_m/tags.erb +0 -1
- data/app/cells/decidim/accountability/result_m_cell.rb +0 -37
- data/app/packs/stylesheets/decidim/accountability/_accountability.scss +0 -4
- data/app/packs/stylesheets/decidim/accountability/accountability/_cards.scss +0 -11
- data/app/packs/stylesheets/decidim/accountability/accountability/_categories.scss +0 -121
- data/app/packs/stylesheets/decidim/accountability/accountability/_lines_breadcrumb.scss +0 -37
- data/app/packs/stylesheets/decidim/accountability/accountability/_results.scss +0 -148
- data/app/views/decidim/accountability/admin/results/proposals_picker.html.erb +0 -1
- data/app/views/decidim/accountability/result_widgets/show.html.erb +0 -2
- data/app/views/decidim/accountability/results/_home_header.html.erb +0 -23
- data/app/views/decidim/accountability/results/_results_leaf.html.erb +0 -47
- data/app/views/decidim/accountability/results/_results_parent.html.erb +0 -32
- data/app/views/decidim/accountability/results/_show_leaf.html.erb +0 -81
- data/app/views/decidim/accountability/results/_show_parent.html.erb +0 -30
- data/app/views/decidim/accountability/results/_stats.html.erb +0 -15
- data/app/views/decidim/accountability/results/_timeline.html.erb +0 -30
- data/app/views/decidim/accountability/versions/index.html.erb +0 -12
- data/config/environment.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d0e9219637a9369c6b8ffca3060c9c11cc4127ad6b3588e5caeb35eb415778
|
4
|
+
data.tar.gz: 767f052eb960ba0e461a7864b121f410db02cb0da5981f9aa277762928a68cbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e82ced7fbbacd1dfbb756a514fe506fdfa66b281b891313bde90c460bdf67243705224703d5c4c66cae7a82c3fc49b03fbd77cd3425e4fda135da28dba264cd9
|
7
|
+
data.tar.gz: d8189bdc78ceeaef893356c262eba1d32269a4a976f9b6c4d4e38cd4617181c064d106f1820e38559fc697ba7e3b199891b1e099651bf7913f5b66688dc7cbd3
|
@@ -3,15 +3,10 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Accountability
|
5
5
|
module ContentBlocks
|
6
|
-
class HighlightedResultsCell < Decidim::ContentBlocks::
|
7
|
-
|
8
|
-
include Decidim::IconHelper
|
9
|
-
include Decidim::Accountability::ApplicationHelper
|
10
|
-
include ActiveSupport::NumberHelper
|
6
|
+
class HighlightedResultsCell < Decidim::ContentBlocks::HighlightedElementsWithCellForListCell
|
7
|
+
private
|
11
8
|
|
12
|
-
def
|
13
|
-
@base_relation ||= Decidim::Accountability::Result.where(component: published_components)
|
14
|
-
end
|
9
|
+
def list_cell_path = "decidim/accountability/highlighted_results_for_component"
|
15
10
|
end
|
16
11
|
end
|
17
12
|
end
|
@@ -1,3 +1,5 @@
|
|
1
1
|
<% published_components.each do |component| %>
|
2
|
-
|
2
|
+
<section class="content-block">
|
3
|
+
<%= cell "decidim/accountability/highlighted_results_for_component", component %>
|
4
|
+
</section>
|
3
5
|
<% end %>
|
@@ -1,21 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<%= translated_attribute(model.name) %> <a href="<%= main_component_path(model) %>" class="text-small"><%= t("decidim.participatory_spaces.highlighted_results.see_all", count: results_count) %></a>
|
4
|
-
</h3>
|
1
|
+
<%# NOTE: Since this call can be called from outside decidim-accountability, frontend assets are required %>
|
2
|
+
<%= apply_accountability_pack_tags %>
|
5
3
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
<div class="content-block__title">
|
5
|
+
<h2 class="h2 decorator">
|
6
|
+
<%= single_component? ? translated_attribute(model.name) : t("decidim.accountability.content_blocks.highlighted_results.results") %>
|
7
|
+
</h2>
|
8
|
+
<div class="label text-lg"><%= results_count %></div>
|
9
|
+
<% if single_component? %>
|
10
|
+
<%= link_to main_component_path(model), class: "button button__sm button__text-secondary" do %>
|
11
|
+
<span><%= t("decidim.participatory_spaces.highlighted_results.see_all") %></span>
|
12
|
+
<%= icon "arrow-right-line" %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
</section>
|
17
|
+
<div>
|
18
|
+
<% results_to_render.each do |result| %>
|
19
|
+
<%= cell "decidim/accountability/result_l", result, title_tag: :h3, **options.slice(:show_space) %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
@@ -14,22 +14,37 @@ module Decidim
|
|
14
14
|
include Decidim::LayoutHelper
|
15
15
|
include Cell::ViewModel::Partial
|
16
16
|
|
17
|
+
delegate :snippets, to: :controller
|
18
|
+
|
17
19
|
def show
|
18
|
-
render unless
|
20
|
+
render unless items_blank?
|
21
|
+
end
|
22
|
+
|
23
|
+
def items_blank?
|
24
|
+
results_count.zero?
|
19
25
|
end
|
20
26
|
|
21
27
|
private
|
22
28
|
|
29
|
+
def results_count
|
30
|
+
@results_count ||= results.size
|
31
|
+
end
|
32
|
+
|
23
33
|
def results
|
24
|
-
@results ||=
|
34
|
+
@results ||= case options[:order]
|
35
|
+
when "recent"
|
36
|
+
Decidim::Accountability::Result.where(component: model).order_by_most_recent
|
37
|
+
else
|
38
|
+
Decidim::Accountability::Result.where(component: model).order_randomly(random_seed)
|
39
|
+
end
|
25
40
|
end
|
26
41
|
|
27
|
-
def
|
28
|
-
@
|
42
|
+
def single_component?
|
43
|
+
@single_component ||= model.is_a?(Decidim::Component)
|
29
44
|
end
|
30
45
|
|
31
|
-
def
|
32
|
-
@
|
46
|
+
def results_to_render
|
47
|
+
@results_to_render ||= results.includes(:component, :status).limit(limit)
|
33
48
|
end
|
34
49
|
|
35
50
|
def cache_hash
|
@@ -43,6 +58,14 @@ module Decidim
|
|
43
58
|
def cache_expiry_time
|
44
59
|
10.minutes
|
45
60
|
end
|
61
|
+
|
62
|
+
def limit
|
63
|
+
4
|
64
|
+
end
|
65
|
+
|
66
|
+
def random_seed
|
67
|
+
(rand * 2) - 1
|
68
|
+
end
|
46
69
|
end
|
47
70
|
end
|
48
71
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<section class="layout-main__section layout-main__heading">
|
2
|
+
<h1 class="h2 decorator"><%= title %></h1>
|
3
|
+
</section>
|
4
|
+
|
5
|
+
<section class="layout-main__section">
|
6
|
+
<div class="editor-content mt-8">
|
7
|
+
<%= description %>
|
8
|
+
</div>
|
9
|
+
</section>
|
10
|
+
|
11
|
+
<%= cell "decidim/tab_panels", tab_panel_items %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<ol class="accountability__project-timeline">
|
2
|
+
<% timeline_entries.each_with_index do |timeline_entry, i| %>
|
3
|
+
<li class="accountability__project-timeline-entry">
|
4
|
+
<div class="accountability__project-timeline-entry-number">
|
5
|
+
<span><%= i + 1 %></span>
|
6
|
+
</div>
|
7
|
+
<div class="accountability__project-timeline-entry-attributes">
|
8
|
+
<h3>
|
9
|
+
<%= translated_attribute timeline_entry.title %>
|
10
|
+
</h3>
|
11
|
+
<div>
|
12
|
+
<%= l timeline_entry.entry_date, format: :decidim_short %>
|
13
|
+
</div>
|
14
|
+
<% if translated_attribute(timeline_entry.description).present? %>
|
15
|
+
<div>
|
16
|
+
<%= translated_attribute(timeline_entry.description).html_safe %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</li>
|
21
|
+
<% end %>
|
22
|
+
</ol>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Accountability
|
7
|
+
# This cell renders a project
|
8
|
+
class ProjectCell < Decidim::ViewModel
|
9
|
+
include ApplicationHelper
|
10
|
+
include Decidim::ResourceHelper
|
11
|
+
include Decidim::TranslationsHelper
|
12
|
+
include Decidim::AttachmentsHelper
|
13
|
+
|
14
|
+
delegate :current_component, :component_settings, to: :controller
|
15
|
+
delegate :children, :timeline_entries, to: :model
|
16
|
+
|
17
|
+
alias result model
|
18
|
+
|
19
|
+
def show
|
20
|
+
render
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def title
|
26
|
+
translated_attribute result.title
|
27
|
+
end
|
28
|
+
|
29
|
+
def description
|
30
|
+
translated_attribute(result.description).html_safe
|
31
|
+
end
|
32
|
+
|
33
|
+
def scope
|
34
|
+
current_scope.presence
|
35
|
+
end
|
36
|
+
|
37
|
+
def tab_panel_items
|
38
|
+
[
|
39
|
+
{
|
40
|
+
enabled: children.any?,
|
41
|
+
id: "list",
|
42
|
+
text: t("decidim.accountability.results.timeline.title"),
|
43
|
+
icon: "route-line",
|
44
|
+
method: :cell,
|
45
|
+
args: ["decidim/accountability/results", result.children]
|
46
|
+
},
|
47
|
+
{
|
48
|
+
enabled: result.linked_resources(:proposals, "included_proposals").present?,
|
49
|
+
id: "included_proposals",
|
50
|
+
text: t("activemodel.attributes.result.proposals"),
|
51
|
+
icon: "chat-new-line",
|
52
|
+
method: :cell,
|
53
|
+
args: ["decidim/linked_resources_for", result, { type: :proposals, link_name: "included_proposals" }]
|
54
|
+
},
|
55
|
+
{
|
56
|
+
enabled: result.linked_resources(:projects, "included_projects").present?,
|
57
|
+
id: "included_projects",
|
58
|
+
text: t("activemodel.attributes.result.project_ids"),
|
59
|
+
icon: "git-pull-request-line",
|
60
|
+
method: :cell,
|
61
|
+
args: ["decidim/linked_resources_for", result, { type: :projects, link_name: "included_projects" }]
|
62
|
+
},
|
63
|
+
{
|
64
|
+
enabled: result.linked_resources(:meetings, "meetings_through_proposals").present?,
|
65
|
+
id: "included_meetings",
|
66
|
+
text: t("activemodel.attributes.result.meetings_ids"),
|
67
|
+
icon: "treasure-map-line",
|
68
|
+
method: :cell,
|
69
|
+
args: ["decidim/linked_resources_for", result, { type: :meetings, link_name: "meetings_through_proposals" }]
|
70
|
+
}
|
71
|
+
] + attachments_tab_panel_items(result)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -5,10 +5,7 @@ module Decidim
|
|
5
5
|
# A cell to display when a Result has been created.
|
6
6
|
class ResultActivityCell < ActivityCell
|
7
7
|
def title
|
8
|
-
I18n.t(
|
9
|
-
"decidim.accountability.last_activity.new_result_at_html",
|
10
|
-
link: participatory_space_link
|
11
|
-
)
|
8
|
+
I18n.t("decidim.accountability.last_activity.new_result")
|
12
9
|
end
|
13
10
|
end
|
14
11
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Accountability
|
7
|
+
# This cell renders the result card for an instance of a Result
|
8
|
+
# the default size is the List Card (:l)
|
9
|
+
class ResultCardCell < Decidim::ViewModel
|
10
|
+
def show
|
11
|
+
cell card_size, model, options
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def card_size
|
17
|
+
"decidim/accountability/result_l"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -5,7 +5,7 @@ require "cell/partial"
|
|
5
5
|
module Decidim
|
6
6
|
module Accountability
|
7
7
|
# This cell renders the result card for an instance of a Result
|
8
|
-
# the default size is the
|
8
|
+
# the default size is the List Card (:l)
|
9
9
|
class ResultCell < Decidim::ViewModel
|
10
10
|
def show
|
11
11
|
cell card_size, model, options
|
@@ -14,7 +14,7 @@ module Decidim
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def card_size
|
17
|
-
"decidim/accountability/
|
17
|
+
"decidim/accountability/result_l"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Accountability
|
7
|
+
# This cell renders the List (:l) result card
|
8
|
+
# for an instance of a Result
|
9
|
+
class ResultLCell < Decidim::CardLCell
|
10
|
+
include ApplicationHelper
|
11
|
+
include ActiveSupport::NumberHelper
|
12
|
+
|
13
|
+
alias result model
|
14
|
+
|
15
|
+
def component_settings
|
16
|
+
controller.try(:component_settings) || result.component.settings
|
17
|
+
end
|
18
|
+
|
19
|
+
def render_extra_data?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def metadata_cell
|
26
|
+
"decidim/accountability/result_metadata"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<ul class="metadata__container layout-main__section" data-metadata-footer>
|
2
|
+
<% items.each do |item| %>
|
3
|
+
<li class="metadata__item">
|
4
|
+
<% if item.has_key? :partial %>
|
5
|
+
<%= render item[:partial] %>
|
6
|
+
<% else %>
|
7
|
+
<%= item[:text] %>
|
8
|
+
<% end %>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= resource_version(result, versions_path: result_version_path(result, result.versions.count)) %>
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Accountability
|
5
|
+
# This cell renders metadata for an instance of a Result
|
6
|
+
class ResultMetadataCell < Decidim::CardMetadataCell
|
7
|
+
include Decidim::SanitizeHelper
|
8
|
+
include Decidim::TranslationsHelper
|
9
|
+
include ActiveSupport::NumberHelper
|
10
|
+
include Decidim::ResourceReferenceHelper
|
11
|
+
include Decidim::ResourceVersionsHelper
|
12
|
+
include Decidim::Accountability::Engine.routes.url_helpers
|
13
|
+
include Decidim::LayoutHelper
|
14
|
+
|
15
|
+
delegate :start_date, :end_date, :status, :category, :parent, :reference, to: :model
|
16
|
+
|
17
|
+
alias result model
|
18
|
+
|
19
|
+
def show
|
20
|
+
render template
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(*)
|
24
|
+
super
|
25
|
+
|
26
|
+
@items.prepend(*result_items)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def result_items
|
32
|
+
return [dates_item, status_item, status_description] if template == :project_aside
|
33
|
+
return [reference, versions] if template == :show_footer
|
34
|
+
|
35
|
+
[dates_item_compact, status_item_compact, category_item]
|
36
|
+
end
|
37
|
+
|
38
|
+
def template
|
39
|
+
@template ||= options[:template] || :show
|
40
|
+
end
|
41
|
+
|
42
|
+
def dates_item_compact
|
43
|
+
return if start_date.blank?
|
44
|
+
|
45
|
+
{
|
46
|
+
text: date_values(format: :decidim_with_month_name_short).join(" - "),
|
47
|
+
icon: "calendar-todo-line"
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def reference
|
52
|
+
{ text: resource_reference(result) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def versions_count
|
56
|
+
@versions_count ||= result.versions_count
|
57
|
+
end
|
58
|
+
|
59
|
+
def versions
|
60
|
+
return if result.versions.blank?
|
61
|
+
|
62
|
+
{ partial: :versions }
|
63
|
+
end
|
64
|
+
|
65
|
+
def category_item
|
66
|
+
return if inherited_category.blank?
|
67
|
+
|
68
|
+
{
|
69
|
+
text: translated_attribute(inherited_category.name),
|
70
|
+
icon: resource_type_icon_key(category.class)
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def status_item_compact
|
75
|
+
return if status.blank?
|
76
|
+
|
77
|
+
{
|
78
|
+
text: translated_attribute(status.name),
|
79
|
+
icon: "focus-2-line"
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
def inherited_category
|
84
|
+
return category if category.present?
|
85
|
+
|
86
|
+
parent&.category
|
87
|
+
end
|
88
|
+
|
89
|
+
def dates_item
|
90
|
+
return if start_date.blank?
|
91
|
+
|
92
|
+
date_title = [
|
93
|
+
*(t("models.result.fields.start_date", scope: "decidim.accountability") if start_date),
|
94
|
+
*(t("models.result.fields.end_date", scope: "decidim.accountability") if end_date)
|
95
|
+
].join(" / ")
|
96
|
+
|
97
|
+
{
|
98
|
+
text: date_title,
|
99
|
+
icon: "calendar-todo-line",
|
100
|
+
value: date_values.join(" / ")
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def date_values(format: :decidim_short_with_month_name_short)
|
105
|
+
@date_values ||= [
|
106
|
+
*(l(start_date, format:) if start_date),
|
107
|
+
*(l(end_date, format:) if end_date)
|
108
|
+
]
|
109
|
+
end
|
110
|
+
|
111
|
+
def status_item
|
112
|
+
return if status.blank?
|
113
|
+
|
114
|
+
{
|
115
|
+
text: t("models.result.fields.status", scope: "decidim.accountability"),
|
116
|
+
icon: "focus-2-line",
|
117
|
+
value: translated_attribute(status.name)
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
def status_description
|
122
|
+
return unless status.present? && (description = translated_attribute(status.description)).present?
|
123
|
+
|
124
|
+
{
|
125
|
+
text: t("models.status.fields.description", scope: "decidim.accountability"),
|
126
|
+
icon: "file-text-line",
|
127
|
+
value: description
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
def has_dates?
|
132
|
+
start_date.present? && end_date.present?
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Accountability
|
7
|
+
# This cell renders a list of results
|
8
|
+
class ResultsCell < Decidim::ViewModel
|
9
|
+
include Decidim::CardHelper
|
10
|
+
|
11
|
+
alias results model
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<p class="accountability__status-title"><%= title %></p>
|
2
|
+
|
3
|
+
<% if component_settings.display_progress_enabled? && progress.present? %>
|
4
|
+
<div class="accountability__status-progress">
|
5
|
+
<div style="width:<%= progress %>%"></div>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<div class="accountability__status-value">
|
10
|
+
<% if progress.present? %>
|
11
|
+
<span><%= display_percentage progress %></span>
|
12
|
+
<% end %>
|
13
|
+
<% if count %>
|
14
|
+
<span><%= count %></span>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Accountability
|
7
|
+
# This cell renders the status of a category
|
8
|
+
class StatusCell < Decidim::ViewModel
|
9
|
+
include ApplicationHelper
|
10
|
+
include BreadcrumbHelper
|
11
|
+
include Decidim::TranslationsHelper
|
12
|
+
include ActiveSupport::NumberHelper
|
13
|
+
|
14
|
+
delegate :current_component, :component_settings, to: :controller
|
15
|
+
|
16
|
+
def show
|
17
|
+
return unless render?
|
18
|
+
|
19
|
+
render
|
20
|
+
end
|
21
|
+
|
22
|
+
def render?
|
23
|
+
options[:render_blank] || has_results?
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_results?
|
27
|
+
results_count&.positive? || progress.present?
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def scope
|
33
|
+
current_scope.presence
|
34
|
+
end
|
35
|
+
|
36
|
+
def url
|
37
|
+
options[:url]
|
38
|
+
end
|
39
|
+
|
40
|
+
def title
|
41
|
+
if model.is_a? Decidim::Category
|
42
|
+
translated_attribute(model.name)
|
43
|
+
else
|
44
|
+
options[:title]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def results_count
|
49
|
+
@results_count ||= if model.is_a? Decidim::Category
|
50
|
+
count_calculator(scope, model.id)
|
51
|
+
else
|
52
|
+
options[:count]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def progress
|
57
|
+
if model.is_a? Decidim::Category
|
58
|
+
progress_calculator(scope, model.id).presence
|
59
|
+
elsif model.respond_to?(:progress)
|
60
|
+
model.progress
|
61
|
+
else
|
62
|
+
options[:progress] || progress_calculator(scope, nil).presence
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def extra_classes
|
67
|
+
options[:extra_classes]
|
68
|
+
end
|
69
|
+
|
70
|
+
def count
|
71
|
+
return unless results_count&.positive? && render_count
|
72
|
+
|
73
|
+
display_count(results_count)
|
74
|
+
end
|
75
|
+
|
76
|
+
def render_count
|
77
|
+
return true unless options.has_key?(:render_count)
|
78
|
+
|
79
|
+
options[:render_count]
|
80
|
+
end
|
81
|
+
|
82
|
+
def count_calculator(scope_id, category_id)
|
83
|
+
Decidim::Accountability::ResultsCalculator.new(current_component, scope_id, category_id).count
|
84
|
+
end
|
85
|
+
|
86
|
+
def decidim
|
87
|
+
Decidim::Accountability::Engine.routes.url_helpers
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|