decidim-participatory_documents 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +2 -2
  3. data/.github/workflows/test.yml +8 -5
  4. data/.ruby-version +1 -1
  5. data/.simplecov +15 -9
  6. data/Gemfile.lock +186 -184
  7. data/README.md +32 -28
  8. data/app/commands/decidim/participatory_documents/create_suggestion.rb +3 -1
  9. data/app/controllers/concerns/decidim/participatory_documents/needs_pdf_document.rb +8 -1
  10. data/app/controllers/decidim/participatory_documents/admin/documents_controller.rb +5 -3
  11. data/app/controllers/decidim/participatory_documents/admin/suggestions_controller.rb +21 -1
  12. data/app/controllers/decidim/participatory_documents/admin/valuation_assignments_controller.rb +5 -1
  13. data/app/controllers/decidim/participatory_documents/document_suggestions_controller.rb +14 -0
  14. data/app/controllers/decidim/participatory_documents/section_suggestions_controller.rb +4 -0
  15. data/app/forms/decidim/participatory_documents/admin/document_form.rb +2 -1
  16. data/app/jobs/decidim/participatory_documents/export_my_suggestions_job.rb +16 -0
  17. data/app/models/decidim/participatory_documents/suggestion.rb +12 -0
  18. data/app/packs/entrypoints/decidim_participatory_documents.scss +8 -0
  19. data/app/packs/entrypoints/decidim_participatory_documents_editor.js +1 -3
  20. data/app/packs/entrypoints/decidim_participatory_documents_viewer_off.js +6 -0
  21. data/app/packs/images/export_suggestions.svg +1 -0
  22. data/app/packs/src/decidim/participatory_documents/pdf/pdf_modal_manager.js +4 -1
  23. data/app/packs/src/decidim/participatory_documents/pdf/suggestion_form.js +1 -1
  24. data/app/packs/src/decidim/participatory_documents/pdf.js +46 -0
  25. data/app/packs/src/decidim/participatory_documents/pdf_off.js +39 -0
  26. data/app/packs/stylesheets/decidim/participatory_documents/pdf/admin_modals.scss +9 -5
  27. data/app/packs/stylesheets/decidim/participatory_documents/pdf/admin_tweaks.scss +0 -21
  28. data/app/packs/stylesheets/decidim/participatory_documents/{decidim_admin_classes.scss → pdf/decidim_admin_styles.scss} +0 -3
  29. data/app/packs/stylesheets/decidim/participatory_documents/pdf/modals.scss +49 -0
  30. data/app/packs/stylesheets/decidim/participatory_documents/pdf/tweaks.scss +76 -7
  31. data/app/permissions/decidim/participatory_documents/admin/permissions.rb +30 -15
  32. data/app/permissions/decidim/participatory_documents/permissions.rb +2 -0
  33. data/app/serializers/decidim/participatory_documents/my_suggestion_serializer.rb +22 -0
  34. data/app/serializers/decidim/participatory_documents/suggestion_serializer.rb +1 -1
  35. data/app/uploaders/decidim/participatory_documents/pdf_document_uploader.rb +4 -0
  36. data/app/views/decidim/participatory_documents/admin/documents/_editor_modal.html.erb +1 -1
  37. data/app/views/decidim/participatory_documents/admin/documents/pdf_viewer.html.erb +1 -1
  38. data/app/views/decidim/participatory_documents/admin/sections/_form.html.erb +0 -3
  39. data/app/views/decidim/participatory_documents/admin/suggestions/_suggestion.html.erb +1 -1
  40. data/app/views/decidim/participatory_documents/documents/_export_modal.html.erb +25 -0
  41. data/app/views/decidim/participatory_documents/documents/_pdfjs_base.html.erb +5 -2
  42. data/app/views/decidim/participatory_documents/documents/pdf_viewer.html.erb +40 -33
  43. data/config/assets.rb +1 -0
  44. data/config/locales/ca.yml +259 -0
  45. data/config/locales/de.yml +259 -0
  46. data/config/locales/en.yml +13 -0
  47. data/config/locales/es.yml +259 -0
  48. data/lib/decidim/participatory_documents/component.rb +6 -4
  49. data/lib/decidim/participatory_documents/engine.rb +5 -1
  50. data/lib/decidim/participatory_documents/version.rb +2 -2
  51. data/lib/decidim/participatory_documents.rb +5 -3
  52. metadata +12 -3
@@ -0,0 +1,259 @@
1
+ ---
2
+ es:
3
+ activemodel:
4
+ attributes:
5
+ document:
6
+ box_color: Color of the boxes
7
+ box_opacity: Opacity applied at the color of the boxes (%)
8
+ description: Helper description
9
+ file: PDF Document
10
+ title: Helper title
11
+ errors:
12
+ models:
13
+ answer_suggestion:
14
+ attributes:
15
+ state:
16
+ inclusion: It's not possible to publish with status "not answered"
17
+ document:
18
+ has_suggestions: This document cannot be changed or removed because it has suggestions
19
+ suggestion:
20
+ attributes:
21
+ not_blank: 'Validation failed: Please provide a message or upload a file'
22
+ too_long: is too long (over %{max_length} characters)
23
+ too_short: is too short (under %{min_length} characters)
24
+ decidim:
25
+ admin:
26
+ actions:
27
+ export: Export
28
+ exports:
29
+ export_as: "%{name} as %{export_format}"
30
+ filters:
31
+ search_placeholder:
32
+ body_cont: Body Contains
33
+ suggestions:
34
+ body_cont:
35
+ label: Body contains
36
+ dummy_author_ids_has:
37
+ label: Author
38
+ dummy_suggestable_id_has:
39
+ label: Section
40
+ state_eq:
41
+ label: State is
42
+ values:
43
+ accepted: Accepted
44
+ evaluating: Evaluating
45
+ not_answered: Not Answered
46
+ published: Published
47
+ rejected: Rejected
48
+ withdrawn: Withdrawn
49
+ valuator_role_ids_has:
50
+ label: Assigned to valuator
51
+ admin_log:
52
+ annotation:
53
+ create: "%{user_name} creó una nueva área participativa para %{document_name}"
54
+ delete: "%{user_name} deleted a participatory area for %{document_name}"
55
+ update: "%{user_name} has updated a participatory area for %{document_name}"
56
+ document:
57
+ create: "%{user_name} creó el documento llamado %{resource_name} en %{space_name}"
58
+ delete: "%{user_name} borro el documento llamado %{resource_name} en %{space_name}"
59
+ update: "%{user_name} actualizo el documento llamado %{resource_name} en %{space_name}"
60
+ section:
61
+ create: "%{user_name} has created a new Section named %{resource_name} for %{document_name}"
62
+ delete: "%{user_name} has deleted a section"
63
+ update: "%{user_name} has updated a section in %{document_name}"
64
+ suggestion_note:
65
+ create: "%{user_name} created a new suggestion note %{suggestion}"
66
+ components:
67
+ participatory_documents:
68
+ name: Documento participativo
69
+ settings:
70
+ global:
71
+ max_suggestion_length: Maximum suggestion length (characters)
72
+ min_suggestion_length: Minimum suggestion length (characters)
73
+ suggestion_answering_enabled: Enable suggestion answering from admin
74
+ events:
75
+ participatory_documents:
76
+ suggestion_answered:
77
+ affected_user:
78
+ email_intro: 'A suggestion you submitted on "<a href="%{resource_path}">%{resource_title}</a>" document has been answered by an administrator. You can read the answer in this page:'
79
+ email_outro: You have received this notification because you have submitted a suggestion for "<a href="%{resource_path}">%{resource_title}</a>" document.
80
+ email_subject: A suggestion you have submitted has been answered by an administrator
81
+ notification_title: A suggestion you submitted on "<a href="%{resource_path}">%{resource_title}</a>" document has been answered by an administrator
82
+ forms:
83
+ file_help:
84
+ file:
85
+ pdf_message: Only PDF files are allowed
86
+ participatory_documents:
87
+ actions:
88
+ back: Atrás
89
+ back_edit: Go back to edit participatory sections
90
+ confirm: This action means that you will not be able to edit the document or create new sections, are you sure?
91
+ edit_boxes: Editar áreas participativas
92
+ edit_document: Editar/subir documento
93
+ finish_publishing: Publish participatory sections
94
+ new: Subir un documento PDF
95
+ preview_publishing_sections: Preview and publish sections
96
+ title: Acciones
97
+ admin:
98
+ documents:
99
+ create:
100
+ invalid: Se ha producido un error al crear el documento
101
+ success: El documento ha sido creado con éxito
102
+ edit:
103
+ title: Edita el documento participativo
104
+ update: Actualiza
105
+ final_publish:
106
+ error: There was an error publishing sections
107
+ success: Sections have been successfully published
108
+ form:
109
+ alert_suggestions_html: "<strong>IMPORTANT:</strong> This document cannot be changed or removed because it already has suggestions attached"
110
+ box_style_preview: 'Box style preview:'
111
+ warning_sections_html: "<strong>Warning:</strong> If you upload a new document, all the participatory areas will be deleted!"
112
+ index:
113
+ start: Por favor cargue un documento PDF para empezar
114
+ new:
115
+ create: Create participatory document
116
+ title: New participatory document
117
+ sections:
118
+ empty: "(empty)"
119
+ update:
120
+ error: There was a problem updating Document
121
+ success: El documento ha sido actualizado con éxito
122
+ exports:
123
+ suggestions: Suggestions
124
+ suggestion_notes:
125
+ create:
126
+ error: There was a problem creating this suggestion note
127
+ success: Suggestion note successfully created
128
+ form:
129
+ note: Note
130
+ submit: Submit
131
+ leave_your_note: Leave your note
132
+ modal:
133
+ body: Body
134
+ title: Edit note
135
+ update: Update
136
+ title: Private notes
137
+ update:
138
+ edited: Edited
139
+ invalid: There was a problem updating this suggestion note
140
+ success: Suggestion note successfully updated
141
+ suggestions:
142
+ answer:
143
+ invalid: There was an error adding the answer
144
+ success: Successfully added the answer
145
+ form:
146
+ answer: Answer
147
+ answer_is_published: Published
148
+ title: Answer Suggestion
149
+ index:
150
+ actions:
151
+ answer: Answer
152
+ assign_to_valuator: Assign to valuator
153
+ assign_to_valuator_button: Assign
154
+ cancel: Cancel
155
+ download: download %{filename}
156
+ publish: Publish
157
+ publish_answers: Publish answers
158
+ title: Actions
159
+ unassign_from_valuator: Unassign from valuator
160
+ unassign_from_valuator_button: Unassign
161
+ author: Author
162
+ created_at: Submitted on
163
+ id: Id
164
+ no_text: "(no text)"
165
+ published_answer: Published Answer
166
+ section: Section
167
+ selected: selected
168
+ state: State
169
+ suggestion: Suggestion
170
+ title: List Suggestions
171
+ publish_answers:
172
+ number_of_suggestions: Answers for %{number} suggestions will be published.
173
+ select_a_suggestion: Please select a suggestion
174
+ success: Suggestion answers successfully published.
175
+ show:
176
+ authors: Authors
177
+ body: Body
178
+ created_at: Creation date
179
+ file: File
180
+ update: Update
181
+ suggestion:
182
+ global: Global
183
+ valuators:
184
+ assigned_valuators: Assigned valuators
185
+ remove_assignment: Remove assignment
186
+ remove_assignment_confirmation: Are you sure you want to remove the valuator from this suggestion?
187
+ valuators: Valuators
188
+ valuation_assignments:
189
+ create:
190
+ invalid: There was an error assigning suggestions to a valuator
191
+ success: Suggestions assigned to a valuator successfully
192
+ delete:
193
+ invalid: There was an error unassigning suggestions from a valuator
194
+ success: Valuator unassigned from suggestions successfully
195
+ document:
196
+ close: Close
197
+ export_my_suggestions: Export my suggestions
198
+ global_suggestions: Global suggestions
199
+ save_changes: Save changes!
200
+ send_suggestion: Send suggestion
201
+ suggestion_answer: Official answer
202
+ upload_file: Attach a document
203
+ document_suggestions:
204
+ export:
205
+ empty: There are no suggestions to export.
206
+ success: "%{count} suggestions have been successfully exported. Please check your email inbox at %{email}."
207
+ documents:
208
+ export_modal:
209
+ description_html: You have %{count} suggestions on this document. If you want to export them, you will receive a ZIP file with and Excel document in it with all your data and any possible answer the admins have given to you. <br><br>You will receive an email at <b>%{email}</b>.
210
+ send: Send me my suggestions
211
+ title: Export my suggestions
212
+ missing: There is no document uploaded yet
213
+ not_supported: This page requires JavaScript to be enabled!
214
+ preview_title: Preview
215
+ publish_description: 'Admin options: you are previewing the participatory sections of the document'
216
+ models:
217
+ document:
218
+ fields:
219
+ document_pages: Número de página
220
+ id: Id
221
+ published: Publicado
222
+ state: Estado
223
+ title: Título
224
+ section:
225
+ fields:
226
+ artificial_tile: Section %{position}
227
+ suggestion:
228
+ fields:
229
+ valuators: Valuators
230
+ 'no': 'No'
231
+ suggestions:
232
+ answers:
233
+ accepted: Accepted
234
+ evaluating: Evaluating
235
+ not_answered: Not Answered
236
+ published: Published
237
+ rejected: Rejected
238
+ withdrawn: Withdrawn
239
+ modal:
240
+ exit_full_screen: Exit fullscreen
241
+ full_screen: Fullscreen
242
+ ui_messages:
243
+ allSaved: All the areas have been saved successfully
244
+ confirmExit: Are you sure you want to exit?
245
+ created: The area has been created
246
+ errorsSaving: Some errors have occurred while saving the areas
247
+ group: Group
248
+ modalTitle: Section %{section}, area %{box}
249
+ move: Move
250
+ needsSaving: You have to save the areas before editing them
251
+ operationFailed: The operation has failed
252
+ removeBoxConfirm: Are you sure you want to delete this area? This cannot be undone.
253
+ removed: The area has been removed
254
+ startEditing: Start creating areas for participation by clicking and dragging. Once created, boxes can be resized, moved, or grouped.
255
+ startSuggesting: Click on a marked area to participate!
256
+ suggestion_form:
257
+ blank: There was an error creating the suggestion. Upload the valid file or add a text message with the suggestion.
258
+ title: Write your suggestion or upload a file with your suggestions
259
+ 'yes': 'Sí'
@@ -31,11 +31,13 @@ Decidim.register_component(:participatory_documents) do |component|
31
31
  # end
32
32
 
33
33
  component.exports :suggestions do |exports|
34
- exports.collection do |component_instance|
34
+ exports.collection do |component_instance, user, context|
35
35
  document = Decidim::ParticipatoryDocuments::Document.find_by(component: component_instance)
36
- Decidim::ParticipatoryDocuments::Suggestion
37
- .where(suggestable: document)
38
- .or(Decidim::ParticipatoryDocuments::Suggestion.where(suggestable: document.sections)).order(:id)
36
+ suggestions = Decidim::ParticipatoryDocuments::Suggestion
37
+ .where(suggestable: document)
38
+ .or(Decidim::ParticipatoryDocuments::Suggestion.where(suggestable: document.sections))
39
+ suggestions = suggestions.where(author: user) if context == :my_suggestions && user
40
+ suggestions.order(:id)
39
41
  end
40
42
 
41
43
  exports.include_in_open_data = false
@@ -14,7 +14,11 @@ module Decidim
14
14
  collection do
15
15
  get :pdf_viewer
16
16
  end
17
- resources :suggestions, only: [:index, :create], controller: :document_suggestions
17
+ resources :suggestions, only: [:index, :create], controller: :document_suggestions do
18
+ collection do
19
+ post :export
20
+ end
21
+ end
18
22
  end
19
23
 
20
24
  root to: "documents#index"
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Decidim
4
4
  module ParticipatoryDocuments
5
- VERSION = "0.2.0"
6
- DECIDIM_VERSION = "0.27.3"
5
+ VERSION = "0.2.1"
6
+ DECIDIM_VERSION = "0.27.4"
7
7
  COMPAT_DECIDIM_VERSION = [">= 0.27.0", "< 0.28"].freeze
8
8
  end
9
9
  end
@@ -8,17 +8,19 @@ module Decidim
8
8
  # Public: The maximum length of any text field (body, answers, etc) to export.
9
9
  # Defaults to 50. Set to 0 to export the full text.
10
10
  config_accessor :max_export_text_length do
11
- 50
11
+ ENV.fetch("MAX_EXPORT_TEXT_LENGTH", 0).to_i
12
12
  end
13
13
 
14
14
  # Public: The minimum length of a suggestion to be considered valid.
15
+ # This setting is configurable per-component by admins
15
16
  config_accessor :min_suggestion_length do
16
- 5
17
+ ENV.fetch("MIN_SUGGESTION_LENGTH", 5).to_i
17
18
  end
18
19
 
19
20
  # Public: The maximum length of a suggestion to be considered valid.
21
+ # This setting is configurable per-component by admins
20
22
  config_accessor :max_suggestion_length do
21
- 500
23
+ ENV.fetch("MAX_SUGGESTION_LENGTH", 1000).to_i
22
24
  end
23
25
  end
24
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-participatory_documents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Vergés
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-13 00:00:00.000000000 Z
11
+ date: 2023-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-core
@@ -126,6 +126,7 @@ files:
126
126
  - app/helpers/decidim/participatory_documents/admin/documents_helper.rb
127
127
  - app/helpers/decidim/participatory_documents/admin/suggestion_helper.rb
128
128
  - app/helpers/decidim/participatory_documents/documents_helper.rb
129
+ - app/jobs/decidim/participatory_documents/export_my_suggestions_job.rb
129
130
  - app/models/concerns/decidim/participatory_documents/participatory_space_user_role_override.rb
130
131
  - app/models/concerns/decidim/participatory_documents/valuator_override.rb
131
132
  - app/models/decidim/participatory_documents/annotation.rb
@@ -143,8 +144,10 @@ files:
143
144
  - app/packs/entrypoints/decidim_participatory_documents_editor.scss
144
145
  - app/packs/entrypoints/decidim_participatory_documents_viewer.js
145
146
  - app/packs/entrypoints/decidim_participatory_documents_viewer.scss
147
+ - app/packs/entrypoints/decidim_participatory_documents_viewer_off.js
146
148
  - app/packs/images/.keep
147
149
  - app/packs/images/badge.svg
150
+ - app/packs/images/export_suggestions.svg
148
151
  - app/packs/images/fullscreen.svg
149
152
  - app/packs/images/fullscreen_exit.svg
150
153
  - app/packs/images/group.svg
@@ -165,11 +168,12 @@ files:
165
168
  - app/packs/src/decidim/participatory_documents/pdf/suggestion_form.js
166
169
  - app/packs/src/decidim/participatory_documents/pdf_admin.js
167
170
  - app/packs/src/decidim/participatory_documents/pdf_notifications.js
171
+ - app/packs/src/decidim/participatory_documents/pdf_off.js
168
172
  - app/packs/src/decidim/participatory_documents/skip_cookie_warning.js
169
- - app/packs/stylesheets/decidim/participatory_documents/decidim_admin_classes.scss
170
173
  - app/packs/stylesheets/decidim/participatory_documents/pdf/admin_modals.scss
171
174
  - app/packs/stylesheets/decidim/participatory_documents/pdf/admin_polygons.scss
172
175
  - app/packs/stylesheets/decidim/participatory_documents/pdf/admin_tweaks.scss
176
+ - app/packs/stylesheets/decidim/participatory_documents/pdf/decidim_admin_styles.scss
173
177
  - app/packs/stylesheets/decidim/participatory_documents/pdf/defaults.scss
174
178
  - app/packs/stylesheets/decidim/participatory_documents/pdf/document.scss
175
179
  - app/packs/stylesheets/decidim/participatory_documents/pdf/modals.scss
@@ -182,6 +186,7 @@ files:
182
186
  - app/presenters/decidim/participatory_documents/admin_log/document_presenter.rb
183
187
  - app/presenters/decidim/participatory_documents/admin_log/section_presenter.rb
184
188
  - app/presenters/decidim/participatory_documents/admin_log/suggestion_note_presenter.rb
189
+ - app/serializers/decidim/participatory_documents/my_suggestion_serializer.rb
185
190
  - app/serializers/decidim/participatory_documents/suggestion_serializer.rb
186
191
  - app/uploaders/decidim/participatory_documents/pdf_document_uploader.rb
187
192
  - app/views/decidim/admin/exports/_dropdown.html.erb
@@ -212,6 +217,7 @@ files:
212
217
  - app/views/decidim/participatory_documents/admin/suggestions/show.html.erb
213
218
  - app/views/decidim/participatory_documents/document_suggestions/_form.html.erb
214
219
  - app/views/decidim/participatory_documents/document_suggestions/index.html.erb
220
+ - app/views/decidim/participatory_documents/documents/_export_modal.html.erb
215
221
  - app/views/decidim/participatory_documents/documents/_pdfjs_base.html.erb
216
222
  - app/views/decidim/participatory_documents/documents/index.html.erb
217
223
  - app/views/decidim/participatory_documents/documents/pdf_viewer.html.erb
@@ -224,7 +230,10 @@ files:
224
230
  - codecov.yml
225
231
  - config/assets.rb
226
232
  - config/i18n-tasks.yml
233
+ - config/locales/ca.yml
234
+ - config/locales/de.yml
227
235
  - config/locales/en.yml
236
+ - config/locales/es.yml
228
237
  - crowdin.yml
229
238
  - db/migrate/20221018112720_create_decidim_participatory_documents_document.rb
230
239
  - db/migrate/20221115233021_create_decidim_participatory_documents_participation_sections.rb