decidim-proposals 0.20.1 → 0.23.1
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/add_proposal.js.es6 +6 -0
- data/app/assets/javascripts/decidim/proposals/admin/proposals.es6 +24 -11
- data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +3 -5
- data/app/assets/javascripts/decidim/proposals/admin/proposals_picker.js.es6 +35 -0
- data/app/cells/decidim/proposals/collaborative_draft_cell.rb +1 -1
- 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/cost_report/show.erb +35 -0
- data/app/cells/decidim/proposals/cost_report_cell.rb +42 -0
- 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 +3 -3
- data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +2 -2
- data/app/cells/decidim/proposals/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 +37 -9
- data/app/cells/decidim/proposals/proposal_tags/show.erb +18 -10
- data/app/cells/decidim/proposals/proposal_tags_cell.rb +5 -0
- 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/answer_proposal.rb +24 -46
- data/app/commands/decidim/proposals/admin/assign_proposals_to_valuator.rb +61 -0
- data/app/commands/decidim/proposals/admin/create_proposal.rb +10 -3
- data/app/commands/decidim/proposals/admin/create_proposal_note.rb +15 -0
- data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +85 -0
- data/app/commands/decidim/proposals/admin/publish_answers.rb +67 -0
- data/app/commands/decidim/proposals/admin/publish_participatory_text.rb +6 -1
- data/app/commands/decidim/proposals/admin/unassign_proposals_from_valuator.rb +62 -0
- data/app/commands/decidim/proposals/admin/update_participatory_text.rb +10 -2
- data/app/commands/decidim/proposals/admin/update_proposal.rb +5 -3
- data/app/commands/decidim/proposals/admin/update_proposal_scope.rb +75 -0
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/create_proposal.rb +7 -3
- data/app/commands/decidim/proposals/gallery_methods.rb +2 -51
- data/app/commands/decidim/proposals/publish_collaborative_draft.rb +2 -2
- data/app/commands/decidim/proposals/update_proposal.rb +25 -9
- data/app/controllers/concerns/decidim/proposals/admin/filterable.rb +82 -0
- 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/admin/proposal_answers_controller.rb +16 -6
- data/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb +8 -9
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +107 -31
- data/app/controllers/decidim/proposals/admin/valuation_assignments_controller.rb +58 -0
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +10 -3
- data/app/controllers/decidim/proposals/proposals_controller.rb +30 -10
- data/app/controllers/decidim/proposals/versions_controller.rb +9 -16
- data/app/controllers/decidim/proposals/{proposal_widgets_controller.rb → widgets_controller.rb} +2 -2
- data/app/events/decidim/proposals/admin/proposal_note_created_event.rb +27 -0
- data/app/events/decidim/proposals/admin/update_proposal_scope_event.rb +11 -0
- data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +3 -1
- data/app/forms/decidim/proposals/admin/participatory_text_proposal_form.rb +20 -0
- data/app/forms/decidim/proposals/admin/preview_participatory_text_form.rb +2 -2
- data/app/forms/decidim/proposals/admin/proposal_answer_form.rb +27 -2
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +136 -0
- data/app/forms/decidim/proposals/admin/proposal_form.rb +6 -117
- data/app/forms/decidim/proposals/admin/valuation_assignment_form.rb +37 -0
- data/app/forms/decidim/proposals/proposal_form.rb +25 -12
- data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +13 -1
- data/app/helpers/decidim/proposals/admin/filterable_helper.rb +17 -0
- data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +35 -0
- data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +63 -0
- data/app/helpers/decidim/proposals/admin/proposals_helper.rb +124 -0
- data/app/helpers/decidim/proposals/admin/proposals_picker_helper.rb +30 -0
- data/app/helpers/decidim/proposals/application_helper.rb +54 -38
- data/app/helpers/decidim/proposals/collaborative_draft_helper.rb +9 -9
- data/app/helpers/decidim/proposals/control_version_helper.rb +1 -37
- data/app/helpers/decidim/proposals/proposal_cells_helper.rb +1 -1
- 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 +24 -0
- data/app/models/decidim/proposals/collaborative_draft.rb +2 -2
- data/app/models/decidim/proposals/participatory_text.rb +3 -0
- data/app/models/decidim/proposals/proposal.rb +152 -42
- data/app/models/decidim/proposals/valuation_assignment.rb +24 -0
- data/app/permissions/decidim/proposals/admin/permissions.rb +77 -11
- data/app/permissions/decidim/proposals/permissions.rb +1 -22
- data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +1 -1
- data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +51 -0
- data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +6 -1
- data/app/presenters/decidim/proposals/admin_log/value_types/valuator_role_user_presenter.rb +19 -0
- data/app/presenters/decidim/proposals/collaborative_draft_presenter.rb +2 -28
- data/app/presenters/decidim/proposals/log/valuation_assignment_presenter.rb +22 -0
- data/app/presenters/decidim/proposals/official_author_presenter.rb +1 -29
- data/app/presenters/decidim/proposals/proposal_presenter.rb +79 -5
- 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/queries/decidim/proposals/similar_proposals.rb +4 -4
- data/app/services/decidim/proposals/collaborative_draft_search.rb +8 -10
- data/app/services/decidim/proposals/diff_renderer.rb +17 -5
- data/app/services/decidim/proposals/proposal_builder.rb +9 -3
- data/app/services/decidim/proposals/proposal_search.rb +11 -69
- data/app/types/decidim/proposals/proposal_input_filter.rb +29 -0
- data/app/types/decidim/proposals/proposal_input_sort.rb +22 -0
- data/app/types/decidim/proposals/proposal_type.rb +34 -13
- data/app/types/decidim/proposals/proposals_type.rb +22 -15
- 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_answers/_form.html.erb +35 -0
- data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -2
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +8 -28
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +26 -27
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_valuator.html.erb +15 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_dropdown.html.erb +21 -1
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_publish_answers.html.erb +14 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_scope-change.html.erb +25 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_valuator.html.erb +15 -0
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +18 -9
- data/app/views/decidim/proposals/admin/proposals/publish_answers.js.erb +12 -0
- data/app/views/decidim/proposals/admin/proposals/show.html.erb +186 -0
- data/app/views/decidim/proposals/admin/proposals/update_category.js.erb +3 -2
- data/app/views/decidim/proposals/admin/proposals/update_scope.js.erb +27 -0
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +11 -9
- data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +10 -8
- 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 +52 -22
- data/app/views/decidim/proposals/proposals/_endorsements_card_row.html.erb +0 -16
- data/app/views/decidim/proposals/proposals/_filters.html.erb +18 -16
- data/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +1 -4
- 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 +14 -7
- 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 +6 -13
- data/app/views/decidim/proposals/proposals/new.html.erb +6 -2
- 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 +62 -50
- 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/am-ET.yml +1 -0
- data/config/locales/ar.yml +62 -66
- data/config/locales/bg-BG.yml +237 -0
- data/config/locales/bg.yml +237 -0
- data/config/locales/ca.yml +176 -66
- data/config/locales/cs.yml +188 -78
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +169 -62
- data/config/locales/el.yml +876 -0
- data/config/locales/en.yml +179 -69
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +173 -63
- data/config/locales/es-PY.yml +173 -63
- data/config/locales/es.yml +179 -69
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +28 -61
- data/config/locales/fi-plain.yml +174 -64
- data/config/locales/fi.yml +210 -100
- data/config/locales/fr-CA.yml +906 -0
- data/config/locales/fr.yml +184 -66
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +28 -61
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +135 -63
- data/config/locales/id-ID.yml +28 -60
- data/config/locales/is-IS.yml +14 -30
- data/config/locales/is.yml +274 -0
- data/config/locales/it.yml +166 -80
- data/config/locales/ja-JP.yml +865 -0
- data/config/locales/ja.yml +889 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +858 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +151 -63
- data/config/locales/no.yml +62 -67
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +525 -392
- data/config/locales/pt-BR.yml +30 -66
- data/config/locales/pt.yml +439 -330
- data/config/locales/ro-RO.yml +841 -0
- data/config/locales/ru.yml +14 -45
- 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/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +126 -0
- data/config/locales/sv.yml +285 -169
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +28 -61
- data/config/locales/uk.yml +14 -45
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +885 -0
- data/config/locales/zh-TW.yml +1 -0
- 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 +54 -0
- data/db/migrate/20200120230130_drop_proposal_endorsements.rb +8 -0
- data/db/migrate/20200203111239_add_proposal_valuation_assignments.rb +12 -0
- data/db/migrate/20200210135152_add_costs_to_proposals.rb +9 -0
- data/db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb +28 -0
- data/db/migrate/20200227175922_add_state_published_at_to_proposals.rb +7 -0
- data/db/migrate/20200306123652_publish_existing_proposals_state.rb +15 -0
- data/db/migrate/20200708091228_move_proposals_fields_to_i18n.rb +86 -0
- data/db/migrate/20200730131631_move_proposal_endorsed_event_notifications_to_resource_endorsed_event.rb +20 -0
- data/db/migrate/20200827154156_add_commentable_counter_cache_to_proposals.rb +12 -0
- data/db/migrate/20200915151348_fix_proposals_data_to_ensure_title_and_body_are_hashes.rb +37 -0
- data/db/migrate/20201002085508_fix_proposals_data.rb +37 -0
- data/lib/decidim/content_renderers/proposal_renderer.rb +3 -1
- data/lib/decidim/proposals.rb +1 -0
- data/lib/decidim/proposals/admin_engine.rb +7 -3
- data/lib/decidim/proposals/component.rb +55 -28
- data/lib/decidim/proposals/engine.rb +3 -7
- data/lib/decidim/proposals/markdown_to_proposals.rb +2 -2
- data/lib/decidim/proposals/proposal_serializer.rb +3 -3
- data/lib/decidim/proposals/test/capybara_proposals_picker.rb +49 -0
- data/lib/decidim/proposals/test/factories.rb +100 -28
- data/lib/decidim/proposals/valuatable.rb +21 -0
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +117 -55
- 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/admin/proposal_answers/edit.html.erb +0 -22
- data/app/views/decidim/proposals/admin/proposal_notes/index.html.erb +0 -3
- data/app/views/decidim/proposals/admin/shared/_info_proposal.html.erb +0 -20
- 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/proposal_widgets/show.html.erb +0 -4
- 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,56 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Makes the #select-identity-button to open a popup for the user to
|
3
|
-
* select with which identity he wants to perform an action.
|
4
|
-
*
|
5
|
-
*/
|
6
|
-
$(document).ready(function () {
|
7
|
-
|
8
|
-
let button = $("#select-identity-button"),
|
9
|
-
refreshUrl = null,
|
10
|
-
userIdentitiesDialog = $("#user-identities");
|
11
|
-
|
12
|
-
if (userIdentitiesDialog.length) {
|
13
|
-
refreshUrl = userIdentitiesDialog.data("refresh-url");
|
14
|
-
|
15
|
-
button.click(function () {
|
16
|
-
$.ajax(refreshUrl).done(function(response) {
|
17
|
-
userIdentitiesDialog.html(response).foundation("open");
|
18
|
-
button.trigger("ajax:success")
|
19
|
-
});
|
20
|
-
});
|
21
|
-
}
|
22
|
-
});
|
23
|
-
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Manage the identity selector for endorsements.
|
27
|
-
*
|
28
|
-
*/
|
29
|
-
$(document).ready(function () {
|
30
|
-
$("#select-identity-button").on("ajax:success", function() {
|
31
|
-
// once reveal popup has been rendered register event callbacks
|
32
|
-
$("#user-identities ul.reveal__list li").each(function(index, elem) {
|
33
|
-
let liTag = $(elem)
|
34
|
-
liTag.on("click", function() {
|
35
|
-
let method = liTag.data("method")
|
36
|
-
let url = liTag.data("url")
|
37
|
-
$.ajax({
|
38
|
-
url: url,
|
39
|
-
method: method,
|
40
|
-
dataType: "script",
|
41
|
-
success: function() {
|
42
|
-
if (liTag.hasClass("selected")) {
|
43
|
-
liTag.removeClass("selected")
|
44
|
-
liTag.find(".icon--circle-check").addClass("invisible")
|
45
|
-
liTag.data("method", "post")
|
46
|
-
} else {
|
47
|
-
liTag.addClass("selected")
|
48
|
-
liTag.find(".icon--circle-check").removeClass("invisible")
|
49
|
-
liTag.data("method", "delete")
|
50
|
-
}
|
51
|
-
}
|
52
|
-
})
|
53
|
-
})
|
54
|
-
});
|
55
|
-
});
|
56
|
-
})
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<div class="section">
|
2
|
-
<a name="list-of-endorsements"></a>
|
3
|
-
<div class="row">
|
4
|
-
<div class="columns large-12">
|
5
|
-
<h4 class="section-heading"><%= t("decidim.proposals.proposals.show.endorsements_list") %></h4>
|
6
|
-
</div>
|
7
|
-
<div class="columns large-12">
|
8
|
-
<%= cell(
|
9
|
-
"decidim/collapsible_list",
|
10
|
-
endorsers,
|
11
|
-
cell_name: "decidim/author",
|
12
|
-
cell_options: { extra_classes: ["author-data--small"] },
|
13
|
-
hidden_elements_count_i18n_key: "decidim.proposals.proposals.show.hidden_endorsers_count"
|
14
|
-
) %>
|
15
|
-
</div>
|
16
|
-
</div>
|
17
|
-
</div>
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "cell/partial"
|
4
|
-
|
5
|
-
module Decidim
|
6
|
-
module Proposals
|
7
|
-
# This cell renders the list of endorsers for the given Proposal.
|
8
|
-
#
|
9
|
-
# Example:
|
10
|
-
#
|
11
|
-
# cell("decidim/proposals/endorsers_list", my_proposal)
|
12
|
-
class EndorsersListCell < Decidim::ViewModel
|
13
|
-
include ProposalCellsHelper
|
14
|
-
|
15
|
-
def show
|
16
|
-
return unless endorsers.any?
|
17
|
-
|
18
|
-
render
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
# Finds the correct author for each endorsement.
|
24
|
-
#
|
25
|
-
# Returns an Array of presented Users/UserGroups
|
26
|
-
def endorsers
|
27
|
-
@endorsers ||= model.endorsements.for_listing.map { |identity| present(identity.normalized_author) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
# A module with all the attachment common methods for proposals
|
6
|
-
# and collaborative draft commands.
|
7
|
-
module AttachmentMethods
|
8
|
-
private
|
9
|
-
|
10
|
-
def build_attachment
|
11
|
-
@attachment = Attachment.new(
|
12
|
-
title: @form.attachment.title,
|
13
|
-
file: @form.attachment.file,
|
14
|
-
attached_to: @attached_to
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
def attachment_invalid?
|
19
|
-
if attachment.invalid? && attachment.errors.has_key?(:file)
|
20
|
-
@form.attachment.errors.add :file, attachment.errors[:file]
|
21
|
-
true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def attachment_present?
|
26
|
-
@form.attachment.file.present?
|
27
|
-
end
|
28
|
-
|
29
|
-
def create_attachment
|
30
|
-
attachment.attached_to = @attached_to
|
31
|
-
attachment.save!
|
32
|
-
end
|
33
|
-
|
34
|
-
def attachments_allowed?
|
35
|
-
@form.current_component.settings.attachments_allowed?
|
36
|
-
end
|
37
|
-
|
38
|
-
def process_attachments?
|
39
|
-
attachments_allowed? && attachment_present?
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
# A command with all the business logic when a user endorses a proposal.
|
6
|
-
class EndorseProposal < Rectify::Command
|
7
|
-
# Public: Initializes the command.
|
8
|
-
#
|
9
|
-
# proposal - A Decidim::Proposals::Proposal object.
|
10
|
-
# current_user - The current user.
|
11
|
-
# current_group_id- (optional) The current_grup that is endorsing the Proposal.
|
12
|
-
def initialize(proposal, current_user, current_group_id = nil)
|
13
|
-
@proposal = proposal
|
14
|
-
@current_user = current_user
|
15
|
-
@current_group_id = current_group_id
|
16
|
-
end
|
17
|
-
|
18
|
-
# Executes the command. Broadcasts these events:
|
19
|
-
#
|
20
|
-
# - :ok when everything is valid, together with the proposal vote.
|
21
|
-
# - :invalid if the form wasn't valid and we couldn't proceed.
|
22
|
-
#
|
23
|
-
# Returns nothing.
|
24
|
-
def call
|
25
|
-
endorsement = build_proposal_endorsement
|
26
|
-
if endorsement.save
|
27
|
-
notify_endorser_followers
|
28
|
-
broadcast(:ok, endorsement)
|
29
|
-
else
|
30
|
-
broadcast(:invalid)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def build_proposal_endorsement
|
37
|
-
endorsement = @proposal.endorsements.build(author: @current_user)
|
38
|
-
endorsement.user_group = user_groups.find(@current_group_id) if @current_group_id.present?
|
39
|
-
endorsement
|
40
|
-
end
|
41
|
-
|
42
|
-
def user_groups
|
43
|
-
Decidim::UserGroups::ManageableUserGroups.for(@current_user).verified
|
44
|
-
end
|
45
|
-
|
46
|
-
def notify_endorser_followers
|
47
|
-
Decidim::EventsManager.publish(
|
48
|
-
event: "decidim.events.proposals.proposal_endorsed",
|
49
|
-
event_class: Decidim::Proposals::ProposalEndorsedEvent,
|
50
|
-
resource: @proposal,
|
51
|
-
followers: @current_user.followers,
|
52
|
-
extra: {
|
53
|
-
endorser_id: @current_user.id
|
54
|
-
}
|
55
|
-
)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
# A command with all the business logic when a user or organization unendorses a proposal.
|
6
|
-
class UnendorseProposal < Rectify::Command
|
7
|
-
# Public: Initializes the command.
|
8
|
-
#
|
9
|
-
# proposal - A Decidim::Proposals::Proposal object.
|
10
|
-
# current_user - The current user.
|
11
|
-
# current_group- (optional) The current_group that is unendorsing from the Proposal.
|
12
|
-
def initialize(proposal, current_user, current_group = nil)
|
13
|
-
@proposal = proposal
|
14
|
-
@current_user = current_user
|
15
|
-
@current_group = current_group
|
16
|
-
end
|
17
|
-
|
18
|
-
# Executes the command. Broadcasts these events:
|
19
|
-
#
|
20
|
-
# - :ok when everything is valid, together with the proposal.
|
21
|
-
# - :invalid if the form wasn't valid and we couldn't proceed.
|
22
|
-
#
|
23
|
-
# Returns nothing.
|
24
|
-
def call
|
25
|
-
destroy_proposal_endorsement
|
26
|
-
broadcast(:ok, @proposal)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def destroy_proposal_endorsement
|
32
|
-
query = @proposal.endorsements.where(
|
33
|
-
author: @current_user,
|
34
|
-
decidim_user_group_id: @current_group&.id
|
35
|
-
)
|
36
|
-
query.destroy_all
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
# Exposes the proposal endorsement resource so that users can endorse proposals.
|
6
|
-
class ProposalEndorsementsController < Decidim::Proposals::ApplicationController
|
7
|
-
helper_method :proposal
|
8
|
-
|
9
|
-
before_action :authenticate_user!
|
10
|
-
|
11
|
-
def create
|
12
|
-
enforce_permission_to :endorse, :proposal, proposal: proposal
|
13
|
-
@from_proposals_list = params[:from_proposals_list] == "true"
|
14
|
-
user_group_id = params[:user_group_id]
|
15
|
-
|
16
|
-
EndorseProposal.call(proposal, current_user, user_group_id) do
|
17
|
-
on(:ok) do
|
18
|
-
proposal.reload
|
19
|
-
render :update_buttons_and_counters
|
20
|
-
end
|
21
|
-
|
22
|
-
on(:invalid) do
|
23
|
-
render json: { error: I18n.t("proposal_endorsements.create.error", scope: "decidim.proposals") }, status: :unprocessable_entity
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def destroy
|
29
|
-
enforce_permission_to :unendorse, :proposal, proposal: proposal
|
30
|
-
@from_proposals_list = params[:from_proposals_list] == "true"
|
31
|
-
user_group_id = params[:user_group_id]
|
32
|
-
user_group = user_groups.find(user_group_id) if user_group_id
|
33
|
-
|
34
|
-
UnendorseProposal.call(proposal, current_user, user_group) do
|
35
|
-
on(:ok) do
|
36
|
-
proposal.reload
|
37
|
-
render :update_buttons_and_counters
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def identities
|
43
|
-
enforce_permission_to :endorse, :proposal, proposal: proposal
|
44
|
-
|
45
|
-
@user_verified_groups = Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
|
46
|
-
render :identities, layout: false
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def user_groups
|
52
|
-
Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
|
53
|
-
end
|
54
|
-
|
55
|
-
def proposal
|
56
|
-
@proposal ||= Proposal.where(component: current_component).find(params[:proposal_id])
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
# A proposal can include an endorsement per user or group.
|
6
|
-
class ProposalEndorsement < ApplicationRecord
|
7
|
-
include Decidim::Authorable
|
8
|
-
|
9
|
-
belongs_to :proposal, foreign_key: "decidim_proposal_id", class_name: "Decidim::Proposals::Proposal", counter_cache: true
|
10
|
-
|
11
|
-
validates :proposal, uniqueness: { scope: [:author, :user_group] }
|
12
|
-
validate :author_and_proposal_same_organization
|
13
|
-
validate :proposal_not_rejected
|
14
|
-
|
15
|
-
scope :for_listing, -> { order(:decidim_user_group_id, :created_at) }
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def organization
|
20
|
-
proposal&.component&.organization
|
21
|
-
end
|
22
|
-
|
23
|
-
# Private: check if the proposal and the author have the same organization
|
24
|
-
def author_and_proposal_same_organization
|
25
|
-
return if !proposal || !author
|
26
|
-
|
27
|
-
errors.add(:proposal, :invalid) unless author.organization == proposal.organization
|
28
|
-
end
|
29
|
-
|
30
|
-
def proposal_not_rejected
|
31
|
-
return unless proposal
|
32
|
-
|
33
|
-
errors.add(:proposal, :invalid) if proposal.rejected?
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<%= render "decidim/proposals/admin/shared/info_proposal" %>
|
2
|
-
<%= decidim_form_for(@form, url: proposal_proposal_answer_path(proposal, @form), html: { class: "form edit_proposal_answer" }) do |f| %>
|
3
|
-
<div class="card">
|
4
|
-
<div class="card-divider">
|
5
|
-
<h2 class="card-title"><%= t ".title", title: present(proposal).title %></h2>
|
6
|
-
</div>
|
7
|
-
|
8
|
-
<div class="card-section">
|
9
|
-
<div class="row column">
|
10
|
-
<%= f.collection_radio_buttons :state, [["accepted", t(".accepted")], ["rejected", t(".rejected")], ["evaluating", t(".evaluating")]], :first, :last, prompt: true %>
|
11
|
-
</div>
|
12
|
-
|
13
|
-
<div class="row column">
|
14
|
-
<%= f.translated :editor, :answer, autofocus: true, rows: 15 %>
|
15
|
-
</div>
|
16
|
-
</div>
|
17
|
-
</div>
|
18
|
-
|
19
|
-
<div class="button--double form-general-submit">
|
20
|
-
<%= f.submit t(".answer_proposal") %>
|
21
|
-
</div>
|
22
|
-
<% end %>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<div class="card">
|
2
|
-
<div class="card-divider">
|
3
|
-
<h2 class="card-title">
|
4
|
-
<%= link_to "#{t ".proposals"} > ", proposals_path %>
|
5
|
-
<%= decidim_html_escape(present(proposal).title).html_safe %>
|
6
|
-
</h2>
|
7
|
-
</div>
|
8
|
-
|
9
|
-
<div class="card-section">
|
10
|
-
<div class="row column">
|
11
|
-
<strong><%= t ".body" %>:</strong> <%= simple_format(present(proposal).body(strip_tags: true)) %>
|
12
|
-
</div>
|
13
|
-
<div class="row column">
|
14
|
-
<strong><%= t ".created_at" %>:</strong> <%= l proposal.created_at, format: :decidim_short %>
|
15
|
-
</div>
|
16
|
-
<div class="row column">
|
17
|
-
<strong><%= t ".proposal_votes_count" %>:</strong> <%= proposal.proposal_votes_count %>
|
18
|
-
</div>
|
19
|
-
</div>
|
20
|
-
</div>
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<li class="<%= selected ? "selected" : "" %>" data-method="<%= http_method.to_s.upcase %>" data-url="<%= current_endorsement_url %>">
|
2
|
-
<div class="author-data author-data--small">
|
3
|
-
<div class="author-data__main">
|
4
|
-
<%== cell("decidim/author", identity, skip_profile_link: true).profile %>
|
5
|
-
</div>
|
6
|
-
</div>
|
7
|
-
|
8
|
-
<%= icon("circle-check", class: "icon--big #{selected ? '' : 'invisible'}") %>
|
9
|
-
</li>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<div class="reveal__header reveal__header--nomargin reveal__bg p-s">
|
2
|
-
<h6 class="heading6 m-none"><%= t ".select_identity" %></h6>
|
3
|
-
</div>
|
4
|
-
<ul class="reveal__list">
|
5
|
-
<%= render_endorsement_identity(proposal, current_user) %>
|
6
|
-
<% @user_verified_groups.each do |user_group| %>
|
7
|
-
<%= render_endorsement_identity(proposal, current_user, user_group) %>
|
8
|
-
<% end %>
|
9
|
-
</ul>
|
10
|
-
<div class="reveal__footer reveal__bg text-right p-s">
|
11
|
-
<button class="button button--nomargin button--sc" type="button" data-close><%= t(".done") %></button>
|
12
|
-
</div>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<% if Decidim::UserGroups::ManageableUserGroups.for(current_user).verified.empty? %>
|
2
|
-
update_main_page_button();
|
3
|
-
<% end %>
|
4
|
-
update_identities_rows();
|
5
|
-
|
6
|
-
function update_main_page_button() {
|
7
|
-
var $proposalEndorsementButton = $('#proposal-<%= proposal.id %>-endorsement-button');
|
8
|
-
morphdom($proposalEndorsementButton[0], '<%= j(endorsement_button(proposal, false)).strip.html_safe %>');
|
9
|
-
}
|
10
|
-
function update_identities_rows() {
|
11
|
-
<% fully_endorsed= fully_endorsed?(proposal, current_user) %>
|
12
|
-
var $proposalEndorsementsRowCount = $('#proposal-<%= proposal.id %>-endorsements-count');
|
13
|
-
morphdom($proposalEndorsementsRowCount[0], '<%= j(render_endorsements_count_card_part(proposal, fully_endorsed)).strip.html_safe %>');
|
14
|
-
var $proposalEndorsementsRowButton = $($('#select-identity-button')[0]);
|
15
|
-
<% if fully_endorsed %>
|
16
|
-
$proposalEndorsementsRowButton.addClass('success')
|
17
|
-
<% else %>
|
18
|
-
$proposalEndorsementsRowButton.removeClass('success')
|
19
|
-
<% end %>
|
20
|
-
}
|