decidim-reporting_proposals 0.5.2 → 0.6.0
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 +382 -400
- 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 +31 -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/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/permissions/decidim/templates/admin/permissions.rb +51 -0
- 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 +4072 -5101
- data/package.json +12 -7
- metadata +73 -105
- 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
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Templates
|
5
|
-
module Admin
|
6
|
-
class CreateProposalAnswerTemplate < Decidim::Command
|
7
|
-
# Initializes the command.
|
8
|
-
#
|
9
|
-
# form - The source for this ProposalAnswerTemplate.
|
10
|
-
def initialize(form)
|
11
|
-
@form = form
|
12
|
-
end
|
13
|
-
|
14
|
-
def call
|
15
|
-
return broadcast(:invalid) unless @form.valid?
|
16
|
-
|
17
|
-
@template = Decidim.traceability.create!(
|
18
|
-
Template,
|
19
|
-
@form.current_user,
|
20
|
-
name: @form.name,
|
21
|
-
description: @form.description,
|
22
|
-
organization: @form.current_organization,
|
23
|
-
field_values: { internal_state: @form.internal_state },
|
24
|
-
target: :proposal_answer
|
25
|
-
)
|
26
|
-
|
27
|
-
resource = identify_templateable_resource
|
28
|
-
@template.update!(templatable: resource)
|
29
|
-
|
30
|
-
broadcast(:ok, @template)
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def identify_templateable_resource
|
36
|
-
resource = @form.scope_for_availability.split("-")
|
37
|
-
case resource.first
|
38
|
-
when "organizations"
|
39
|
-
@form.current_organization
|
40
|
-
when "components"
|
41
|
-
component = Decidim::Component.find_by(id: resource.last)
|
42
|
-
component&.participatory_space&.decidim_organization_id == @form.current_organization.id ? component : nil
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Templates
|
5
|
-
module Admin
|
6
|
-
class UpdateProposalAnswerTemplate < Decidim::Command
|
7
|
-
# Initializes the command.
|
8
|
-
#
|
9
|
-
# template - The Template to update.
|
10
|
-
# form - The form object containing the data to update.
|
11
|
-
# user - The user that updates the template.
|
12
|
-
def initialize(template, form, user)
|
13
|
-
@template = template
|
14
|
-
@form = form
|
15
|
-
@user = user
|
16
|
-
end
|
17
|
-
|
18
|
-
def call
|
19
|
-
return broadcast(:invalid) unless @form.valid?
|
20
|
-
return broadcast(:invalid) unless @user.organization == @template.organization
|
21
|
-
|
22
|
-
@template = Decidim.traceability.update!(
|
23
|
-
@template,
|
24
|
-
@user,
|
25
|
-
name: @form.name,
|
26
|
-
description: @form.description,
|
27
|
-
field_values: { internal_state: @form.internal_state },
|
28
|
-
target: :proposal_answer
|
29
|
-
)
|
30
|
-
|
31
|
-
resource = identify_templateable_resource
|
32
|
-
@template.update!(templatable: resource)
|
33
|
-
|
34
|
-
broadcast(:ok, @template)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def identify_templateable_resource
|
40
|
-
resource = @form.scope_for_availability.split("-")
|
41
|
-
case resource.first
|
42
|
-
when "organizations"
|
43
|
-
@form.current_organization
|
44
|
-
when "components"
|
45
|
-
component = Decidim::Component.find_by(id: resource.last)
|
46
|
-
component&.participatory_space&.decidim_organization_id == @form.current_organization.id ? component : nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Templates
|
5
|
-
module Admin
|
6
|
-
module ApplicationControllerOverride
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
def template_types
|
11
|
-
@template_types ||= {
|
12
|
-
I18n.t("template_types.questionnaires", scope: "decidim.templates") => decidim_admin_templates.questionnaire_templates_path,
|
13
|
-
I18n.t("template_types.proposal_answer_templates", scope: "decidim.templates") => decidim_admin_templates.proposal_answer_templates_path
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,183 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Templates
|
5
|
-
module Admin
|
6
|
-
class ProposalAnswerTemplatesController < Decidim::Templates::Admin::ApplicationController
|
7
|
-
include Decidim::TranslatableAttributes
|
8
|
-
include Decidim::Paginable
|
9
|
-
|
10
|
-
def permission_class_chain
|
11
|
-
[::Decidim::Templates::Admin::ExtraPermissions] + super
|
12
|
-
end
|
13
|
-
|
14
|
-
helper_method :availability_option_as_text, :availability_options_for_select
|
15
|
-
|
16
|
-
rescue_from ActiveRecord::RecordNotFound do |exception|
|
17
|
-
if request.xhr?
|
18
|
-
render json: { msg: I18n.t("templates.fetch.error", scope: "decidim.admin"), error: exception.message }, status: :unprocessable_entity
|
19
|
-
else
|
20
|
-
throw exception
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def new
|
25
|
-
enforce_permission_to :create, :template
|
26
|
-
@form = form(ProposalAnswerTemplateForm).instance
|
27
|
-
end
|
28
|
-
|
29
|
-
def edit
|
30
|
-
enforce_permission_to :update, :template, template: template
|
31
|
-
@form = form(ProposalAnswerTemplateForm).from_model(template)
|
32
|
-
end
|
33
|
-
|
34
|
-
def create
|
35
|
-
enforce_permission_to :create, :template
|
36
|
-
|
37
|
-
@form = form(ProposalAnswerTemplateForm).from_params(params)
|
38
|
-
|
39
|
-
CreateProposalAnswerTemplate.call(@form) do
|
40
|
-
on(:ok) do |_template|
|
41
|
-
flash[:notice] = I18n.t("templates.create.success", scope: "decidim.admin")
|
42
|
-
redirect_to proposal_answer_templates_path
|
43
|
-
end
|
44
|
-
|
45
|
-
on(:invalid) do
|
46
|
-
flash.now[:alert] = I18n.t("templates.create.error", scope: "decidim.admin")
|
47
|
-
render :new
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def destroy
|
53
|
-
enforce_permission_to :destroy, :template, template: template
|
54
|
-
|
55
|
-
DestroyTemplate.call(template, current_user) do
|
56
|
-
on(:ok) do
|
57
|
-
flash[:notice] = I18n.t("templates.destroy.success", scope: "decidim.admin")
|
58
|
-
redirect_to action: :index
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def fetch
|
64
|
-
enforce_permission_to :read, :template, template: template, proposal: proposal
|
65
|
-
|
66
|
-
response_object = {
|
67
|
-
state: template.field_values["internal_state"],
|
68
|
-
template: populate_template_interpolations(proposal)
|
69
|
-
}
|
70
|
-
|
71
|
-
respond_to do |format|
|
72
|
-
format.json do
|
73
|
-
render json: response_object.to_json
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def update
|
79
|
-
enforce_permission_to :update, :template, template: template
|
80
|
-
@form = form(ProposalAnswerTemplateForm).from_params(params)
|
81
|
-
UpdateProposalAnswerTemplate.call(template, @form, current_user) do
|
82
|
-
on(:ok) do |_questionnaire_template|
|
83
|
-
flash[:notice] = I18n.t("templates.update.success", scope: "decidim.admin")
|
84
|
-
redirect_to proposal_answer_templates_path
|
85
|
-
end
|
86
|
-
|
87
|
-
on(:invalid) do |template|
|
88
|
-
@template = template
|
89
|
-
flash.now[:error] = I18n.t("templates.update.error", scope: "decidim.admin")
|
90
|
-
render action: :edit
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def copy
|
96
|
-
enforce_permission_to :copy, :template
|
97
|
-
|
98
|
-
CopyProposalAnswerTemplate.call(template) do
|
99
|
-
on(:ok) do
|
100
|
-
flash[:notice] = I18n.t("templates.copy.success", scope: "decidim.admin")
|
101
|
-
redirect_to action: :index
|
102
|
-
end
|
103
|
-
|
104
|
-
on(:invalid) do
|
105
|
-
flash[:alert] = I18n.t("templates.copy.error", scope: "decidim.admin")
|
106
|
-
redirect_to action: :index
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def index
|
112
|
-
enforce_permission_to :index, :templates
|
113
|
-
@templates = collection
|
114
|
-
|
115
|
-
respond_to do |format|
|
116
|
-
format.html { render :index }
|
117
|
-
format.json do
|
118
|
-
term = params[:term]
|
119
|
-
|
120
|
-
@templates = search(term)
|
121
|
-
|
122
|
-
render json: @templates.map { |t| { value: t.id, label: translated_attribute(t.name) } }
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
private
|
128
|
-
|
129
|
-
def populate_template_interpolations(proposal)
|
130
|
-
template.description do |language, value|
|
131
|
-
value.gsub!("%{organization}", proposal.organization.name)
|
132
|
-
value.gsub!("%{name}", proposal.creator_author.name)
|
133
|
-
value.gsub!("%{admin}", current_user.name)
|
134
|
-
|
135
|
-
[language, value]
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def proposal
|
140
|
-
@proposal ||= Decidim::Proposals::Proposal.find(params[:proposal_id])
|
141
|
-
end
|
142
|
-
|
143
|
-
def availability_option_as_text(template)
|
144
|
-
return unless template.templatable_type
|
145
|
-
|
146
|
-
key = "#{template.templatable_type.demodulize.tableize}-#{template.templatable_id}"
|
147
|
-
avaliablity_options[key].presence || t("templates.missing_resource", scope: "decidim.admin")
|
148
|
-
end
|
149
|
-
|
150
|
-
def availability_options_for_select
|
151
|
-
avaliablity_options.collect { |key, value| [value, key] }.to_a
|
152
|
-
end
|
153
|
-
|
154
|
-
def avaliablity_options
|
155
|
-
@avaliablity_options = {}
|
156
|
-
Decidim::Component.includes(:participatory_space).where(manifest_name: accepted_components)
|
157
|
-
.select { |a| a.participatory_space&.decidim_organization_id == current_organization.id }.each do |component|
|
158
|
-
@avaliablity_options["components-#{component.id}"] = formated_name(component)
|
159
|
-
end
|
160
|
-
global_scope = { "organizations-#{current_organization.id}" => t("global_scope", scope: "decidim.templates.admin.proposal_answer_templates.index") }
|
161
|
-
@avaliablity_options = global_scope.merge(@avaliablity_options.sort_by { |_, val| val }.to_h)
|
162
|
-
end
|
163
|
-
|
164
|
-
def formated_name(component)
|
165
|
-
space_type = t(component.participatory_space.class.name.underscore, scope: "activerecord.models", count: 1)
|
166
|
-
"#{space_type}: #{translated_attribute(component.participatory_space.title)} > #{translated_attribute(component.name)}"
|
167
|
-
end
|
168
|
-
|
169
|
-
def accepted_components
|
170
|
-
[:proposals]
|
171
|
-
end
|
172
|
-
|
173
|
-
def template
|
174
|
-
@template ||= Template.find(params[:id])
|
175
|
-
end
|
176
|
-
|
177
|
-
def collection
|
178
|
-
@collection ||= paginate(current_organization.templates.where(target: :proposal_answer).order(:id))
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Templates
|
5
|
-
module Admin
|
6
|
-
class ProposalAnswerTemplateForm < TemplateForm
|
7
|
-
attribute :internal_state, String
|
8
|
-
attribute :scope_for_availability, String
|
9
|
-
|
10
|
-
validates :internal_state, presence: true
|
11
|
-
|
12
|
-
def map_model(model)
|
13
|
-
self.scope_for_availability = "#{model.templatable_type.try(:demodulize).try(:tableize)}-#{model.templatable_id.to_i}"
|
14
|
-
(model.field_values || []).to_h.map do |k, v|
|
15
|
-
self[k.to_sym] = v
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Admin
|
5
|
-
# A custom mailer to mail Decidim users
|
6
|
-
# that they have been hidden
|
7
|
-
class HiddenResourceMailer < Decidim::ApplicationMailer
|
8
|
-
include Decidim::TranslationsHelper
|
9
|
-
include Decidim::SanitizeHelper
|
10
|
-
include Decidim::ApplicationHelper
|
11
|
-
include Decidim::TranslatableAttributes
|
12
|
-
|
13
|
-
helper Decidim::ResourceHelper
|
14
|
-
helper Decidim::TranslationsHelper
|
15
|
-
helper Decidim::ApplicationHelper
|
16
|
-
|
17
|
-
def notify_mail(resource, resource_authors, reason)
|
18
|
-
@resource_authors = resource_authors
|
19
|
-
@organization = resource.organization
|
20
|
-
@resource = resource
|
21
|
-
@reason = reason
|
22
|
-
|
23
|
-
mail(to: resource_authors.pluck(:email).uniq,
|
24
|
-
subject: I18n.t("decidim.admin.hidden_resource_mailer.notify_mail.subject"))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ReportedMailerOverride
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
included do
|
8
|
-
helper Decidim::ComponentPathHelper
|
9
|
-
helper_method :resource_admin_url
|
10
|
-
|
11
|
-
def resource_admin_url
|
12
|
-
@resource_admin_url ||= Decidim::ResourceLocatorPresenter.new(@reportable).admin_url
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/app/overrides/decidim/proposals/proposals/_edit_form_fields/replace_add_photos.html.erb.deface
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
<!-- replace '.gallery__container.photos_container' -->
|
2
|
-
|
3
|
-
<% if Decidim::ReportingProposals.use_camera_button.include?(current_component.manifest_name.to_sym) %>
|
4
|
-
<fieldset class="gallery__container photos_container">
|
5
|
-
<% if @form.photos.any? %>
|
6
|
-
<% @form.photos.each do |photo| %>
|
7
|
-
<div class="callout gallery__item" id="attachment_<%= photo.id %>" data-closable>
|
8
|
-
<%= image_tag photo.thumbnail_url, class: "thumbnail", alt: photo.file.filename %>
|
9
|
-
<%= form.hidden_field :photos, multiple: true, value: photo.id, id: "photo-#{photo.id}" %>
|
10
|
-
<button class="close-button"
|
11
|
-
aria-label="<%= t("delete_image", scope: "decidim.reporting_proposals.proposals.edit") %>"
|
12
|
-
title="<%= t("delete_image", scope: "decidim.reporting_proposals.proposals.edit") %>"
|
13
|
-
type="button"
|
14
|
-
data-close>
|
15
|
-
<span aria-hidden="true">×</span>
|
16
|
-
</button>
|
17
|
-
</div>
|
18
|
-
<% end %>
|
19
|
-
<% end %>
|
20
|
-
<div class="field row column">
|
21
|
-
<%= form.file_field :add_photos, multiple: false, label: t("image", scope: "decidim.reporting_proposals.proposals.form") %>
|
22
|
-
</div>
|
23
|
-
</fieldset>
|
24
|
-
<% else %>
|
25
|
-
<fieldset class="gallery__container photos_container">
|
26
|
-
<legend><%= t("gallery_legend", scope: "decidim.proposals.proposals.edit") %></legend>
|
27
|
-
<div class="row column">
|
28
|
-
<%= form.attachment :photos,
|
29
|
-
multiple: false,
|
30
|
-
label: t("decidim.proposals.proposals.edit.add_image"),
|
31
|
-
button_label: t("decidim.proposals.proposals.edit.add_image"),
|
32
|
-
button_edit_label: t("decidim.proposals.proposals.edit.edit_image"),
|
33
|
-
help_i18n_scope: "decidim.forms.file_help.image",
|
34
|
-
extension_allowlist: Decidim::OrganizationSettings.for(current_organization).upload_allowed_file_extensions_image %>
|
35
|
-
</div>
|
36
|
-
</fieldset>
|
37
|
-
<% end %>
|
data/app/overrides/decidim/proposals/proposals/_proposal_similar/add_distance_badge.html.erb.deface
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
<!-- insert_before ".card__header" -->
|
2
|
-
|
3
|
-
<% if geocoding_comparison? %>
|
4
|
-
<span class="label secondary float-right"><%= icon("location") %> <%= t("away", scope: "decidim.reporting_proposals.proposals.compare.geocoding", meters: distance(1000 * @proposal.distance_from([proposal.latitude, proposal.longitude], :km))) %></span>
|
5
|
-
<% end %>
|
@@ -1 +0,0 @@
|
|
1
|
-
import "src/decidim/reporting_proposals/proposal_extra_validations.js"
|
@@ -1 +0,0 @@
|
|
1
|
-
import "src/decidim/templates/admin/proposal_answer_template_chooser";
|
@@ -1,27 +0,0 @@
|
|
1
|
-
$(() => {
|
2
|
-
$("#proposal_answer_template_chooser").change(() => {
|
3
|
-
const $dropDown = $("#proposal_answer_template_chooser");
|
4
|
-
$dropDown.next("#template-error").remove();
|
5
|
-
if ($dropDown.val() === "") {
|
6
|
-
return;
|
7
|
-
}
|
8
|
-
$.getJSON($dropDown.data("url"), {
|
9
|
-
id: $dropDown.val(),
|
10
|
-
/* eslint camelcase: [0] */
|
11
|
-
proposal_id: $dropDown.data("proposal")
|
12
|
-
}).done((data) => {
|
13
|
-
$(`#proposal_answer_internal_state_${data.state}`).trigger("click");
|
14
|
-
|
15
|
-
const $editors = $dropDown.parent().parent().find(".editor-container");
|
16
|
-
$editors.each((index, element) => {
|
17
|
-
const localElement = $(element);
|
18
|
-
const $locale = localElement.siblings("input[type=hidden]").attr("id").replace("proposal_answer_answer_", "");
|
19
|
-
const editor = Quill.find(element);
|
20
|
-
const delta = editor.clipboard.convert(data.template[$locale]);
|
21
|
-
editor.setContents(delta);
|
22
|
-
});
|
23
|
-
}).fail((err) => {
|
24
|
-
$dropDown.after(`<p id="template-error" class="text-alert">${err.responseJSON.msg || err.responseJSON.error || err.responseJSON}</p>`);
|
25
|
-
});
|
26
|
-
});
|
27
|
-
});
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Templates
|
5
|
-
module Admin
|
6
|
-
class ExtraPermissions < Decidim::DefaultPermissions
|
7
|
-
# this should go to the standard templates/permissions class but to avoid hacking it we put it here
|
8
|
-
# to be removed when proposal templates is accepted into core
|
9
|
-
def permissions
|
10
|
-
return permission_action if permission_action.scope != :admin
|
11
|
-
return permission_action unless user
|
12
|
-
return permission_action if context[:current_organization] != user.organization
|
13
|
-
|
14
|
-
allow! if user_has_a_role? && (permission_action.subject == :template && permission_action.action == :read)
|
15
|
-
|
16
|
-
super
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def participatory_space
|
22
|
-
@participatory_space ||= context[:proposal].try(:participatory_space)
|
23
|
-
end
|
24
|
-
|
25
|
-
def user_roles
|
26
|
-
@user_roles ||= participatory_space.try(:user_roles)
|
27
|
-
end
|
28
|
-
|
29
|
-
def user_has_a_role?
|
30
|
-
return unless user_roles
|
31
|
-
|
32
|
-
user_roles.exists?(user: user)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ResourceLocatorPresenterOverride
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
included do
|
8
|
-
# Generates and admin url only if the manifest has the property :admin_route_name defined
|
9
|
-
# this allows to distinct from resources that can be administrated from those that are not
|
10
|
-
def admin_url(options = {})
|
11
|
-
admin_member_route("url", options.merge(host: root_resource.organization.host))
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def admin_member_route(route_type, options)
|
17
|
-
return if manifest_for(target).admin_route_name.blank?
|
18
|
-
|
19
|
-
options.merge!(options_for_polymorphic)
|
20
|
-
admin_route_proxy.send("#{admin_member_route_name}_#{route_type}", target, options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def admin_member_route_name
|
24
|
-
if polymorphic?
|
25
|
-
admin_polymorphic_member_route_name
|
26
|
-
else
|
27
|
-
manifest_for(target).admin_route_name
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def admin_polymorphic_member_route_name
|
32
|
-
return unless polymorphic?
|
33
|
-
|
34
|
-
resource.map { |record| manifest_for(record).admin_route_name }.join("_")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ResourceManifestOverride
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
included do
|
8
|
-
# The name of the named Rails route to create the url to admin the resource
|
9
|
-
# If it is not defined, the resource will be considered non-administrable
|
10
|
-
# and no link will be generated in some places
|
11
|
-
attribute :admin_route_name, String
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/app/views/decidim/proposals/admin/proposals_valuator_mailer/notify_proposals_valuator.html.erb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
<p class="email-greeting"><%= t(".greeting", name: @valuator_user.name) %></p>
|
2
|
-
|
3
|
-
<p class="email-instructions"><%= t(".email_body") %></p>
|
4
|
-
|
5
|
-
<p class="email-instructions">
|
6
|
-
<ul>
|
7
|
-
<% @proposals.each do |proposal| %>
|
8
|
-
<li class="mb-sm">
|
9
|
-
<span><%= translated_attribute(proposal.title) %></span>:
|
10
|
-
<%= sanitize link_to(t(".public_side"), Decidim::ResourceLocatorPresenter.new(proposal).url), tags: ["a"], attributes: ["href"] %>,
|
11
|
-
<%= sanitize link_to(t(".admin_panel"), Decidim::ResourceLocatorPresenter.new(proposal).admin_url), tags: ["a"], attributes: ["href"] %>
|
12
|
-
</li>
|
13
|
-
<% end %>
|
14
|
-
</ul>
|
15
|
-
</p>
|
16
|
-
|
17
|
-
<p class="email-closing"><%= t(".gratitude") %></p>
|
@@ -1,34 +0,0 @@
|
|
1
|
-
<div class="card">
|
2
|
-
<div class="card-divider">
|
3
|
-
<h2 class="card-title"><%= t(".template_title") %></h2>
|
4
|
-
<%= form.submit t(".save"), class: "button tiny button--title" %>
|
5
|
-
</div>
|
6
|
-
|
7
|
-
<div class="card-section">
|
8
|
-
<div class="row column">
|
9
|
-
<%= form.translated :text_field, :name %>
|
10
|
-
</div>
|
11
|
-
|
12
|
-
<div class="row column">
|
13
|
-
<%= form.translated :editor, :description, rows: 15, label: t(".answer_template") %>
|
14
|
-
<%= t(".hint").html_safe %>
|
15
|
-
<ul>
|
16
|
-
<li><%= t(".hint1").html_safe %></li>
|
17
|
-
<li><%= t(".hint2").html_safe %></li>
|
18
|
-
<li><%= t(".hint3").html_safe %></li>
|
19
|
-
</ul>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
<div class="row column">
|
23
|
-
<%= form.label :internal_state %>
|
24
|
-
<%= form.collection_radio_buttons :internal_state,
|
25
|
-
Decidim::Proposals::Proposal::POSSIBLE_STATES - %w(withdrawn),
|
26
|
-
:to_s,
|
27
|
-
->(mode) { t(mode, scope: "decidim.proposals.admin.proposal_answers.form") } %>
|
28
|
-
</div>
|
29
|
-
|
30
|
-
<div class="row column">
|
31
|
-
<%= form.select :scope_for_availability, availability_options_for_select, help_text: t(".scope_for_availability_help") %>
|
32
|
-
</div>
|
33
|
-
</div>
|
34
|
-
</div>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<% templates = Decidim::Templates::Template .where(
|
2
|
-
target: :proposal_answer,
|
3
|
-
templatable: [current_organization, current_component]
|
4
|
-
).order(:templatable_id) %>
|
5
|
-
<% if templates.any? %>
|
6
|
-
<div class="row column">
|
7
|
-
<%= javascript_pack_tag "decidim_templates_admin" %>
|
8
|
-
|
9
|
-
<select id="proposal_answer_template_chooser" data-locale="en" data-proposal="<%= proposal.id %>" data-url="<%= decidim_admin_templates.fetch_proposal_answer_templates_url %>">
|
10
|
-
<option value=""><%= t(".select_template") %></option>
|
11
|
-
<% templates.each do |template| %>
|
12
|
-
<option value="<%= template.id %>"><%= translated_attribute(template.name) %></option>
|
13
|
-
<% end %>
|
14
|
-
</select>
|
15
|
-
</div>
|
16
|
-
<% end %>
|