decidim-proposals 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/admin/decidim_proposals_manifest.js +1 -0
- data/app/assets/images/decidim/gamification/badges/accepted_proposals.svg +1 -234
- data/app/assets/images/decidim/gamification/badges/proposal_votes.svg +1 -95
- data/app/assets/images/decidim/gamification/badges/proposals.svg +1 -229
- data/app/assets/images/decidim/proposals/icon.svg +1 -3
- data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +0 -5
- data/app/assets/javascripts/decidim/proposals/admin/proposals_picker.js.es6 +35 -0
- data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +1 -1
- data/app/cells/decidim/proposals/collaborative_draft_m/footer.erb +1 -1
- data/app/cells/decidim/proposals/collaborative_draft_m_cell.rb +1 -1
- data/app/cells/decidim/proposals/highlighted_proposals_for_component/show.erb +3 -3
- data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +1 -1
- data/app/cells/decidim/proposals/irreversible_action_modal/show.erb +2 -2
- data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
- data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +1 -1
- data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_m/footer.erb +4 -1
- data/app/cells/decidim/proposals/proposal_m_cell.rb +28 -8
- data/app/cells/decidim/proposals/proposal_tags/show.erb +8 -2
- data/app/cells/decidim/proposals/proposals_picker/proposals.erb +12 -0
- data/app/cells/decidim/proposals/proposals_picker/show.erb +14 -0
- data/app/cells/decidim/proposals/proposals_picker_cell.rb +72 -0
- data/app/commands/decidim/proposals/admin/create_proposal.rb +1 -1
- data/app/commands/decidim/proposals/admin/create_proposal_note.rb +15 -0
- data/app/commands/decidim/proposals/admin/update_proposal.rb +1 -1
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/create_proposal.rb +1 -1
- data/app/commands/decidim/proposals/gallery_methods.rb +2 -51
- data/app/commands/decidim/proposals/update_proposal.rb +1 -1
- data/app/controllers/concerns/decidim/proposals/admin/picker.rb +21 -0
- data/app/controllers/concerns/decidim/proposals/orderable.rb +1 -1
- data/app/controllers/decidim/proposals/proposals_controller.rb +4 -5
- data/app/controllers/decidim/proposals/versions_controller.rb +8 -18
- data/app/events/decidim/proposals/admin/proposal_note_created_event.rb +27 -0
- data/app/forms/decidim/proposals/admin/participatory_text_proposal_form.rb +13 -0
- data/app/forms/decidim/proposals/admin/preview_participatory_text_form.rb +2 -2
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +129 -0
- data/app/forms/decidim/proposals/admin/proposal_form.rb +2 -120
- data/app/forms/decidim/proposals/proposal_form.rb +4 -0
- data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +5 -1
- data/app/helpers/decidim/proposals/admin/filterable_helper.rb +2 -2
- data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +2 -2
- data/app/helpers/decidim/proposals/admin/proposals_picker_helper.rb +30 -0
- data/app/helpers/decidim/proposals/application_helper.rb +6 -6
- data/app/helpers/decidim/proposals/control_version_helper.rb +1 -37
- data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -145
- data/app/helpers/decidim/proposals/proposal_votes_helper.rb +2 -2
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +24 -7
- data/app/helpers/decidim/proposals/proposals_helper.rb +6 -0
- data/app/models/decidim/proposals/proposal.rb +4 -14
- data/app/permissions/decidim/proposals/permissions.rb +1 -22
- data/app/presenters/decidim/proposals/proposal_presenter.rb +14 -2
- data/app/queries/decidim/proposals/metrics/accepted_proposals_metric_manage.rb +1 -2
- data/app/queries/decidim/proposals/metrics/endorsements_metric_manage.rb +15 -12
- data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +5 -4
- data/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb +2 -8
- data/app/queries/decidim/proposals/metrics/votes_metric_manage.rb +3 -9
- data/app/services/decidim/proposals/diff_renderer.rb +2 -0
- data/app/services/decidim/proposals/proposal_builder.rb +1 -1
- data/app/services/decidim/proposals/proposal_search.rb +2 -2
- data/app/types/decidim/proposals/proposal_input_sort.rb +1 -7
- data/app/types/decidim/proposals/proposal_type.rb +1 -11
- data/app/types/decidim/proposals/proposals_type.rb +10 -0
- data/app/validators/proposal_length_validator.rb +38 -0
- data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +9 -1
- data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +2 -2
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +3 -23
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/show.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +6 -4
- data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +9 -7
- data/app/views/decidim/proposals/collaborative_drafts/_new_collaborative_draft_button.html.erb +4 -4
- data/app/views/decidim/proposals/collaborative_drafts/_reject_request_access_form.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +4 -2
- data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +2 -0
- data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +2 -0
- data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +3 -1
- data/app/views/decidim/proposals/collaborative_drafts/index.html.erb +4 -2
- data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +4 -0
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +29 -30
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +5 -3
- data/app/views/decidim/proposals/proposals/_endorsements_card_row.html.erb +0 -16
- data/app/views/decidim/proposals/proposals/_filters.html.erb +12 -10
- data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +1 -11
- data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_proposals.html.erb +14 -0
- data/app/views/decidim/proposals/proposals/_vote_button.html.erb +13 -6
- data/app/views/decidim/proposals/proposals/_wizard_aside.html.erb +4 -2
- data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +4 -3
- data/app/views/decidim/proposals/proposals/compare.html.erb +2 -0
- data/app/views/decidim/proposals/proposals/complete.html.erb +2 -0
- data/app/views/decidim/proposals/proposals/edit.html.erb +3 -1
- data/app/views/decidim/proposals/proposals/edit_draft.html.erb +2 -0
- data/app/views/decidim/proposals/proposals/index.html.erb +5 -10
- data/app/views/decidim/proposals/proposals/new.html.erb +5 -1
- data/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_vote_button.html.erb +10 -3
- data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/preview.html.erb +7 -8
- data/app/views/decidim/proposals/proposals/show.html.erb +52 -34
- data/app/views/decidim/proposals/versions/index.html.erb +14 -32
- data/app/views/decidim/proposals/versions/show.html.erb +16 -34
- data/config/locales/ar.yml +8 -64
- data/config/locales/bg-BG.yml +237 -0
- data/config/locales/ca.yml +68 -61
- data/config/locales/cs.yml +78 -68
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/de.yml +142 -58
- data/config/locales/el.yml +875 -0
- data/config/locales/en.yml +74 -67
- data/config/locales/es-MX.yml +68 -61
- data/config/locales/es-PY.yml +68 -61
- data/config/locales/es.yml +68 -61
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/eu.yml +5 -43
- data/config/locales/fi-plain.yml +68 -61
- data/config/locales/fi.yml +109 -102
- data/config/locales/fr-CA.yml +876 -0
- data/config/locales/fr.yml +128 -60
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +5 -43
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hu.yml +38 -61
- data/config/locales/id-ID.yml +5 -42
- data/config/locales/is-IS.yml +1 -27
- data/config/locales/it.yml +136 -76
- data/config/locales/ja-JP.yml +886 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lv-LV.yml +858 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/nl.yml +114 -59
- data/config/locales/no.yml +11 -64
- data/config/locales/pl.yml +170 -60
- data/config/locales/pt-BR.yml +6 -47
- data/config/locales/pt.yml +419 -331
- data/config/locales/ro-RO.yml +840 -0
- data/config/locales/ru.yml +1 -40
- data/config/locales/sk-SK.yml +896 -0
- data/config/locales/sk.yml +869 -0
- data/config/locales/sl.yml +26 -0
- data/config/locales/sr-CS.yml +126 -0
- data/config/locales/sv.yml +228 -156
- data/config/locales/tr-TR.yml +5 -43
- data/config/locales/uk.yml +1 -40
- data/db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb +4 -0
- data/db/migrate/20191206154128_add_endorsements_counter_cache_to_proposals.rb +7 -0
- data/db/migrate/20200120215928_move_proposal_endorsements_to_core_endorsements.rb +52 -0
- data/db/migrate/20200730131631_move_proposal_endorsed_event_notifications_to_resource_endorsed_event.rb +20 -0
- data/lib/decidim/proposals/component.rb +8 -4
- data/lib/decidim/proposals/engine.rb +1 -5
- data/lib/decidim/proposals/test/capybara_proposals_picker.rb +49 -0
- data/lib/decidim/proposals/test/factories.rb +3 -12
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +55 -34
- data/app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6 +0 -56
- data/app/cells/decidim/proposals/endorsers_list/show.erb +0 -17
- data/app/cells/decidim/proposals/endorsers_list_cell.rb +0 -31
- data/app/commands/decidim/proposals/attachment_methods.rb +0 -43
- data/app/commands/decidim/proposals/endorse_proposal.rb +0 -59
- data/app/commands/decidim/proposals/unendorse_proposal.rb +0 -40
- data/app/controllers/decidim/proposals/proposal_endorsements_controller.rb +0 -60
- data/app/models/decidim/proposals/proposal_endorsement.rb +0 -37
- data/app/views/decidim/proposals/proposal_endorsements/_identity.html.erb +0 -9
- data/app/views/decidim/proposals/proposal_endorsements/identities.html.erb +0 -12
- data/app/views/decidim/proposals/proposal_endorsements/update_buttons_and_counters.js.erb +0 -20
- data/app/views/decidim/proposals/proposals/_endorsement_button.html.erb +0 -11
- data/app/views/decidim/proposals/proposals/_endorsement_identities_cabin.html.erb +0 -13
- data/app/views/decidim/proposals/versions/_version.html.erb +0 -20
@@ -1,3 +1 @@
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 35">
|
2
|
-
<path d="M17.5 35A17.5 17.5 0 1 1 35 17.5 17.52 17.52 0 0 1 17.5 35zm0-33.06A15.56 15.56 0 1 0 33.06 17.5 15.57 15.57 0 0 0 17.5 1.94zm9.5 13.7H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zm0 3.68H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zM22.26 23H8a1 1 0 0 1 0-1.94h14.26a1 1 0 0 1 0 1.94z"/>
|
3
|
-
</svg>
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 35"><path d="M17.5 35A17.5 17.5 0 1 1 35 17.5 17.52 17.52 0 0 1 17.5 35zm0-33.06A15.56 15.56 0 1 0 33.06 17.5 15.57 15.57 0 0 0 17.5 1.94zm9.5 13.7H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zm0 3.68H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zM22.26 23H8a1 1 0 0 1 0-1.94h14.26a1 1 0 0 1 0 1.94z"/></svg>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
$(() => {
|
2
|
+
const $content = $(".picker-content"),
|
3
|
+
pickerMore = $content.data("picker-more"),
|
4
|
+
pickerPath = $content.data("picker-path"),
|
5
|
+
toggleNoProposals = () => {
|
6
|
+
const showNoProposals = $("#proposals_list li:visible").length === 0
|
7
|
+
$("#no_proposals").toggle(showNoProposals)
|
8
|
+
}
|
9
|
+
|
10
|
+
let jqxhr = null
|
11
|
+
|
12
|
+
toggleNoProposals()
|
13
|
+
|
14
|
+
$(".data_picker-modal-content").on("change keyup", "#proposals_filter", (event) => {
|
15
|
+
const filter = event.target.value.toLowerCase()
|
16
|
+
|
17
|
+
if (pickerMore) {
|
18
|
+
if (jqxhr !== null) {
|
19
|
+
jqxhr.abort()
|
20
|
+
}
|
21
|
+
|
22
|
+
$content.html("<div class='loading-spinner'></div>")
|
23
|
+
jqxhr = $.get(`${pickerPath}?q=${filter}`, (data) => {
|
24
|
+
$content.html(data)
|
25
|
+
jqxhr = null
|
26
|
+
toggleNoProposals()
|
27
|
+
})
|
28
|
+
} else {
|
29
|
+
$("#proposals_list li").each((index, li) => {
|
30
|
+
$(li).toggle(li.textContent.toLowerCase().indexOf(filter) > -1)
|
31
|
+
})
|
32
|
+
toggleNoProposals()
|
33
|
+
}
|
34
|
+
})
|
35
|
+
})
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="card__footer">
|
2
2
|
<div class="card__support">
|
3
3
|
<div class="card__support__data"></div>
|
4
|
-
<%= link_to t("decidim.proposals.collaborative_drafts.collaborative_draft.view_collaborative_draft"), resource_path, class: "card__button button small
|
4
|
+
<%= link_to t("decidim.proposals.collaborative_drafts.collaborative_draft.view_collaborative_draft"), resource_path, class: "card__button button--sc light button small" %>
|
5
5
|
</div>
|
6
6
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<section class="section row collapse highlighted_proposals">
|
2
|
-
<
|
2
|
+
<h3 class="section-heading">
|
3
3
|
<%= translated_attribute(model.name) %> <a href="<%= main_component_path(model) %>" class="text-small"><%= t("decidim.participatory_spaces.highlighted_proposals.see_all", count: proposals_count) %></a>
|
4
|
-
</
|
4
|
+
</h3>
|
5
5
|
|
6
6
|
<%= cell(
|
7
7
|
"decidim/collapsible_list",
|
@@ -14,6 +14,6 @@
|
|
14
14
|
<%= link_to(
|
15
15
|
t("decidim.participatory_spaces.highlighted_proposals.see_all", count: proposals_count),
|
16
16
|
main_component_path(model),
|
17
|
-
class: "button button--sc
|
17
|
+
class: "button button--sc hollow button--right"
|
18
18
|
) %>
|
19
19
|
</section>
|
@@ -23,7 +23,7 @@ module Decidim
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def proposals_to_render
|
26
|
-
@proposals_to_render ||= proposals.limit(Decidim::Proposals.config.participatory_space_highlighted_proposals_limit)
|
26
|
+
@proposals_to_render ||= proposals.includes([:amendable, :category, :component, :scope]).limit(Decidim::Proposals.config.participatory_space_highlighted_proposals_limit)
|
27
27
|
end
|
28
28
|
|
29
29
|
def proposals_count
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%= button_reveal_modal %>
|
2
2
|
|
3
|
-
<div id="<%= modal_id %>" class="reveal" data-reveal aria-labelledby="<%=
|
3
|
+
<div id="<%= modal_id %>" class="reveal" data-reveal aria-labelledby="<%= modal_id %>-title" aria-hidden="true" role="dialog">
|
4
4
|
<div class="reveal__header">
|
5
|
-
<h3 class="reveal__title">
|
5
|
+
<h3 id="<%= modal_id %>-title" class="reveal__title">
|
6
6
|
<%= modal_title %>
|
7
7
|
</h3>
|
8
8
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<% if component_settings.comments_enabled? %>
|
15
15
|
<div class="button-group button-group--collapse row collapse comment-buttons">
|
16
16
|
<% if current_settings.comments_blocked? %>
|
17
|
-
<%= content_tag :button, class: "column medium-4 button light secondary"
|
17
|
+
<%= content_tag :button, class: "column medium-4 button light secondary" do %>
|
18
18
|
<%= icon "comment-square", class: "icon--small", aria_label: t("comments", scope: "decidim.proposals.participatory_text_proposal.buttons"), role: "img" %>
|
19
19
|
<%= model.comments.count %>
|
20
20
|
<% end %>
|
@@ -21,7 +21,7 @@ module Decidim
|
|
21
21
|
def title
|
22
22
|
case model.participatory_text_level
|
23
23
|
when "section"
|
24
|
-
"<h5><strong
|
24
|
+
"<h5><strong>#{section_title}</strong></h5>"
|
25
25
|
else
|
26
26
|
"<h6><strong>#{section_title}</strong></h6>"
|
27
27
|
end
|
@@ -16,7 +16,10 @@
|
|
16
16
|
<%= render partial: "decidim/proposals/proposals/vote_button.html", locals: { proposal: model, from_proposals_list: true } %>
|
17
17
|
<% elsif has_footer? %>
|
18
18
|
<div class="card__support__data"></div>
|
19
|
-
<%= link_to
|
19
|
+
<%= link_to resource_path, class: "card__button button--sc light button small" do %>
|
20
|
+
<%= t("decidim.proposals.proposals.proposal.view_proposal") %>
|
21
|
+
<span class="show-for-sr"><%= title %></span>
|
22
|
+
<% end %>
|
20
23
|
<% end %>
|
21
24
|
</div>
|
22
25
|
</div>
|
@@ -14,12 +14,16 @@ module Decidim
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
+
def preview?
|
18
|
+
options[:preview]
|
19
|
+
end
|
20
|
+
|
17
21
|
def title
|
18
22
|
decidim_html_escape(present(model).title)
|
19
23
|
end
|
20
24
|
|
21
25
|
def body
|
22
|
-
present(model).body
|
26
|
+
decidim_sanitize(present(model).body)
|
23
27
|
end
|
24
28
|
|
25
29
|
def has_state?
|
@@ -50,28 +54,40 @@ module Decidim
|
|
50
54
|
state_classes.concat(["label", "proposal-status"]).join(" ")
|
51
55
|
end
|
52
56
|
|
57
|
+
def base_statuses
|
58
|
+
@base_statuses ||= begin
|
59
|
+
if endorsements_visible?
|
60
|
+
[:endorsements_count, :comments_count]
|
61
|
+
else
|
62
|
+
[:comments_count]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
53
67
|
def statuses
|
54
|
-
return [
|
55
|
-
return
|
68
|
+
return [] if preview?
|
69
|
+
return base_statuses if model.draft?
|
70
|
+
return [:creation_date] + base_statuses if !has_link_to_resource? || !can_be_followed?
|
56
71
|
|
57
|
-
[:creation_date, :follow
|
72
|
+
[:creation_date, :follow] + base_statuses
|
58
73
|
end
|
59
74
|
|
60
75
|
def creation_date_status
|
61
|
-
|
76
|
+
explanation = content_tag(:strong, t("activemodel.attributes.common.created_at"))
|
77
|
+
"#{explanation}<br>#{l(model.published_at.to_date, format: :decidim_short)}"
|
62
78
|
end
|
63
79
|
|
64
80
|
def endorsements_count_status
|
65
81
|
return endorsements_count unless has_link_to_resource?
|
66
82
|
|
67
|
-
link_to resource_path do
|
83
|
+
link_to resource_path, "aria-label" => "#{t("decidim.endorsable.endorsements_count")}: #{model.endorsements_count}", title: t("decidim.endorsable.endorsements_count") do
|
68
84
|
endorsements_count
|
69
85
|
end
|
70
86
|
end
|
71
87
|
|
72
88
|
def endorsements_count
|
73
|
-
with_tooltip t("decidim.
|
74
|
-
icon("bullhorn", class: "icon--small") + " " + model.
|
89
|
+
with_tooltip t("decidim.endorsable.endorsements") do
|
90
|
+
icon("bullhorn", class: "icon--small") + " " + model.endorsements_count.to_s
|
75
91
|
end
|
76
92
|
end
|
77
93
|
|
@@ -95,6 +111,10 @@ module Decidim
|
|
95
111
|
!model.withdrawn?
|
96
112
|
end
|
97
113
|
|
114
|
+
def endorsements_visible?
|
115
|
+
model.component.current_settings.endorsements_enabled?
|
116
|
+
end
|
117
|
+
|
98
118
|
def has_image?
|
99
119
|
model.attachments.first.present? && model.attachments.first.file.content_type.start_with?("image") && model.component.settings.allow_card_image
|
100
120
|
end
|
@@ -2,7 +2,10 @@
|
|
2
2
|
<ul class="tags tags--proposal tags--list">
|
3
3
|
<% if category.present? %>
|
4
4
|
<li>
|
5
|
-
<%= link_to
|
5
|
+
<%= link_to resource_locator(model).index(filter: { category_id: [category.id.to_s] }), title: t("decidim.tags.filter_results_for_category", resource: translated_attribute(category.name)) do %>
|
6
|
+
<span class="show-for-sr"><%= t "decidim.tags.filter_results_for_category", resource: translated_attribute(category.name) %></span>
|
7
|
+
<span aria-hidden="true"><%= translated_attribute(category.name) %></span>
|
8
|
+
<% end %>
|
6
9
|
<% if previous_category.present? && show_previous_category? %>
|
7
10
|
|
8
11
|
<small class="text-small">
|
@@ -14,7 +17,10 @@
|
|
14
17
|
|
15
18
|
<% if has_visible_scopes?(model) %>
|
16
19
|
<li>
|
17
|
-
<%= link_to
|
20
|
+
<%= link_to resource_locator(model).index(filter: { scope_id: [scope.id] }), title: t("decidim.tags.filter_results_for_scope", resource: translated_attribute(scope.name)) do %>
|
21
|
+
<span class="show-for-sr"><%= t "decidim.tags.filter_results_for_scope", resource: translated_attribute(scope.name) %></span>
|
22
|
+
<span aria-hidden="true"><%= translated_attribute(scope.name) %></span>
|
23
|
+
<% end %>
|
18
24
|
<% if previous_scope.present? && show_previous_scope? %>
|
19
25
|
|
20
26
|
<small class="text-small">
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<ul id="proposals_list">
|
2
|
+
<% decorated_proposals do |proposal| %>
|
3
|
+
<li>
|
4
|
+
<label><input type="checkbox" data-picker-text="<%= proposal.id_and_title(html_escape: true) %>" data-picker-url="<%= picker_path %>" value="<%= proposal.id %>" data-picker-choose> <%= proposal.id_and_title(html_escape: true) %> (<%= proposal.reference %>)</label>
|
5
|
+
</li>
|
6
|
+
<% end %>
|
7
|
+
<% if more_proposals? %>
|
8
|
+
<li><div class="callout warning"><%= t("proposals_picker.more_proposals", scope: "decidim.proposals", number: more_proposals_count) %></div>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
<div id="no_proposals" class="callout warning"><%= t("proposals_picker.no_proposals", scope: "decidim.proposals") %></div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="picker-header">
|
2
|
+
<h1><%= t("proposals_picker.choose_proposals", scope: "decidim.proposals") %></h1>
|
3
|
+
<input type="text" name="proposals-filter" id="proposals_filter" placeholder="<%= t("decidim.admin.filters.search_placeholder.id_string_or_title_cont", collection: proposals_collection_name) %>">
|
4
|
+
</div>
|
5
|
+
<div class="picker-content picker-list" data-picker-path="<%= picker_path %>" data-picker-more="<%= more_proposals? %>">
|
6
|
+
<%= render :proposals %>
|
7
|
+
</div>
|
8
|
+
<div class="picker-footer">
|
9
|
+
<div class="buttons button--double">
|
10
|
+
<a class="button" data-close=""><%= t("proposals_picker.close", scope: "decidim.proposals") %></a>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= javascript_include_tag "decidim/proposals/admin/proposals_picker" %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Proposals
|
7
|
+
# This cell renders a proposals picker.
|
8
|
+
class ProposalsPickerCell < Decidim::ViewModel
|
9
|
+
MAX_PROPOSALS = 1000
|
10
|
+
|
11
|
+
def show
|
12
|
+
if filtered?
|
13
|
+
render :proposals
|
14
|
+
else
|
15
|
+
render
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
alias component model
|
20
|
+
|
21
|
+
def filtered?
|
22
|
+
!search_text.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
def picker_path
|
26
|
+
request.path
|
27
|
+
end
|
28
|
+
|
29
|
+
def search_text
|
30
|
+
params[:q]
|
31
|
+
end
|
32
|
+
|
33
|
+
def more_proposals?
|
34
|
+
@more_proposals ||= more_proposals_count.positive?
|
35
|
+
end
|
36
|
+
|
37
|
+
def more_proposals_count
|
38
|
+
@more_proposals_count ||= proposals_count - MAX_PROPOSALS
|
39
|
+
end
|
40
|
+
|
41
|
+
def proposals_count
|
42
|
+
@proposals_count ||= filtered_proposals.count
|
43
|
+
end
|
44
|
+
|
45
|
+
def decorated_proposals
|
46
|
+
filtered_proposals.limit(MAX_PROPOSALS).each do |proposal|
|
47
|
+
yield Decidim::Proposals::ProposalPresenter.new(proposal)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def filtered_proposals
|
52
|
+
@filtered_proposals ||= if filtered?
|
53
|
+
proposals.where("title ILIKE ?", "%#{search_text}%")
|
54
|
+
.or(proposals.where("reference ILIKE ?", "%#{search_text}%"))
|
55
|
+
.or(proposals.where("id::text ILIKE ?", "%#{search_text}%"))
|
56
|
+
else
|
57
|
+
proposals
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def proposals
|
62
|
+
@proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, component)
|
63
|
+
&.published
|
64
|
+
&.order(id: :asc)
|
65
|
+
end
|
66
|
+
|
67
|
+
def proposals_collection_name
|
68
|
+
Decidim::Proposals::Proposal.model_name.human(count: 2)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when a user creates a new proposal.
|
7
7
|
class CreateProposal < Rectify::Command
|
8
|
-
include AttachmentMethods
|
8
|
+
include ::Decidim::AttachmentMethods
|
9
9
|
include GalleryMethods
|
10
10
|
include HashtagsMethods
|
11
11
|
|
@@ -24,6 +24,7 @@ module Decidim
|
|
24
24
|
return broadcast(:invalid) if form.invalid?
|
25
25
|
|
26
26
|
create_proposal_note
|
27
|
+
notify_admins_and_valuators
|
27
28
|
|
28
29
|
broadcast(:ok, proposal_note)
|
29
30
|
end
|
@@ -46,6 +47,20 @@ module Decidim
|
|
46
47
|
}
|
47
48
|
)
|
48
49
|
end
|
50
|
+
|
51
|
+
def notify_admins_and_valuators
|
52
|
+
affected_users = Decidim::User.org_admins_except_me(form.current_user).all
|
53
|
+
affected_users += Decidim::Proposals::ValuationAssignment.includes(valuator_role: :user).where.not(id: form.current_user.id).where(proposal: proposal).map(&:valuator)
|
54
|
+
|
55
|
+
data = {
|
56
|
+
event: "decidim.events.proposals.admin.proposal_note_created",
|
57
|
+
event_class: Decidim::Proposals::Admin::ProposalNoteCreatedEvent,
|
58
|
+
resource: proposal,
|
59
|
+
affected_users: affected_users
|
60
|
+
}
|
61
|
+
|
62
|
+
Decidim::EventsManager.publish(data)
|
63
|
+
end
|
49
64
|
end
|
50
65
|
end
|
51
66
|
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when a user updates a proposal.
|
7
7
|
class UpdateProposal < Rectify::Command
|
8
|
-
include AttachmentMethods
|
8
|
+
include ::Decidim::AttachmentMethods
|
9
9
|
include GalleryMethods
|
10
10
|
include HashtagsMethods
|
11
11
|
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user creates a new collaborative draft.
|
6
6
|
class CreateCollaborativeDraft < Rectify::Command
|
7
|
-
include AttachmentMethods
|
7
|
+
include ::Decidim::AttachmentMethods
|
8
8
|
include HashtagsMethods
|
9
9
|
|
10
10
|
# Public: Initializes the command.
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user creates a new proposal.
|
6
6
|
class CreateProposal < Rectify::Command
|
7
|
-
include AttachmentMethods
|
7
|
+
include ::Decidim::AttachmentMethods
|
8
8
|
include HashtagsMethods
|
9
9
|
|
10
10
|
# Public: Initializes the command.
|
@@ -6,62 +6,13 @@ module Decidim
|
|
6
6
|
# and collaborative draft commands.
|
7
7
|
# Allows to create several image attachments at once
|
8
8
|
module GalleryMethods
|
9
|
-
|
10
|
-
|
11
|
-
def build_gallery
|
12
|
-
@gallery = []
|
13
|
-
@form.add_photos.each do |photo|
|
14
|
-
next unless image? photo
|
15
|
-
|
16
|
-
@gallery << Attachment.new(
|
17
|
-
title: photo.original_filename,
|
18
|
-
file: photo,
|
19
|
-
attached_to: @attached_to
|
20
|
-
)
|
21
|
-
end
|
22
|
-
end
|
9
|
+
include ::Decidim::GalleryMethods
|
23
10
|
|
24
|
-
|
25
|
-
return unless image.respond_to? :content_type
|
26
|
-
|
27
|
-
image.content_type.start_with? "image"
|
28
|
-
end
|
29
|
-
|
30
|
-
def gallery_invalid?
|
31
|
-
gallery.each do |photo|
|
32
|
-
if photo.invalid? && photo.errors.has_key?(:file)
|
33
|
-
@form.errors.add(:add_photos, photo.errors[:file])
|
34
|
-
return true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
false
|
38
|
-
end
|
39
|
-
|
40
|
-
def create_gallery
|
41
|
-
@gallery.map! do |photo|
|
42
|
-
photo.attached_to = @attached_to
|
43
|
-
photo.save!
|
44
|
-
@form.photos << photo.id.to_s
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def photo_cleanup!
|
49
|
-
@attached_to.photos.each do |photo|
|
50
|
-
photo.destroy! if @form.photos.exclude? photo.id.to_s
|
51
|
-
end
|
52
|
-
# manually reset cached photos
|
53
|
-
@attached_to.reload
|
54
|
-
@attached_to.instance_variable_set(:@photos, nil)
|
55
|
-
end
|
11
|
+
private
|
56
12
|
|
57
|
-
# maybe a custom settings options would be nice
|
58
13
|
def gallery_allowed?
|
59
14
|
@form.current_component.settings.attachments_allowed?
|
60
15
|
end
|
61
|
-
|
62
|
-
def process_gallery?
|
63
|
-
gallery_allowed? && @form.add_photos.any?
|
64
|
-
end
|
65
16
|
end
|
66
17
|
end
|
67
18
|
end
|