decidim-reporting_proposals 0.5.2 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +3 -3
- data/.github/workflows/test_integration.yml +17 -3
- data/.github/workflows/test_unit.yml +18 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -3
- data/.rubocop_ruby.yml +1 -2
- data/.ruby-version +1 -1
- data/Gemfile +6 -5
- data/Gemfile.lock +381 -402
- data/README.md +14 -9
- data/Rakefile +0 -2
- data/app/cells/concerns/decidim/reporting_proposals/linked_resources_for_cell_override.rb +23 -0
- data/app/cells/decidim/reporting_proposals/edit_note_modal/show.erb +22 -19
- data/app/commands/concerns/decidim/{proposals → reporting_proposals}/admin/answer_proposal_override.rb +2 -2
- data/app/commands/concerns/decidim/{proposals → reporting_proposals}/admin/assign_proposals_to_valuator_override.rb +1 -1
- data/app/commands/concerns/decidim/reporting_proposals/admin/update_category_override.rb +1 -1
- data/app/commands/concerns/decidim/reporting_proposals/admin/update_proposal_answer_template_override.rb +26 -0
- data/app/commands/concerns/decidim/{proposals → reporting_proposals}/publish_proposal_override.rb +2 -2
- data/app/commands/decidim/reporting_proposals/create_reporting_proposal.rb +1 -1
- data/app/commands/decidim/reporting_proposals/update_reporting_proposal.rb +38 -0
- data/app/controllers/concerns/decidim/reporting_proposals/admin/proposal_answer_templates_controller_override.rb +14 -0
- data/app/controllers/concerns/decidim/reporting_proposals/admin/proposal_answers_controller_override.rb +1 -1
- data/app/controllers/concerns/decidim/reporting_proposals/admin/proposals_controller_override.rb +2 -2
- data/app/controllers/concerns/decidim/{proposals → reporting_proposals}/admin/valuation_assignments_controller_override.rb +5 -5
- data/app/controllers/concerns/decidim/reporting_proposals/needs_proposal_extra_validations_snippets.rb +0 -1
- data/app/controllers/concerns/decidim/reporting_proposals/proposals_controller_override.rb +39 -0
- data/app/controllers/decidim/reporting_proposals/admin/proposals_controller.rb +4 -4
- data/app/controllers/decidim/reporting_proposals/geolocation_controller.rb +1 -1
- data/app/events/concerns/decidim/{proposals → reporting_proposals}/publish_proposal_event_override.rb +1 -1
- data/app/forms/concerns/decidim/reporting_proposals/form_builder_override.rb +9 -16
- data/app/forms/concerns/decidim/reporting_proposals/map_builder_override.rb +6 -5
- data/app/forms/decidim/reporting_proposals/admin/proposal_photo_form.rb +1 -5
- data/app/forms/decidim/reporting_proposals/proposal_form.rb +2 -0
- data/app/helpers/concerns/decidim/reporting_proposals/proposal_wizard_helper_override.rb +7 -30
- data/app/helpers/concerns/decidim/reporting_proposals/resource_helper_override.rb +1 -1
- data/app/mailers/concerns/decidim/reporting_proposals/admin/hidden_resource_mailer.rb +30 -0
- data/app/mailers/concerns/decidim/{proposals → reporting_proposals}/admin/notification_answer_proposal_mailer.rb +1 -1
- data/app/mailers/concerns/decidim/{proposals → reporting_proposals}/admin/proposals_valuator_mailer.rb +2 -2
- data/app/mailers/concerns/decidim/{proposals → reporting_proposals}/notification_publish_proposal_mailer.rb +1 -1
- data/app/mailers/concerns/decidim/reporting_proposals/reported_mailer_override.rb +18 -0
- data/app/overrides/decidim/proposals/admin/proposals/_proposal-tr/add_valuators_name.html.erb.deface +2 -2
- data/app/overrides/decidim/proposals/admin/proposals/show/add_address.html.erb.deface +1 -1
- data/app/overrides/decidim/proposals/admin/proposals/show/add_photo_management.html.erb.deface +1 -1
- data/app/overrides/decidim/proposals/admin/proposals/show/add_send_email_btn.html.erb.deface +1 -1
- data/app/overrides/decidim/proposals/admin/proposals/show/add_valuators_form.html.erb.deface +16 -10
- data/app/overrides/decidim/proposals/proposals/_wizard_header/add_description.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/proposals/_wizard_header/replace_title.html.erb.deface +5 -6
- data/app/overrides/decidim/proposals/proposals/compare/add_css.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/proposals/compare/add_distance_badge.html.erb.deface +10 -0
- data/app/overrides/decidim/proposals/proposals/edit/add_css.html.erb.deface +1 -1
- data/app/overrides/decidim/proposals/proposals/edit/replace_javascript.html.erb.deface +2 -2
- data/app/overrides/decidim/proposals/proposals/edit_draft/replace_javascript.html.erb.deface +3 -3
- data/app/overrides/decidim/proposals/proposals/edit_draft/replace_partial_edit_form_fields.html.erb.deface +6 -1
- data/app/overrides/decidim/proposals/proposals/new/add_css.html.erb.deface +2 -2
- data/app/overrides/decidim/proposals/proposals/new/remove_body.html.erb.deface +1 -0
- data/app/overrides/decidim/proposals/proposals/new/remove_title.html.erb.deface +1 -1
- data/app/overrides/decidim/proposals/proposals/new/replace_javascript.html.erb.deface +2 -2
- data/app/overrides/decidim/proposals/proposals/preview/add_css.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/proposals/show/add_additional_button.html.erb.deface +1 -1
- data/app/packs/entrypoints/decidim_reporting_proposals.js +1 -0
- data/app/packs/src/decidim/reporting_proposals/proposal_extra_validations.js +12 -13
- data/app/packs/src/decidim/reporting_proposals/proposals/add_proposal.js +45 -41
- data/app/packs/src/decidim/reporting_proposals/reverse_geocoding.js +0 -2
- data/app/packs/src/decidim/reporting_proposals/user_camera_inputs.js +7 -7
- data/app/packs/stylesheets/decidim/reporting_proposals/geocoding_addons.scss +9 -26
- data/app/packs/stylesheets/decidim/reporting_proposals/list_component_admin.scss +6 -6
- data/app/packs/stylesheets/decidim/reporting_proposals/manage_component_admin.scss +44 -30
- data/app/packs/stylesheets/decidim/reporting_proposals/proposals/add_proposal.scss +9 -4
- data/app/packs/stylesheets/decidim/reporting_proposals/user_camera_inputs.scss +21 -13
- data/app/presenters/concerns/decidim/reporting_proposals/resource_locator_presenter_override.rb +40 -0
- data/app/resources/concerns/decidim/reporting_proposals/resource_manifest_override.rb +16 -0
- data/app/serializers/decidim/reporting_proposals/proposal_serializer_override.rb +4 -4
- data/app/views/decidim/proposals/admin/proposal_notes/_editing_note.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes_body.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/_address.html.erb +11 -10
- data/app/views/decidim/proposals/admin/proposals/_send_email_button.html.erb +6 -4
- data/app/views/decidim/proposals/proposals/_additional_button.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/index.js.erb +0 -2
- data/app/views/decidim/reporting_proposals/admin/proposals/_photo_form.html.erb +2 -3
- data/app/views/decidim/reporting_proposals/admin/proposals/_photo_gallery.html.erb +3 -4
- data/app/views/decidim/reporting_proposals/admin/proposals/_photos.html.erb +15 -11
- data/app/views/decidim/reporting_proposals/admin/proposals/_proposal_td_hide.html.erb +7 -11
- data/app/views/decidim/reporting_proposals/admin/proposals/_proposal_td_title.html.erb +2 -2
- data/app/views/decidim/reporting_proposals/admin/proposals_valuator_mailer/notify_proposals_valuator.html.erb +17 -0
- data/app/views/decidim/reporting_proposals/proposals/_additional_button_for_show.html.erb +5 -2
- data/app/views/decidim/reporting_proposals/proposals/_camera_button.html.erb +26 -0
- data/app/views/decidim/reporting_proposals/proposals/_new_proposal_fields.html.erb +7 -5
- data/app/views/decidim/reporting_proposals/proposals/_reporting_proposal_fields.html.erb +61 -86
- data/app/views/decidim/reporting_proposals/proposals/_user_group.html.erb +1 -1
- data/bin/dev +5 -0
- data/bin/{webpack-dev-server → shakapacker} +1 -1
- data/bin/shakapacker-dev-server +6 -0
- data/config/assets.rb +1 -3
- data/config/locales/ca.yml +0 -2
- data/config/locales/en.yml +22 -48
- data/decidim-reporting_proposals.gemspec +1 -2
- data/lib/decidim/reporting_proposals/admin_engine.rb +4 -0
- data/lib/decidim/reporting_proposals/component.rb +26 -26
- data/lib/decidim/reporting_proposals/engine.rb +18 -12
- data/lib/decidim/reporting_proposals/test/factories.rb +2 -12
- data/lib/decidim/reporting_proposals/version.rb +3 -4
- data/lib/tasks/reporting_proposals_upgrade.rake +5 -0
- data/package-lock.json +4043 -5064
- data/package.json +12 -7
- metadata +73 -106
- data/app/commands/concerns/decidim/admin/hide_resource_override.rb +0 -34
- data/app/commands/concerns/decidim/templates/admin/copy_questionnaire_template_override.rb +0 -32
- data/app/commands/concerns/decidim/templates/admin/create_questionnaire_template_override.rb +0 -32
- data/app/commands/decidim/templates/admin/copy_proposal_answer_template.rb +0 -35
- data/app/commands/decidim/templates/admin/create_proposal_answer_template.rb +0 -48
- data/app/commands/decidim/templates/admin/update_proposal_answer_template.rb +0 -52
- data/app/controllers/concerns/decidim/templates/admin/application_controller_override.rb +0 -20
- data/app/controllers/decidim/templates/admin/proposal_answer_templates_controller.rb +0 -183
- data/app/forms/decidim/templates/admin/proposal_answer_template_form.rb +0 -21
- data/app/mailers/concerns/decidim/admin/hidden_resource_mailer.rb +0 -28
- data/app/mailers/concerns/decidim/reported_mailer_override.rb +0 -16
- data/app/overrides/decidim/proposals/admin/proposal_answers/_form/add_template_chooser.html.erb.deface +0 -5
- data/app/overrides/decidim/proposals/proposals/_edit_form_fields/replace_add_photos.html.erb.deface +0 -37
- data/app/overrides/decidim/proposals/proposals/_proposal_similar/add_distance_badge.html.erb.deface +0 -5
- data/app/overrides/decidim/proposals/proposals/edit_draft/add_css.html.erb.deface +0 -5
- data/app/overrides/decidim/proposals/proposals/edit_draft/add_user_group.html.erb.deface +0 -3
- data/app/packs/entrypoints/decidim_reporting_proposals_js_validations.js +0 -1
- data/app/packs/entrypoints/decidim_templates_admin.js +0 -1
- data/app/packs/src/decidim/templates/admin/proposal_answer_template_chooser.js +0 -27
- data/app/permissions/decidim/templates/admin/extra_permissions.rb +0 -37
- data/app/presenters/concerns/decidim/resource_locator_presenter_override.rb +0 -38
- data/app/resources/concerns/decidim/resource_manifest_override.rb +0 -14
- data/app/views/decidim/proposals/admin/proposals_valuator_mailer/notify_proposals_valuator.html.erb +0 -17
- data/app/views/decidim/templates/admin/proposal_answer_templates/_form.html.erb +0 -34
- data/app/views/decidim/templates/admin/proposal_answer_templates/_template_chooser.html.erb +0 -16
- data/app/views/decidim/templates/admin/proposal_answer_templates/edit.html.erb +0 -3
- data/app/views/decidim/templates/admin/proposal_answer_templates/index.html.erb +0 -52
- data/app/views/decidim/templates/admin/proposal_answer_templates/new.html.erb +0 -6
- data/db/migrate/20230404103706_add_target_and_field_values_to_decidim_templates_templates.rb +0 -8
- data/db/migrate/20230404104741_migrate_templatable.rb +0 -13
- /data/app/views/decidim/{admin → reporting_proposals/admin}/hidden_resource_mailer/notify_mail.html.erb +0 -0
- /data/app/views/decidim/{proposals → reporting_proposals}/admin/notification_answer_proposal_mailer/notify_proposal_author.html.erb +0 -0
- /data/app/views/decidim/{proposals → reporting_proposals}/notification_publish_proposal_mailer/notify_proposal_author.html.erb +0 -0
data/README.md
CHANGED
@@ -29,7 +29,7 @@ And then execute (do also this on upgrades):
|
|
29
29
|
|
30
30
|
```
|
31
31
|
bundle
|
32
|
-
|
32
|
+
bin/rails decidim:upgrade
|
33
33
|
bin/rails db:migrate
|
34
34
|
```
|
35
35
|
|
@@ -52,12 +52,21 @@ bin/rails db:migrate
|
|
52
52
|
>
|
53
53
|
> Alternatively, use any other ENV var to set up the `config.deface.enabled` to `false` during the precompilation phase.
|
54
54
|
|
55
|
+
> **EXPERTS ONLY**
|
56
|
+
>
|
57
|
+
> Under the hood, when running `bundle exec rails decidim:upgrade` the `decidim-reporting_proposals` gem will run the following (that can also be run manually if you consider):
|
58
|
+
>
|
59
|
+
> ```bash
|
60
|
+
> bin/rails decidim_reporting_proposals:install:migrations
|
61
|
+
> ```
|
62
|
+
|
55
63
|
Depending on your Decidim version, you can choose the corresponding version to ensure compatibility:
|
56
64
|
|
57
65
|
| Version | Compatible Decidim versions |
|
58
|
-
|
59
|
-
| 0.
|
60
|
-
| 0.
|
66
|
+
|---------|-----------------------------|
|
67
|
+
| 0.6.x | 0.28.x |
|
68
|
+
| 0.5.x | 0.27.x |
|
69
|
+
| 0.4.x | 0.26.x |
|
61
70
|
|
62
71
|
## Usage
|
63
72
|
|
@@ -88,10 +97,6 @@ This module provides the following features:
|
|
88
97
|
|
89
98
|
7. **Hide proposals without reporting**: Administrators can hide proposals directly, without using the reporting process. Also, authors who's content has been hidden receive a notification.
|
90
99
|
|
91
|
-
8. **Proposal answers templates**: Administrators can create templates for the answers to proposals. This is useful to provide a standard answer to proposals that are similar. This feature requires to enable the `decidim-templates` official module.
|
92
|
-
![Templates for proposals answers](features/templates1.png)
|
93
|
-
![Applying a template](features/templates2.png)
|
94
|
-
|
95
100
|
### Customization
|
96
101
|
|
97
102
|
Almost all the features of this module can be customized/disabled through an initializer.
|
@@ -119,7 +124,7 @@ Decidim::ReportingProposals.configure do |config|
|
|
119
124
|
config.show_my_location_button = [:proposals, :meetings, :reporting_proposals]
|
120
125
|
|
121
126
|
# Public Setting that adds a button next to the "add image" input[type=file] to open the camera directly
|
122
|
-
config.use_camera_button =
|
127
|
+
config.use_camera_button = true
|
123
128
|
|
124
129
|
# Public setting to prevent valuators or admins to modify the photos attached to a proposal
|
125
130
|
# otherwise can be configured at the component level
|
data/Rakefile
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
require "decidim/dev/common_rake"
|
4
4
|
|
5
5
|
def install_module(path)
|
6
|
-
# maintain until https://github.com/decidim/decidim/commit/51b81b37004708ab72e70993fef4634eef18ee6c is in the decidim version used
|
7
|
-
FileUtils.cp("babel.config.json", "#{path}/babel.config.json")
|
8
6
|
Dir.chdir(path) do
|
9
7
|
system("bundle exec rake decidim_reporting_proposals:install:migrations")
|
10
8
|
system("bundle exec rake db:migrate")
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ReportingProposals
|
5
|
+
# Exposes the proposal resource so users can view and create them.
|
6
|
+
module LinkedResourcesForCellOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
private
|
11
|
+
|
12
|
+
def linked_resources
|
13
|
+
@linked_resources ||= begin
|
14
|
+
query = resource.linked_resources(type, link_name)
|
15
|
+
query = query.or(resource.linked_resources(:reporting_proposals, link_name)) if type == :proposals
|
16
|
+
|
17
|
+
query.group_by { |linked_resource| linked_resource.class.name }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,20 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
<h3 id="<%= modal_id %>-label" class="
|
5
|
-
|
6
|
-
|
7
|
-
</button>
|
1
|
+
<%= decidim_modal id: modal_id do %>
|
2
|
+
<div data-dialog-container>
|
3
|
+
<%= icon "edit-line" %>
|
4
|
+
<h3 id="<%= modal_id %>-label" class="h3" tabindex="-1" data-dialog-title>
|
5
|
+
<%= t("modal.title", scope: "decidim.reporting_proposals.admin.proposal_notes") %>
|
6
|
+
</h3>
|
8
7
|
</div>
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
</div>
|
8
|
+
<div data-dialog-container>
|
9
|
+
<%= decidim_form_for(notes_form,
|
10
|
+
url: note_path,
|
11
|
+
method: :patch,
|
12
|
+
html: { class: "form form-defaults edit_proposal_note" }) do |f| %>
|
13
|
+
<div class="form__wrapper gap-2">
|
14
|
+
<%= f.text_area :body, rows: 10, label: t("modal.body", scope: "decidim.reporting_proposals.admin.proposal_notes"), value: note_body %>
|
15
|
+
</div>
|
16
|
+
<div data-dialog-actions>
|
17
|
+
<div class="button button__sm button__secondary">
|
18
|
+
<%= f.submit t("modal.update", scope: "decidim.reporting_proposals.admin.proposal_notes") %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
<% end %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
|
-
module
|
4
|
+
module ReportingProposals
|
5
5
|
module Admin
|
6
6
|
module AnswerProposalOverride
|
7
7
|
extend ActiveSupport::Concern
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
return unless Decidim::ReportingProposals.notify_authors_on_answering.include?(proposal.component.manifest_name.to_sym)
|
28
28
|
|
29
29
|
affected_users.each do |user|
|
30
|
-
Decidim::
|
30
|
+
Decidim::ReportingProposals::Admin::NotificationAnswerProposalMailer.notify_proposal_author(proposal, user).deliver_later
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -22,7 +22,7 @@ module Decidim
|
|
22
22
|
def update_valuators
|
23
23
|
category.category_valuators.destroy_all
|
24
24
|
category.participatory_space.user_roles.where(id: form.valuator_ids).each do |valuator|
|
25
|
-
Decidim::ReportingProposals::CategoryValuator.create!(category
|
25
|
+
Decidim::ReportingProposals::CategoryValuator.create!(category:, valuator_role: valuator)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ReportingProposals
|
5
|
+
module Admin
|
6
|
+
module UpdateProposalAnswerTemplateOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
private
|
11
|
+
|
12
|
+
def identify_templateable_resource
|
13
|
+
resource = @form.current_organization
|
14
|
+
if @form.component_constraint.present?
|
15
|
+
found_component = Decidim::Component.find_by(id: @form.component_constraint, manifest_name: %w(proposals reporting_proposals))
|
16
|
+
if found_component.present?
|
17
|
+
resource = found_component&.participatory_space&.decidim_organization_id == @form.current_organization.id ? found_component : nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
resource
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/app/commands/concerns/decidim/{proposals → reporting_proposals}/publish_proposal_override.rb
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
|
-
module
|
4
|
+
module ReportingProposals
|
5
5
|
module PublishProposalOverride
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
@@ -59,7 +59,7 @@ module Decidim
|
|
59
59
|
return unless Decidim::ReportingProposals.notify_authors_on_publish.include?(@proposal.component.manifest_name.to_sym)
|
60
60
|
|
61
61
|
affected_users.each do |user|
|
62
|
-
Decidim::
|
62
|
+
Decidim::ReportingProposals::NotificationPublishProposalMailer.notify_proposal_author(@proposal, user).deliver_later
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ReportingProposals
|
5
|
+
class UpdateReportingProposal < Decidim::Proposals::UpdateProposal
|
6
|
+
include ::Decidim::Proposals::GalleryMethods
|
7
|
+
|
8
|
+
def call
|
9
|
+
return broadcast(:invalid) if invalid?
|
10
|
+
|
11
|
+
if process_attachments?
|
12
|
+
build_attachments
|
13
|
+
return broadcast(:invalid) if attachments_invalid?
|
14
|
+
end
|
15
|
+
|
16
|
+
if process_gallery?
|
17
|
+
build_gallery
|
18
|
+
return broadcast(:invalid) if gallery_invalid?
|
19
|
+
end
|
20
|
+
|
21
|
+
with_events(with_transaction: true) do
|
22
|
+
if @proposal.draft?
|
23
|
+
update_draft
|
24
|
+
else
|
25
|
+
update_proposal
|
26
|
+
end
|
27
|
+
|
28
|
+
document_cleanup!(include_all_attachments: true)
|
29
|
+
|
30
|
+
create_attachments(first_weight: first_attachment_weight) if process_attachments?
|
31
|
+
create_gallery if process_gallery?
|
32
|
+
end
|
33
|
+
|
34
|
+
broadcast(:ok, proposal)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -8,6 +8,20 @@ module Decidim
|
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
10
|
included do
|
11
|
+
def avaliablity_options
|
12
|
+
@avaliablity_options = []
|
13
|
+
|
14
|
+
Decidim::Component.includes(:participatory_space).where(manifest_name: accepted_components)
|
15
|
+
.select { |a| a.participatory_space.decidim_organization_id == current_organization.id }.each do |component|
|
16
|
+
@avaliablity_options.push [formatted_name(component), component.id]
|
17
|
+
end
|
18
|
+
|
19
|
+
@avaliablity_options.sort_by!(&:first)
|
20
|
+
@avaliablity_options.prepend [t("global_scope", scope: "decidim.templates.admin.proposal_answer_templates.index"), 0]
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
11
25
|
def accepted_components
|
12
26
|
[:proposals, :reporting_proposals]
|
13
27
|
end
|
@@ -10,7 +10,7 @@ module Decidim
|
|
10
10
|
included do
|
11
11
|
helper Decidim::Proposals::Admin::ProposalBulkActionsHelper
|
12
12
|
def update
|
13
|
-
enforce_permission_to
|
13
|
+
enforce_permission_to(:create, :proposal_answer, proposal:)
|
14
14
|
|
15
15
|
@notes_form = form(Decidim::Proposals::Admin::ProposalNoteForm).instance
|
16
16
|
@answer_form = form(Decidim::Proposals::Admin::ProposalAnswerForm).from_params(params)
|
data/app/controllers/concerns/decidim/reporting_proposals/admin/proposals_controller_override.rb
CHANGED
@@ -10,7 +10,7 @@ module Decidim
|
|
10
10
|
included do
|
11
11
|
helper_method :reporting_proposal?, :proposals, :query, :form_presenter, :proposal, :proposal_ids
|
12
12
|
def show
|
13
|
-
enforce_permission_to
|
13
|
+
enforce_permission_to(:show, :proposal, proposal:)
|
14
14
|
|
15
15
|
@notes_form = form(Decidim::Proposals::Admin::ProposalNoteForm).instance
|
16
16
|
@answer_form = form(Decidim::Proposals::Admin::ProposalAnswerForm).from_model(proposal)
|
@@ -20,7 +20,7 @@ module Decidim
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def reporting_proposal?
|
23
|
-
component = current_component ||
|
23
|
+
component = current_component || proposal.current_component
|
24
24
|
component.manifest_name == "reporting_proposals"
|
25
25
|
end
|
26
26
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
|
-
module
|
4
|
+
module ReportingProposals
|
5
5
|
module Admin
|
6
6
|
module ValuationAssignmentsControllerOverride
|
7
7
|
extend ActiveSupport::Concern
|
@@ -9,8 +9,8 @@ module Decidim
|
|
9
9
|
included do
|
10
10
|
def create
|
11
11
|
enforce_permission_to :assign_to_valuator, :proposals
|
12
|
-
@form = form(Admin::ValuationAssignmentForm).from_params(params)
|
13
|
-
Admin::AssignProposalsToValuator.call(@form) do
|
12
|
+
@form = form(Decidim::Proposals::Admin::ValuationAssignmentForm).from_params(params)
|
13
|
+
Decidim::Proposals::Admin::AssignProposalsToValuator.call(@form) do
|
14
14
|
on(:ok) do |_proposal|
|
15
15
|
flash[:notice] = I18n.t("valuation_assignments.create.success", scope: "decidim.proposals.admin")
|
16
16
|
redirect_to after_add_evaluator_url
|
@@ -24,11 +24,11 @@ module Decidim
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def destroy
|
27
|
-
@form = form(Admin::ValuationAssignmentForm).from_params(destroy_params)
|
27
|
+
@form = form(Decidim::Proposals::Admin::ValuationAssignmentForm).from_params(destroy_params)
|
28
28
|
|
29
29
|
enforce_permission_to :unassign_from_valuator, :proposals, valuator: @form.valuator_user
|
30
30
|
|
31
|
-
Admin::UnassignProposalsFromValuator.call(@form) do
|
31
|
+
Decidim::Proposals::Admin::UnassignProposalsFromValuator.call(@form) do
|
32
32
|
on(:ok) do |_proposal|
|
33
33
|
flash.keep[:notice] = I18n.t("valuation_assignments.delete.success", scope: "decidim.proposals.admin")
|
34
34
|
if current_user == @form.valuator_user
|
@@ -14,7 +14,6 @@ module Decidim
|
|
14
14
|
@snippets ||= Decidim::Snippets.new
|
15
15
|
|
16
16
|
unless @snippets.any?(:reporting_proposals_js_validations)
|
17
|
-
@snippets.add(:reporting_proposals_js_validations, ActionController::Base.helpers.javascript_pack_tag("decidim_reporting_proposals_js_validations"))
|
18
17
|
@snippets.add(:reporting_proposals_js_validations, rules_tag)
|
19
18
|
@snippets.add(:foot, @snippets.for(:reporting_proposals_js_validations))
|
20
19
|
end
|
@@ -75,6 +75,41 @@ module Decidim
|
|
75
75
|
enforce_permission_to :edit, :proposal, proposal: @proposal
|
76
76
|
end
|
77
77
|
|
78
|
+
def update_draft
|
79
|
+
@step = Proposals::ProposalsController::STEP1
|
80
|
+
enforce_permission_to :edit, :proposal, proposal: @proposal
|
81
|
+
|
82
|
+
@form = form_proposal_params
|
83
|
+
update_proposal_command.call(@form, current_user, @proposal) do
|
84
|
+
on(:ok) do |proposal|
|
85
|
+
flash[:notice] = I18n.t("proposals.update_draft.success", scope: "decidim")
|
86
|
+
redirect_to "#{Decidim::ResourceLocatorPresenter.new(proposal).path}/preview"
|
87
|
+
end
|
88
|
+
|
89
|
+
on(:invalid) do
|
90
|
+
flash.now[:alert] = I18n.t("proposals.update_draft.error", scope: "decidim")
|
91
|
+
render :edit_draft
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def update
|
97
|
+
enforce_permission_to :edit, :proposal, proposal: @proposal
|
98
|
+
|
99
|
+
@form = form_proposal_params
|
100
|
+
update_proposal_command.call(@form, current_user, @proposal) do
|
101
|
+
on(:ok) do |proposal|
|
102
|
+
flash[:notice] = I18n.t("proposals.update.success", scope: "decidim")
|
103
|
+
redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path
|
104
|
+
end
|
105
|
+
|
106
|
+
on(:invalid) do
|
107
|
+
flash.now[:alert] = I18n.t("proposals.update.error", scope: "decidim")
|
108
|
+
render :edit
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
78
113
|
private
|
79
114
|
|
80
115
|
def form_proposal_params
|
@@ -97,6 +132,10 @@ module Decidim
|
|
97
132
|
reporting_proposal? ? CreateReportingProposal : Decidim::Proposals::CreateProposal
|
98
133
|
end
|
99
134
|
|
135
|
+
def update_proposal_command
|
136
|
+
reporting_proposal? ? Decidim::ReportingProposals::UpdateReportingProposal : Decidim::Proposals::UpdateProposal
|
137
|
+
end
|
138
|
+
|
100
139
|
def reporting_proposal?
|
101
140
|
component = current_component || @form.component
|
102
141
|
component.manifest_name == "reporting_proposals"
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
class ProposalsController < Admin::ApplicationController
|
7
7
|
def hide_proposal
|
8
|
-
enforce_permission_to
|
8
|
+
enforce_permission_to(:hide_proposal, :proposals, proposal:)
|
9
9
|
|
10
10
|
Decidim::Admin::HideResource.call(proposal, current_user) do
|
11
11
|
on(:ok) do
|
@@ -20,9 +20,9 @@ module Decidim
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def add_photos
|
23
|
-
enforce_permission_to
|
23
|
+
enforce_permission_to(:edit_photos, :proposals, proposal:)
|
24
24
|
|
25
|
-
@photo_form = form(Decidim::ReportingProposals::Admin::ProposalPhotoForm).from_params(params)
|
25
|
+
@photo_form = form(Decidim::ReportingProposals::Admin::ProposalPhotoForm).from_params(params, current_component: proposal.component)
|
26
26
|
|
27
27
|
Decidim::ReportingProposals::Admin::UpdateProposal.call(@photo_form, proposal) do
|
28
28
|
on(:ok) do |_proposal|
|
@@ -37,7 +37,7 @@ module Decidim
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def remove_photo
|
40
|
-
enforce_permission_to
|
40
|
+
enforce_permission_to(:edit_photos, :proposals, proposal:)
|
41
41
|
|
42
42
|
attachment = proposal.attachments.find_by(id: params[:photo_id])
|
43
43
|
if attachment.try(:photo?)
|
@@ -15,7 +15,7 @@ module Decidim
|
|
15
15
|
|
16
16
|
geocoder = Decidim::Map.utility(:geocoding, organization: current_organization)
|
17
17
|
address = geocoder.address([params[:latitude], params[:longitude]])
|
18
|
-
render json: { address
|
18
|
+
render json: { address:, found: address.present? }
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -11,36 +11,29 @@ module Decidim
|
|
11
11
|
|
12
12
|
included do
|
13
13
|
def file_field(object_name, options = {})
|
14
|
-
return super(object_name, options) unless use_camera_button
|
14
|
+
return super(object_name, options) unless Decidim::ReportingProposals.use_camera_button
|
15
15
|
|
16
16
|
unless @template.snippets.any?(:reporting_proposals_camera_scripts) || @template.snippets.any?(:reporting_proposals_camera_styles)
|
17
|
-
@template.snippets.add(:reporting_proposals_camera_scripts, @template.
|
18
|
-
@template.snippets.add(:reporting_proposals_camera_styles, @template.
|
17
|
+
@template.snippets.add(:reporting_proposals_camera_scripts, @template.prepend_javascript_pack_tag("decidim_reporting_proposals_camera"))
|
18
|
+
@template.snippets.add(:reporting_proposals_camera_styles, @template.append_stylesheet_pack_tag("decidim_reporting_proposals_camera"))
|
19
19
|
|
20
20
|
# This will display the snippets in the <head> part of the page.
|
21
21
|
@template.snippets.add(:head, @template.snippets.for(:reporting_proposals_camera_styles))
|
22
22
|
@template.snippets.add(:foot, @template.snippets.for(:reporting_proposals_camera_scripts))
|
23
23
|
end
|
24
24
|
|
25
|
-
content_tag(:div, class: "input-group") do
|
25
|
+
content_tag(:div, class: "camera-container input-group") do
|
26
26
|
super(object_name, options) +
|
27
27
|
content_tag(:div, class: "input-group-button") do
|
28
|
-
content_tag(:button,
|
29
|
-
|
28
|
+
content_tag(:button,
|
29
|
+
class: "button button__secondary user-device-camera",
|
30
|
+
type: "button",
|
31
|
+
data: { input: object_name }) do
|
32
|
+
icon("camera-line", role: "img", "aria-hidden": true) + " #{I18n.t("use_my_camera", scope: "decidim.reporting_proposals.forms")}"
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def use_camera_button?(object_name)
|
38
|
-
return unless @template.respond_to?(:current_component)
|
39
|
-
|
40
|
-
return unless Decidim::ReportingProposals.use_camera_button.include?(@template.current_component.manifest_name.to_sym)
|
41
|
-
|
42
|
-
object_name == :add_photos
|
43
|
-
end
|
44
37
|
end
|
45
38
|
end
|
46
39
|
end
|
@@ -15,9 +15,10 @@ module Decidim
|
|
15
15
|
def geocoding_field(object_name, method, options = {})
|
16
16
|
return original_geocoding_field(object_name, method, options) unless show_my_location_button?
|
17
17
|
|
18
|
+
append_assets
|
18
19
|
unless template.snippets.any?(:reporting_proposals_geocoding_scripts) || template.snippets.any?(:reporting_proposals_geocoding_styles)
|
19
|
-
template.snippets.add(:reporting_proposals_geocoding_scripts, template.
|
20
|
-
template.snippets.add(:reporting_proposals_geocoding_styles, template.
|
20
|
+
template.snippets.add(:reporting_proposals_geocoding_scripts, template.append_javascript_pack_tag("decidim_reporting_proposals_geocoding"))
|
21
|
+
template.snippets.add(:reporting_proposals_geocoding_styles, template.append_stylesheet_pack_tag("decidim_reporting_proposals_geocoding"))
|
21
22
|
|
22
23
|
# This will display the snippets in the <head> part of the page.
|
23
24
|
template.snippets.add(:head, template.snippets.for(:reporting_proposals_geocoding_styles))
|
@@ -28,14 +29,14 @@ module Decidim
|
|
28
29
|
options[:autocomplete] ||= "off"
|
29
30
|
options[:class] ||= "input-group-field"
|
30
31
|
|
31
|
-
template.content_tag(:div, class: "
|
32
|
+
template.content_tag(:div, class: "geocoding-container") do
|
32
33
|
template.text_field(
|
33
34
|
object_name,
|
34
35
|
method,
|
35
36
|
options.merge("data-decidim-geocoding" => view_options.to_json)
|
36
37
|
) +
|
37
38
|
template.content_tag(:div, class: "input-group-button user-device-location") do
|
38
|
-
template.content_tag(:button, class: "button
|
39
|
+
template.content_tag(:button, class: "button button__secondary", type: "button", data: {
|
39
40
|
input: "#{object_name}_#{method}",
|
40
41
|
latitude: "#{object_name}_latitude",
|
41
42
|
longitude: "#{object_name}_longitude",
|
@@ -43,7 +44,7 @@ module Decidim
|
|
43
44
|
error_unsupported: I18n.t("errors.device_not_supported", scope: "decidim.reporting_proposals.forms"),
|
44
45
|
url: Decidim::ReportingProposals::Engine.routes.url_helpers.locate_path
|
45
46
|
}) do
|
46
|
-
icon("
|
47
|
+
icon("map-pin-line", role: "img", "aria-hidden": true) + " #{I18n.t("use_my_location", scope: "decidim.reporting_proposals.forms")}"
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
@@ -10,12 +10,8 @@ module Decidim
|
|
10
10
|
|
11
11
|
validates :add_photos, presence: true
|
12
12
|
|
13
|
-
def proposal
|
14
|
-
@proposal ||= Decidim::Proposals::Proposal.find(id)
|
15
|
-
end
|
16
|
-
|
17
13
|
def current_component
|
18
|
-
@current_component ||=
|
14
|
+
@current_component ||= context&.current_component
|
19
15
|
end
|
20
16
|
end
|
21
17
|
end
|
@@ -7,34 +7,12 @@ module Decidim
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
def
|
11
|
-
steps =
|
12
|
-
|
13
|
-
|
14
|
-
)
|
15
|
-
steps = %(#{steps} #{proposal_wizard_stepper_step(Proposals::ProposalsController::STEP3, current_step)}) unless reporting_proposals_component?
|
16
|
-
steps = %(#{steps} #{proposal_wizard_stepper_step(Proposals::ProposalsController::STEP4, current_step)})
|
17
|
-
|
18
|
-
content_tag :ol, class: "wizard__steps" do
|
19
|
-
steps.html_safe
|
20
|
-
end
|
10
|
+
def proposal_wizard_steps
|
11
|
+
steps = [Proposals::ProposalsController::STEP1, Proposals::ProposalsController::STEP2]
|
12
|
+
steps << Proposals::ProposalsController::STEP3 unless reporting_proposals_component?
|
13
|
+
steps << Proposals::ProposalsController::STEP4
|
21
14
|
end
|
22
15
|
|
23
|
-
def proposal_wizard_current_step_of(step)
|
24
|
-
current_step_num = proposal_wizard_step_number(step)
|
25
|
-
current_step_num = 3 if current_step_num == 4 && reporting_proposals_component?
|
26
|
-
see_steps = content_tag(:span, class: "hide-for-large") do
|
27
|
-
concat " ("
|
28
|
-
concat content_tag :a, t(:"decidim.proposals.proposals.wizard_steps.see_steps"), "data-toggle": "steps"
|
29
|
-
concat ")"
|
30
|
-
end
|
31
|
-
content_tag :span, class: "text-small" do
|
32
|
-
concat t(:"decidim.proposals.proposals.wizard_steps.step_of", current_step_num: current_step_num, total_steps: total_steps)
|
33
|
-
concat see_steps
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# rubocop:disable Rails/HelperInstanceVariable:
|
38
16
|
def distance(meters = nil)
|
39
17
|
meters = @proposal.component.settings.geocoding_comparison_radius.to_f if meters.nil?
|
40
18
|
|
@@ -46,15 +24,14 @@ module Decidim
|
|
46
24
|
private
|
47
25
|
|
48
26
|
def total_steps
|
49
|
-
|
27
|
+
proposal_wizard_steps.count
|
50
28
|
end
|
51
29
|
|
52
30
|
def reporting_proposals_component?
|
53
|
-
return unless
|
31
|
+
return unless current_component&.manifest_name
|
54
32
|
|
55
|
-
|
33
|
+
current_component.manifest_name == "reporting_proposals"
|
56
34
|
end
|
57
|
-
# rubocop:enable Rails/HelperInstanceVariable:
|
58
35
|
end
|
59
36
|
end
|
60
37
|
end
|
@@ -15,7 +15,7 @@ module Decidim
|
|
15
15
|
content_tag(:div, class: "section") do
|
16
16
|
i18n_name = "#{resource.class.name.demodulize.underscore}_#{resource_manifest.name}"
|
17
17
|
content_tag(:h3, I18n.t(i18n_name, scope: "decidim.resource_links.#{link_name}"), class: "section-heading") +
|
18
|
-
render(partial: resource_manifest.template, locals: { resources:
|
18
|
+
render(partial: resource_manifest.template, locals: { resources: })
|
19
19
|
end
|
20
20
|
end)
|
21
21
|
end
|