decidim-participatory_documents 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (559) hide show
  1. checksums.yaml +7 -0
  2. data/.erb-lint.yml +30 -0
  3. data/.eslintignore +3 -0
  4. data/.eslintrc.json +3 -0
  5. data/.github/workflows/lint.yml +43 -0
  6. data/.github/workflows/test.yml +60 -0
  7. data/.gitignore +27 -0
  8. data/.rspec +3 -0
  9. data/.rubocop-disabled.yml +11 -0
  10. data/.rubocop.yml +4 -0
  11. data/.rubocop_rails.yml +91 -0
  12. data/.rubocop_ruby.yml +1768 -0
  13. data/.ruby-version +1 -0
  14. data/.simplecov +13 -0
  15. data/CODE_OF_CONDUCT.md +74 -0
  16. data/Gemfile +39 -0
  17. data/Gemfile.lock +817 -0
  18. data/LICENSE-AGPLv3.txt +661 -0
  19. data/README.md +166 -0
  20. data/Rakefile +44 -0
  21. data/app/cells/decidim/participatory_documents/edit_suggestion_note_modal/show.erb +20 -0
  22. data/app/cells/decidim/participatory_documents/edit_suggestion_note_modal_cell.rb +35 -0
  23. data/app/cells/decidim/participatory_documents/suggestion/admin_answer.erb +7 -0
  24. data/app/cells/decidim/participatory_documents/suggestion/show.erb +11 -0
  25. data/app/cells/decidim/participatory_documents/suggestion_author/avatar.erb +3 -0
  26. data/app/cells/decidim/participatory_documents/suggestion_author/date.erb +1 -0
  27. data/app/cells/decidim/participatory_documents/suggestion_author/name.erb +3 -0
  28. data/app/cells/decidim/participatory_documents/suggestion_author/show.erb +9 -0
  29. data/app/cells/decidim/participatory_documents/suggestion_author_cell.rb +50 -0
  30. data/app/cells/decidim/participatory_documents/suggestion_cell.rb +41 -0
  31. data/app/commands/decidim/participatory_documents/admin/answer_suggestion.rb +62 -0
  32. data/app/commands/decidim/participatory_documents/admin/assign_suggestions_to_valuator.rb +59 -0
  33. data/app/commands/decidim/participatory_documents/admin/create_document.rb +55 -0
  34. data/app/commands/decidim/participatory_documents/admin/create_suggestion_note.rb +49 -0
  35. data/app/commands/decidim/participatory_documents/admin/destroy_annotation.rb +67 -0
  36. data/app/commands/decidim/participatory_documents/admin/notify_suggestion_answer.rb +52 -0
  37. data/app/commands/decidim/participatory_documents/admin/publish_answers.rb +59 -0
  38. data/app/commands/decidim/participatory_documents/admin/publish_document.rb +26 -0
  39. data/app/commands/decidim/participatory_documents/admin/unassign_suggestions_from_valuator.rb +60 -0
  40. data/app/commands/decidim/participatory_documents/admin/update_document.rb +85 -0
  41. data/app/commands/decidim/participatory_documents/admin/update_or_create_annotation.rb +98 -0
  42. data/app/commands/decidim/participatory_documents/admin/update_section.rb +52 -0
  43. data/app/commands/decidim/participatory_documents/admin/update_suggestion_note.rb +36 -0
  44. data/app/commands/decidim/participatory_documents/create_suggestion.rb +65 -0
  45. data/app/controllers/concerns/decidim/participatory_documents/admin/needs_admin_snippets.rb +25 -0
  46. data/app/controllers/concerns/decidim/participatory_documents/needs_pdf_document.rb +105 -0
  47. data/app/controllers/decidim/participatory_documents/admin/annotations_controller.rb +51 -0
  48. data/app/controllers/decidim/participatory_documents/admin/application_controller.rb +18 -0
  49. data/app/controllers/decidim/participatory_documents/admin/documents_controller.rb +104 -0
  50. data/app/controllers/decidim/participatory_documents/admin/sections_controller.rb +39 -0
  51. data/app/controllers/decidim/participatory_documents/admin/suggestion_notes_controller.rb +59 -0
  52. data/app/controllers/decidim/participatory_documents/admin/suggestions_controller.rb +160 -0
  53. data/app/controllers/decidim/participatory_documents/admin/valuation_assignments_controller.rb +58 -0
  54. data/app/controllers/decidim/participatory_documents/application_controller.rb +14 -0
  55. data/app/controllers/decidim/participatory_documents/document_suggestions_controller.rb +40 -0
  56. data/app/controllers/decidim/participatory_documents/documents_controller.rb +18 -0
  57. data/app/controllers/decidim/participatory_documents/section_suggestions_controller.rb +40 -0
  58. data/app/events/decidim/participatory_documents/suggestion_answer_event.rb +43 -0
  59. data/app/forms/decidim/participatory_documents/admin/annotation_form.rb +26 -0
  60. data/app/forms/decidim/participatory_documents/admin/answer_suggestion_form.rb +21 -0
  61. data/app/forms/decidim/participatory_documents/admin/document_form.rb +29 -0
  62. data/app/forms/decidim/participatory_documents/admin/section_form.rb +17 -0
  63. data/app/forms/decidim/participatory_documents/admin/suggestion_note_form.rb +15 -0
  64. data/app/forms/decidim/participatory_documents/admin/valuation_assignment_form.rb +38 -0
  65. data/app/forms/decidim/participatory_documents/suggestion_form.rb +39 -0
  66. data/app/helpers/decidim/participatory_documents/admin/button_helper.rb +17 -0
  67. data/app/helpers/decidim/participatory_documents/admin/documents_helper.rb +71 -0
  68. data/app/helpers/decidim/participatory_documents/admin/suggestion_helper.rb +54 -0
  69. data/app/helpers/decidim/participatory_documents/documents_helper.rb +41 -0
  70. data/app/models/concerns/decidim/participatory_documents/participatory_space_user_role_override.rb +19 -0
  71. data/app/models/concerns/decidim/participatory_documents/valuator_override.rb +18 -0
  72. data/app/models/decidim/participatory_documents/annotation.rb +28 -0
  73. data/app/models/decidim/participatory_documents/application_record.rb +10 -0
  74. data/app/models/decidim/participatory_documents/document.rb +67 -0
  75. data/app/models/decidim/participatory_documents/section.rb +44 -0
  76. data/app/models/decidim/participatory_documents/suggestion.rb +167 -0
  77. data/app/models/decidim/participatory_documents/suggestion_note.rb +18 -0
  78. data/app/models/decidim/participatory_documents/valuation_assignment.rb +21 -0
  79. data/app/packs/entrypoints/decidim_participatory_documents.js +6 -0
  80. data/app/packs/entrypoints/decidim_participatory_documents.scss +18 -0
  81. data/app/packs/entrypoints/decidim_participatory_documents_admin.js +7 -0
  82. data/app/packs/entrypoints/decidim_participatory_documents_admin.scss +69 -0
  83. data/app/packs/entrypoints/decidim_participatory_documents_editor.js +12 -0
  84. data/app/packs/entrypoints/decidim_participatory_documents_editor.scss +33 -0
  85. data/app/packs/entrypoints/decidim_participatory_documents_viewer.js +6 -0
  86. data/app/packs/entrypoints/decidim_participatory_documents_viewer.scss +11 -0
  87. data/app/packs/images/.keep +0 -0
  88. data/app/packs/images/badge.svg +6 -0
  89. data/app/packs/images/fullscreen.svg +6 -0
  90. data/app/packs/images/fullscreen_exit.svg +14 -0
  91. data/app/packs/images/group.svg +1 -0
  92. data/app/packs/images/move.svg +49 -0
  93. data/app/packs/images/participatory_documents.svg +14 -0
  94. data/app/packs/src/decidim/participatory_documents/admin/manage_bulk_suggestions.js +133 -0
  95. data/app/packs/src/decidim/participatory_documents/admin/preview_box_color.js +14 -0
  96. data/app/packs/src/decidim/participatory_documents/global.js +22 -0
  97. data/app/packs/src/decidim/participatory_documents/pdf/box.js +234 -0
  98. data/app/packs/src/decidim/participatory_documents/pdf/box_control_group.js +80 -0
  99. data/app/packs/src/decidim/participatory_documents/pdf/box_control_move.js +55 -0
  100. data/app/packs/src/decidim/participatory_documents/pdf/box_controls.js +18 -0
  101. data/app/packs/src/decidim/participatory_documents/pdf/pdf_modal_manager.js +129 -0
  102. data/app/packs/src/decidim/participatory_documents/pdf/pdf_state_manager.js +141 -0
  103. data/app/packs/src/decidim/participatory_documents/pdf/polygon_editor.js +99 -0
  104. data/app/packs/src/decidim/participatory_documents/pdf/polygon_viewer.js +55 -0
  105. data/app/packs/src/decidim/participatory_documents/pdf/suggestion_form.js +142 -0
  106. data/app/packs/src/decidim/participatory_documents/pdf.js +37 -0
  107. data/app/packs/src/decidim/participatory_documents/pdf_admin.js +60 -0
  108. data/app/packs/src/decidim/participatory_documents/pdf_notifications.js +20 -0
  109. data/app/packs/src/decidim/participatory_documents/skip_cookie_warning.js +10 -0
  110. data/app/packs/stylesheets/decidim/participatory_documents/decidim_admin_classes.scss +13 -0
  111. data/app/packs/stylesheets/decidim/participatory_documents/pdf/admin_modals.scss +41 -0
  112. data/app/packs/stylesheets/decidim/participatory_documents/pdf/admin_polygons.scss +131 -0
  113. data/app/packs/stylesheets/decidim/participatory_documents/pdf/admin_tweaks.scss +44 -0
  114. data/app/packs/stylesheets/decidim/participatory_documents/pdf/defaults.scss +7 -0
  115. data/app/packs/stylesheets/decidim/participatory_documents/pdf/document.scss +7 -0
  116. data/app/packs/stylesheets/decidim/participatory_documents/pdf/modals.scss +152 -0
  117. data/app/packs/stylesheets/decidim/participatory_documents/pdf/notifications.scss +31 -0
  118. data/app/packs/stylesheets/decidim/participatory_documents/pdf/polygons.scss +80 -0
  119. data/app/packs/stylesheets/decidim/participatory_documents/pdf/tweaks.scss +147 -0
  120. data/app/permissions/decidim/participatory_documents/admin/permissions.rb +118 -0
  121. data/app/permissions/decidim/participatory_documents/permissions.rb +16 -0
  122. data/app/presenters/decidim/participatory_documents/admin_log/annotation_presenter.rb +25 -0
  123. data/app/presenters/decidim/participatory_documents/admin_log/document_presenter.rb +13 -0
  124. data/app/presenters/decidim/participatory_documents/admin_log/section_presenter.rb +25 -0
  125. data/app/presenters/decidim/participatory_documents/admin_log/suggestion_note_presenter.rb +49 -0
  126. data/app/serializers/decidim/participatory_documents/suggestion_serializer.rb +67 -0
  127. data/app/uploaders/decidim/participatory_documents/pdf_document_uploader.rb +11 -0
  128. data/app/views/decidim/admin/exports/_dropdown.html.erb +16 -0
  129. data/app/views/decidim/participatory_documents/admin/documents/_editor_modal.html.erb +3 -0
  130. data/app/views/decidim/participatory_documents/admin/documents/_form.html.erb +39 -0
  131. data/app/views/decidim/participatory_documents/admin/documents/_title.html.erb +7 -0
  132. data/app/views/decidim/participatory_documents/admin/documents/edit.html.erb +18 -0
  133. data/app/views/decidim/participatory_documents/admin/documents/edit_pdf.html.erb +15 -0
  134. data/app/views/decidim/participatory_documents/admin/documents/index.html.erb +11 -0
  135. data/app/views/decidim/participatory_documents/admin/documents/new.html.erb +17 -0
  136. data/app/views/decidim/participatory_documents/admin/documents/pdf_viewer.html.erb +105 -0
  137. data/app/views/decidim/participatory_documents/admin/sections/_form.html.erb +24 -0
  138. data/app/views/decidim/participatory_documents/admin/suggestion_notes/_editing_suggestion_note.html.erb +18 -0
  139. data/app/views/decidim/participatory_documents/admin/suggestion_notes/_form.html.erb +8 -0
  140. data/app/views/decidim/participatory_documents/admin/suggestion_notes/_suggestion_notes.html.erb +46 -0
  141. data/app/views/decidim/participatory_documents/admin/suggestions/_add_valuators.html.erb +17 -0
  142. data/app/views/decidim/participatory_documents/admin/suggestions/_bulk-actions.html.erb +7 -0
  143. data/app/views/decidim/participatory_documents/admin/suggestions/_form.html.erb +30 -0
  144. data/app/views/decidim/participatory_documents/admin/suggestions/_js-callout.html.erb +6 -0
  145. data/app/views/decidim/participatory_documents/admin/suggestions/_suggestion.html.erb +33 -0
  146. data/app/views/decidim/participatory_documents/admin/suggestions/_valuators.html.erb +43 -0
  147. data/app/views/decidim/participatory_documents/admin/suggestions/bulk_actions/_assign_to_valuator.html.erb +15 -0
  148. data/app/views/decidim/participatory_documents/admin/suggestions/bulk_actions/_dropdown.html.erb +36 -0
  149. data/app/views/decidim/participatory_documents/admin/suggestions/bulk_actions/_publish_answers.html.erb +14 -0
  150. data/app/views/decidim/participatory_documents/admin/suggestions/bulk_actions/_unassign_from_valuator.html.erb +15 -0
  151. data/app/views/decidim/participatory_documents/admin/suggestions/index.html.erb +45 -0
  152. data/app/views/decidim/participatory_documents/admin/suggestions/publish_answers.js.erb +17 -0
  153. data/app/views/decidim/participatory_documents/admin/suggestions/show.html.erb +55 -0
  154. data/app/views/decidim/participatory_documents/document_suggestions/_form.html.erb +29 -0
  155. data/app/views/decidim/participatory_documents/document_suggestions/index.html.erb +14 -0
  156. data/app/views/decidim/participatory_documents/documents/_pdfjs_base.html.erb +428 -0
  157. data/app/views/decidim/participatory_documents/documents/index.html.erb +27 -0
  158. data/app/views/decidim/participatory_documents/documents/pdf_viewer.html.erb +63 -0
  159. data/app/views/decidim/participatory_documents/section_suggestions/_form.html.erb +8 -0
  160. data/app/views/decidim/participatory_documents/section_suggestions/index.html.erb +14 -0
  161. data/babel.config.json +25 -0
  162. data/bin/bundle +62 -0
  163. data/bin/rails +6 -0
  164. data/bin/webpack-dev-server +6 -0
  165. data/codecov.yml +11 -0
  166. data/config/assets.rb +11 -0
  167. data/config/i18n-tasks.yml +12 -0
  168. data/config/locales/en.yml +266 -0
  169. data/crowdin.yml +45 -0
  170. data/db/migrate/20221018112720_create_decidim_participatory_documents_document.rb +17 -0
  171. data/db/migrate/20221115233021_create_decidim_participatory_documents_participation_sections.rb +12 -0
  172. data/db/migrate/20221115233022_create_decidim_participatory_documents_annotations.rb +13 -0
  173. data/db/migrate/20221115233023_create_decidim_participatory_documents_suggestions.rb +17 -0
  174. data/db/migrate/20221115233024_create_decidim_participatory_documents_suggestion_notes.rb +15 -0
  175. data/db/migrate/20221115233024_create_decidim_participatory_documents_valuation_assignments.rb +12 -0
  176. data/db/migrate/20230616100340_add_published_at_to_decidim_participatory_documents_documents.rb +8 -0
  177. data/db/migrate/20230622081831_add_decidim_participatory_documents_box_positions.rb +37 -0
  178. data/decidim-participatory_documents.gemspec +30 -0
  179. data/lib/decidim/participatory_documents/admin.rb +8 -0
  180. data/lib/decidim/participatory_documents/admin_engine.rb +45 -0
  181. data/lib/decidim/participatory_documents/component.rb +202 -0
  182. data/lib/decidim/participatory_documents/engine.rb +46 -0
  183. data/lib/decidim/participatory_documents/seeds/Exampledocument.pdf +0 -0
  184. data/lib/decidim/participatory_documents/test/factories.rb +144 -0
  185. data/lib/decidim/participatory_documents/version.rb +9 -0
  186. data/lib/decidim/participatory_documents.rb +29 -0
  187. data/lib/tasks/decidim_participatory_documents.rake +27 -0
  188. data/package-lock.json +12687 -0
  189. data/package.json +52 -0
  190. data/pdfjs/LICENSE +177 -0
  191. data/pdfjs/README.md +12 -0
  192. data/pdfjs/build/pdf.js +15629 -0
  193. data/pdfjs/build/pdf.js.map +1 -0
  194. data/pdfjs/build/pdf.sandbox.js +280 -0
  195. data/pdfjs/build/pdf.sandbox.js.map +1 -0
  196. data/pdfjs/build/pdf.worker.js +64496 -0
  197. data/pdfjs/build/pdf.worker.js.map +1 -0
  198. data/pdfjs/web/cmaps/78-EUC-H.bcmap +0 -0
  199. data/pdfjs/web/cmaps/78-EUC-V.bcmap +0 -0
  200. data/pdfjs/web/cmaps/78-H.bcmap +0 -0
  201. data/pdfjs/web/cmaps/78-RKSJ-H.bcmap +0 -0
  202. data/pdfjs/web/cmaps/78-RKSJ-V.bcmap +0 -0
  203. data/pdfjs/web/cmaps/78-V.bcmap +0 -0
  204. data/pdfjs/web/cmaps/78ms-RKSJ-H.bcmap +0 -0
  205. data/pdfjs/web/cmaps/78ms-RKSJ-V.bcmap +0 -0
  206. data/pdfjs/web/cmaps/83pv-RKSJ-H.bcmap +0 -0
  207. data/pdfjs/web/cmaps/90ms-RKSJ-H.bcmap +0 -0
  208. data/pdfjs/web/cmaps/90ms-RKSJ-V.bcmap +0 -0
  209. data/pdfjs/web/cmaps/90msp-RKSJ-H.bcmap +0 -0
  210. data/pdfjs/web/cmaps/90msp-RKSJ-V.bcmap +0 -0
  211. data/pdfjs/web/cmaps/90pv-RKSJ-H.bcmap +0 -0
  212. data/pdfjs/web/cmaps/90pv-RKSJ-V.bcmap +0 -0
  213. data/pdfjs/web/cmaps/Add-H.bcmap +0 -0
  214. data/pdfjs/web/cmaps/Add-RKSJ-H.bcmap +0 -0
  215. data/pdfjs/web/cmaps/Add-RKSJ-V.bcmap +0 -0
  216. data/pdfjs/web/cmaps/Add-V.bcmap +0 -0
  217. data/pdfjs/web/cmaps/Adobe-CNS1-0.bcmap +0 -0
  218. data/pdfjs/web/cmaps/Adobe-CNS1-1.bcmap +0 -0
  219. data/pdfjs/web/cmaps/Adobe-CNS1-2.bcmap +0 -0
  220. data/pdfjs/web/cmaps/Adobe-CNS1-3.bcmap +0 -0
  221. data/pdfjs/web/cmaps/Adobe-CNS1-4.bcmap +0 -0
  222. data/pdfjs/web/cmaps/Adobe-CNS1-5.bcmap +0 -0
  223. data/pdfjs/web/cmaps/Adobe-CNS1-6.bcmap +0 -0
  224. data/pdfjs/web/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  225. data/pdfjs/web/cmaps/Adobe-GB1-0.bcmap +0 -0
  226. data/pdfjs/web/cmaps/Adobe-GB1-1.bcmap +0 -0
  227. data/pdfjs/web/cmaps/Adobe-GB1-2.bcmap +0 -0
  228. data/pdfjs/web/cmaps/Adobe-GB1-3.bcmap +0 -0
  229. data/pdfjs/web/cmaps/Adobe-GB1-4.bcmap +0 -0
  230. data/pdfjs/web/cmaps/Adobe-GB1-5.bcmap +0 -0
  231. data/pdfjs/web/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  232. data/pdfjs/web/cmaps/Adobe-Japan1-0.bcmap +0 -0
  233. data/pdfjs/web/cmaps/Adobe-Japan1-1.bcmap +0 -0
  234. data/pdfjs/web/cmaps/Adobe-Japan1-2.bcmap +0 -0
  235. data/pdfjs/web/cmaps/Adobe-Japan1-3.bcmap +0 -0
  236. data/pdfjs/web/cmaps/Adobe-Japan1-4.bcmap +0 -0
  237. data/pdfjs/web/cmaps/Adobe-Japan1-5.bcmap +0 -0
  238. data/pdfjs/web/cmaps/Adobe-Japan1-6.bcmap +0 -0
  239. data/pdfjs/web/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  240. data/pdfjs/web/cmaps/Adobe-Korea1-0.bcmap +0 -0
  241. data/pdfjs/web/cmaps/Adobe-Korea1-1.bcmap +0 -0
  242. data/pdfjs/web/cmaps/Adobe-Korea1-2.bcmap +0 -0
  243. data/pdfjs/web/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  244. data/pdfjs/web/cmaps/B5-H.bcmap +0 -0
  245. data/pdfjs/web/cmaps/B5-V.bcmap +0 -0
  246. data/pdfjs/web/cmaps/B5pc-H.bcmap +0 -0
  247. data/pdfjs/web/cmaps/B5pc-V.bcmap +0 -0
  248. data/pdfjs/web/cmaps/CNS-EUC-H.bcmap +0 -0
  249. data/pdfjs/web/cmaps/CNS-EUC-V.bcmap +0 -0
  250. data/pdfjs/web/cmaps/CNS1-H.bcmap +0 -0
  251. data/pdfjs/web/cmaps/CNS1-V.bcmap +0 -0
  252. data/pdfjs/web/cmaps/CNS2-H.bcmap +0 -0
  253. data/pdfjs/web/cmaps/CNS2-V.bcmap +3 -0
  254. data/pdfjs/web/cmaps/ETHK-B5-H.bcmap +0 -0
  255. data/pdfjs/web/cmaps/ETHK-B5-V.bcmap +0 -0
  256. data/pdfjs/web/cmaps/ETen-B5-H.bcmap +0 -0
  257. data/pdfjs/web/cmaps/ETen-B5-V.bcmap +0 -0
  258. data/pdfjs/web/cmaps/ETenms-B5-H.bcmap +3 -0
  259. data/pdfjs/web/cmaps/ETenms-B5-V.bcmap +0 -0
  260. data/pdfjs/web/cmaps/EUC-H.bcmap +0 -0
  261. data/pdfjs/web/cmaps/EUC-V.bcmap +0 -0
  262. data/pdfjs/web/cmaps/Ext-H.bcmap +0 -0
  263. data/pdfjs/web/cmaps/Ext-RKSJ-H.bcmap +0 -0
  264. data/pdfjs/web/cmaps/Ext-RKSJ-V.bcmap +0 -0
  265. data/pdfjs/web/cmaps/Ext-V.bcmap +0 -0
  266. data/pdfjs/web/cmaps/GB-EUC-H.bcmap +0 -0
  267. data/pdfjs/web/cmaps/GB-EUC-V.bcmap +0 -0
  268. data/pdfjs/web/cmaps/GB-H.bcmap +4 -0
  269. data/pdfjs/web/cmaps/GB-V.bcmap +0 -0
  270. data/pdfjs/web/cmaps/GBK-EUC-H.bcmap +0 -0
  271. data/pdfjs/web/cmaps/GBK-EUC-V.bcmap +0 -0
  272. data/pdfjs/web/cmaps/GBK2K-H.bcmap +0 -0
  273. data/pdfjs/web/cmaps/GBK2K-V.bcmap +0 -0
  274. data/pdfjs/web/cmaps/GBKp-EUC-H.bcmap +0 -0
  275. data/pdfjs/web/cmaps/GBKp-EUC-V.bcmap +0 -0
  276. data/pdfjs/web/cmaps/GBT-EUC-H.bcmap +0 -0
  277. data/pdfjs/web/cmaps/GBT-EUC-V.bcmap +0 -0
  278. data/pdfjs/web/cmaps/GBT-H.bcmap +0 -0
  279. data/pdfjs/web/cmaps/GBT-V.bcmap +0 -0
  280. data/pdfjs/web/cmaps/GBTpc-EUC-H.bcmap +0 -0
  281. data/pdfjs/web/cmaps/GBTpc-EUC-V.bcmap +0 -0
  282. data/pdfjs/web/cmaps/GBpc-EUC-H.bcmap +0 -0
  283. data/pdfjs/web/cmaps/GBpc-EUC-V.bcmap +0 -0
  284. data/pdfjs/web/cmaps/H.bcmap +0 -0
  285. data/pdfjs/web/cmaps/HKdla-B5-H.bcmap +0 -0
  286. data/pdfjs/web/cmaps/HKdla-B5-V.bcmap +0 -0
  287. data/pdfjs/web/cmaps/HKdlb-B5-H.bcmap +0 -0
  288. data/pdfjs/web/cmaps/HKdlb-B5-V.bcmap +0 -0
  289. data/pdfjs/web/cmaps/HKgccs-B5-H.bcmap +0 -0
  290. data/pdfjs/web/cmaps/HKgccs-B5-V.bcmap +0 -0
  291. data/pdfjs/web/cmaps/HKm314-B5-H.bcmap +0 -0
  292. data/pdfjs/web/cmaps/HKm314-B5-V.bcmap +0 -0
  293. data/pdfjs/web/cmaps/HKm471-B5-H.bcmap +0 -0
  294. data/pdfjs/web/cmaps/HKm471-B5-V.bcmap +0 -0
  295. data/pdfjs/web/cmaps/HKscs-B5-H.bcmap +0 -0
  296. data/pdfjs/web/cmaps/HKscs-B5-V.bcmap +0 -0
  297. data/pdfjs/web/cmaps/Hankaku.bcmap +0 -0
  298. data/pdfjs/web/cmaps/Hiragana.bcmap +0 -0
  299. data/pdfjs/web/cmaps/KSC-EUC-H.bcmap +0 -0
  300. data/pdfjs/web/cmaps/KSC-EUC-V.bcmap +0 -0
  301. data/pdfjs/web/cmaps/KSC-H.bcmap +0 -0
  302. data/pdfjs/web/cmaps/KSC-Johab-H.bcmap +0 -0
  303. data/pdfjs/web/cmaps/KSC-Johab-V.bcmap +0 -0
  304. data/pdfjs/web/cmaps/KSC-V.bcmap +0 -0
  305. data/pdfjs/web/cmaps/KSCms-UHC-H.bcmap +0 -0
  306. data/pdfjs/web/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  307. data/pdfjs/web/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  308. data/pdfjs/web/cmaps/KSCms-UHC-V.bcmap +0 -0
  309. data/pdfjs/web/cmaps/KSCpc-EUC-H.bcmap +0 -0
  310. data/pdfjs/web/cmaps/KSCpc-EUC-V.bcmap +0 -0
  311. data/pdfjs/web/cmaps/Katakana.bcmap +0 -0
  312. data/pdfjs/web/cmaps/LICENSE +36 -0
  313. data/pdfjs/web/cmaps/NWP-H.bcmap +0 -0
  314. data/pdfjs/web/cmaps/NWP-V.bcmap +0 -0
  315. data/pdfjs/web/cmaps/RKSJ-H.bcmap +0 -0
  316. data/pdfjs/web/cmaps/RKSJ-V.bcmap +0 -0
  317. data/pdfjs/web/cmaps/Roman.bcmap +0 -0
  318. data/pdfjs/web/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  319. data/pdfjs/web/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  320. data/pdfjs/web/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  321. data/pdfjs/web/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  322. data/pdfjs/web/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  323. data/pdfjs/web/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  324. data/pdfjs/web/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  325. data/pdfjs/web/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  326. data/pdfjs/web/cmaps/UniGB-UCS2-H.bcmap +0 -0
  327. data/pdfjs/web/cmaps/UniGB-UCS2-V.bcmap +0 -0
  328. data/pdfjs/web/cmaps/UniGB-UTF16-H.bcmap +0 -0
  329. data/pdfjs/web/cmaps/UniGB-UTF16-V.bcmap +0 -0
  330. data/pdfjs/web/cmaps/UniGB-UTF32-H.bcmap +0 -0
  331. data/pdfjs/web/cmaps/UniGB-UTF32-V.bcmap +0 -0
  332. data/pdfjs/web/cmaps/UniGB-UTF8-H.bcmap +0 -0
  333. data/pdfjs/web/cmaps/UniGB-UTF8-V.bcmap +0 -0
  334. data/pdfjs/web/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  335. data/pdfjs/web/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  336. data/pdfjs/web/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  337. data/pdfjs/web/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  338. data/pdfjs/web/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  339. data/pdfjs/web/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  340. data/pdfjs/web/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  341. data/pdfjs/web/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  342. data/pdfjs/web/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  343. data/pdfjs/web/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  344. data/pdfjs/web/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  345. data/pdfjs/web/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  346. data/pdfjs/web/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  347. data/pdfjs/web/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  348. data/pdfjs/web/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  349. data/pdfjs/web/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  350. data/pdfjs/web/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  351. data/pdfjs/web/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  352. data/pdfjs/web/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  353. data/pdfjs/web/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  354. data/pdfjs/web/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  355. data/pdfjs/web/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  356. data/pdfjs/web/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  357. data/pdfjs/web/cmaps/UniKS-UCS2-H.bcmap +0 -0
  358. data/pdfjs/web/cmaps/UniKS-UCS2-V.bcmap +0 -0
  359. data/pdfjs/web/cmaps/UniKS-UTF16-H.bcmap +0 -0
  360. data/pdfjs/web/cmaps/UniKS-UTF16-V.bcmap +0 -0
  361. data/pdfjs/web/cmaps/UniKS-UTF32-H.bcmap +0 -0
  362. data/pdfjs/web/cmaps/UniKS-UTF32-V.bcmap +0 -0
  363. data/pdfjs/web/cmaps/UniKS-UTF8-H.bcmap +0 -0
  364. data/pdfjs/web/cmaps/UniKS-UTF8-V.bcmap +0 -0
  365. data/pdfjs/web/cmaps/V.bcmap +0 -0
  366. data/pdfjs/web/cmaps/WP-Symbol.bcmap +0 -0
  367. data/pdfjs/web/compressed.tracemonkey-pldi-09.pdf +0 -0
  368. data/pdfjs/web/debugger.css +113 -0
  369. data/pdfjs/web/debugger.js +612 -0
  370. data/pdfjs/web/images/annotation-check.svg +11 -0
  371. data/pdfjs/web/images/annotation-comment.svg +16 -0
  372. data/pdfjs/web/images/annotation-help.svg +26 -0
  373. data/pdfjs/web/images/annotation-insert.svg +10 -0
  374. data/pdfjs/web/images/annotation-key.svg +11 -0
  375. data/pdfjs/web/images/annotation-newparagraph.svg +11 -0
  376. data/pdfjs/web/images/annotation-noicon.svg +7 -0
  377. data/pdfjs/web/images/annotation-note.svg +42 -0
  378. data/pdfjs/web/images/annotation-paperclip.svg +6 -0
  379. data/pdfjs/web/images/annotation-paragraph.svg +16 -0
  380. data/pdfjs/web/images/annotation-pushpin.svg +7 -0
  381. data/pdfjs/web/images/cursor-editorFreeText.svg +3 -0
  382. data/pdfjs/web/images/cursor-editorInk.svg +4 -0
  383. data/pdfjs/web/images/findbarButton-next.svg +3 -0
  384. data/pdfjs/web/images/findbarButton-previous.svg +3 -0
  385. data/pdfjs/web/images/loading-dark.svg +24 -0
  386. data/pdfjs/web/images/loading-icon.gif +0 -0
  387. data/pdfjs/web/images/loading.svg +1 -0
  388. data/pdfjs/web/images/secondaryToolbarButton-documentProperties.svg +3 -0
  389. data/pdfjs/web/images/secondaryToolbarButton-firstPage.svg +3 -0
  390. data/pdfjs/web/images/secondaryToolbarButton-handTool.svg +3 -0
  391. data/pdfjs/web/images/secondaryToolbarButton-lastPage.svg +3 -0
  392. data/pdfjs/web/images/secondaryToolbarButton-rotateCcw.svg +3 -0
  393. data/pdfjs/web/images/secondaryToolbarButton-rotateCw.svg +3 -0
  394. data/pdfjs/web/images/secondaryToolbarButton-scrollHorizontal.svg +3 -0
  395. data/pdfjs/web/images/secondaryToolbarButton-scrollPage.svg +3 -0
  396. data/pdfjs/web/images/secondaryToolbarButton-scrollVertical.svg +3 -0
  397. data/pdfjs/web/images/secondaryToolbarButton-scrollWrapped.svg +3 -0
  398. data/pdfjs/web/images/secondaryToolbarButton-selectTool.svg +3 -0
  399. data/pdfjs/web/images/secondaryToolbarButton-spreadEven.svg +3 -0
  400. data/pdfjs/web/images/secondaryToolbarButton-spreadNone.svg +3 -0
  401. data/pdfjs/web/images/secondaryToolbarButton-spreadOdd.svg +3 -0
  402. data/pdfjs/web/images/shadow.png +0 -0
  403. data/pdfjs/web/images/toolbarButton-bookmark.svg +3 -0
  404. data/pdfjs/web/images/toolbarButton-currentOutlineItem.svg +3 -0
  405. data/pdfjs/web/images/toolbarButton-download.svg +4 -0
  406. data/pdfjs/web/images/toolbarButton-editorFreeText.svg +3 -0
  407. data/pdfjs/web/images/toolbarButton-editorInk.svg +4 -0
  408. data/pdfjs/web/images/toolbarButton-menuArrow.svg +3 -0
  409. data/pdfjs/web/images/toolbarButton-openFile.svg +3 -0
  410. data/pdfjs/web/images/toolbarButton-pageDown.svg +3 -0
  411. data/pdfjs/web/images/toolbarButton-pageUp.svg +3 -0
  412. data/pdfjs/web/images/toolbarButton-presentationMode.svg +3 -0
  413. data/pdfjs/web/images/toolbarButton-print.svg +3 -0
  414. data/pdfjs/web/images/toolbarButton-search.svg +3 -0
  415. data/pdfjs/web/images/toolbarButton-secondaryToolbarToggle.svg +3 -0
  416. data/pdfjs/web/images/toolbarButton-sidebarToggle.svg +3 -0
  417. data/pdfjs/web/images/toolbarButton-viewAttachments.svg +3 -0
  418. data/pdfjs/web/images/toolbarButton-viewLayers.svg +3 -0
  419. data/pdfjs/web/images/toolbarButton-viewOutline.svg +3 -0
  420. data/pdfjs/web/images/toolbarButton-viewThumbnail.svg +3 -0
  421. data/pdfjs/web/images/toolbarButton-zoomIn.svg +3 -0
  422. data/pdfjs/web/images/toolbarButton-zoomOut.svg +3 -0
  423. data/pdfjs/web/images/treeitem-collapsed.svg +1 -0
  424. data/pdfjs/web/images/treeitem-expanded.svg +1 -0
  425. data/pdfjs/web/locale/ach/viewer.properties +200 -0
  426. data/pdfjs/web/locale/af/viewer.properties +177 -0
  427. data/pdfjs/web/locale/an/viewer.properties +243 -0
  428. data/pdfjs/web/locale/ar/viewer.properties +247 -0
  429. data/pdfjs/web/locale/ast/viewer.properties +207 -0
  430. data/pdfjs/web/locale/az/viewer.properties +243 -0
  431. data/pdfjs/web/locale/be/viewer.properties +274 -0
  432. data/pdfjs/web/locale/bg/viewer.properties +235 -0
  433. data/pdfjs/web/locale/bn/viewer.properties +239 -0
  434. data/pdfjs/web/locale/bo/viewer.properties +238 -0
  435. data/pdfjs/web/locale/br/viewer.properties +247 -0
  436. data/pdfjs/web/locale/brx/viewer.properties +205 -0
  437. data/pdfjs/web/locale/bs/viewer.properties +194 -0
  438. data/pdfjs/web/locale/ca/viewer.properties +251 -0
  439. data/pdfjs/web/locale/cak/viewer.properties +249 -0
  440. data/pdfjs/web/locale/ckb/viewer.properties +234 -0
  441. data/pdfjs/web/locale/cs/viewer.properties +274 -0
  442. data/pdfjs/web/locale/cy/viewer.properties +274 -0
  443. data/pdfjs/web/locale/da/viewer.properties +274 -0
  444. data/pdfjs/web/locale/de/viewer.properties +274 -0
  445. data/pdfjs/web/locale/dsb/viewer.properties +274 -0
  446. data/pdfjs/web/locale/el/viewer.properties +274 -0
  447. data/pdfjs/web/locale/en-CA/viewer.properties +274 -0
  448. data/pdfjs/web/locale/en-GB/viewer.properties +274 -0
  449. data/pdfjs/web/locale/en-US/viewer.properties +253 -0
  450. data/pdfjs/web/locale/eo/viewer.properties +274 -0
  451. data/pdfjs/web/locale/es-AR/viewer.properties +274 -0
  452. data/pdfjs/web/locale/es-CL/viewer.properties +274 -0
  453. data/pdfjs/web/locale/es-ES/viewer.properties +274 -0
  454. data/pdfjs/web/locale/es-MX/viewer.properties +274 -0
  455. data/pdfjs/web/locale/et/viewer.properties +262 -0
  456. data/pdfjs/web/locale/eu/viewer.properties +272 -0
  457. data/pdfjs/web/locale/fa/viewer.properties +216 -0
  458. data/pdfjs/web/locale/ff/viewer.properties +235 -0
  459. data/pdfjs/web/locale/fi/viewer.properties +274 -0
  460. data/pdfjs/web/locale/fr/viewer.properties +274 -0
  461. data/pdfjs/web/locale/fy-NL/viewer.properties +274 -0
  462. data/pdfjs/web/locale/ga-IE/viewer.properties +202 -0
  463. data/pdfjs/web/locale/gd/viewer.properties +249 -0
  464. data/pdfjs/web/locale/gl/viewer.properties +249 -0
  465. data/pdfjs/web/locale/gn/viewer.properties +274 -0
  466. data/pdfjs/web/locale/gu-IN/viewer.properties +235 -0
  467. data/pdfjs/web/locale/he/viewer.properties +274 -0
  468. data/pdfjs/web/locale/hi-IN/viewer.properties +235 -0
  469. data/pdfjs/web/locale/hr/viewer.properties +249 -0
  470. data/pdfjs/web/locale/hsb/viewer.properties +274 -0
  471. data/pdfjs/web/locale/hu/viewer.properties +274 -0
  472. data/pdfjs/web/locale/hy-AM/viewer.properties +239 -0
  473. data/pdfjs/web/locale/hye/viewer.properties +252 -0
  474. data/pdfjs/web/locale/ia/viewer.properties +274 -0
  475. data/pdfjs/web/locale/id/viewer.properties +274 -0
  476. data/pdfjs/web/locale/is/viewer.properties +274 -0
  477. data/pdfjs/web/locale/it/viewer.properties +215 -0
  478. data/pdfjs/web/locale/ja/viewer.properties +274 -0
  479. data/pdfjs/web/locale/ka/viewer.properties +274 -0
  480. data/pdfjs/web/locale/kab/viewer.properties +274 -0
  481. data/pdfjs/web/locale/kk/viewer.properties +274 -0
  482. data/pdfjs/web/locale/km/viewer.properties +210 -0
  483. data/pdfjs/web/locale/kn/viewer.properties +187 -0
  484. data/pdfjs/web/locale/ko/viewer.properties +274 -0
  485. data/pdfjs/web/locale/lij/viewer.properties +235 -0
  486. data/pdfjs/web/locale/lo/viewer.properties +145 -0
  487. data/pdfjs/web/locale/locale.properties +327 -0
  488. data/pdfjs/web/locale/lt/viewer.properties +260 -0
  489. data/pdfjs/web/locale/ltg/viewer.properties +213 -0
  490. data/pdfjs/web/locale/lv/viewer.properties +235 -0
  491. data/pdfjs/web/locale/meh/viewer.properties +111 -0
  492. data/pdfjs/web/locale/mk/viewer.properties +139 -0
  493. data/pdfjs/web/locale/mr/viewer.properties +231 -0
  494. data/pdfjs/web/locale/ms/viewer.properties +235 -0
  495. data/pdfjs/web/locale/my/viewer.properties +191 -0
  496. data/pdfjs/web/locale/nb-NO/viewer.properties +274 -0
  497. data/pdfjs/web/locale/ne-NP/viewer.properties +218 -0
  498. data/pdfjs/web/locale/nl/viewer.properties +274 -0
  499. data/pdfjs/web/locale/nn-NO/viewer.properties +274 -0
  500. data/pdfjs/web/locale/oc/viewer.properties +274 -0
  501. data/pdfjs/web/locale/pa-IN/viewer.properties +285 -0
  502. data/pdfjs/web/locale/pl/viewer.properties +274 -0
  503. data/pdfjs/web/locale/pt-BR/viewer.properties +274 -0
  504. data/pdfjs/web/locale/pt-PT/viewer.properties +274 -0
  505. data/pdfjs/web/locale/rm/viewer.properties +274 -0
  506. data/pdfjs/web/locale/ro/viewer.properties +241 -0
  507. data/pdfjs/web/locale/ru/viewer.properties +274 -0
  508. data/pdfjs/web/locale/sat/viewer.properties +198 -0
  509. data/pdfjs/web/locale/sc/viewer.properties +240 -0
  510. data/pdfjs/web/locale/scn/viewer.properties +101 -0
  511. data/pdfjs/web/locale/sco/viewer.properties +249 -0
  512. data/pdfjs/web/locale/si/viewer.properties +237 -0
  513. data/pdfjs/web/locale/sk/viewer.properties +274 -0
  514. data/pdfjs/web/locale/sl/viewer.properties +274 -0
  515. data/pdfjs/web/locale/son/viewer.properties +173 -0
  516. data/pdfjs/web/locale/sq/viewer.properties +267 -0
  517. data/pdfjs/web/locale/sr/viewer.properties +253 -0
  518. data/pdfjs/web/locale/sv-SE/viewer.properties +274 -0
  519. data/pdfjs/web/locale/szl/viewer.properties +245 -0
  520. data/pdfjs/web/locale/ta/viewer.properties +194 -0
  521. data/pdfjs/web/locale/te/viewer.properties +237 -0
  522. data/pdfjs/web/locale/tg/viewer.properties +274 -0
  523. data/pdfjs/web/locale/th/viewer.properties +274 -0
  524. data/pdfjs/web/locale/tl/viewer.properties +243 -0
  525. data/pdfjs/web/locale/tr/viewer.properties +274 -0
  526. data/pdfjs/web/locale/trs/viewer.properties +206 -0
  527. data/pdfjs/web/locale/uk/viewer.properties +274 -0
  528. data/pdfjs/web/locale/ur/viewer.properties +239 -0
  529. data/pdfjs/web/locale/uz/viewer.properties +163 -0
  530. data/pdfjs/web/locale/vi/viewer.properties +274 -0
  531. data/pdfjs/web/locale/wo/viewer.properties +123 -0
  532. data/pdfjs/web/locale/xh/viewer.properties +177 -0
  533. data/pdfjs/web/locale/zh-CN/viewer.properties +274 -0
  534. data/pdfjs/web/locale/zh-TW/viewer.properties +274 -0
  535. data/pdfjs/web/standard_fonts/FoxitDingbats.pfb +0 -0
  536. data/pdfjs/web/standard_fonts/FoxitFixed.pfb +0 -0
  537. data/pdfjs/web/standard_fonts/FoxitFixedBold.pfb +0 -0
  538. data/pdfjs/web/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  539. data/pdfjs/web/standard_fonts/FoxitFixedItalic.pfb +0 -0
  540. data/pdfjs/web/standard_fonts/FoxitSans.pfb +0 -0
  541. data/pdfjs/web/standard_fonts/FoxitSansBold.pfb +0 -0
  542. data/pdfjs/web/standard_fonts/FoxitSansBoldItalic.pfb +0 -0
  543. data/pdfjs/web/standard_fonts/FoxitSansItalic.pfb +0 -0
  544. data/pdfjs/web/standard_fonts/FoxitSerif.pfb +0 -0
  545. data/pdfjs/web/standard_fonts/FoxitSerifBold.pfb +0 -0
  546. data/pdfjs/web/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  547. data/pdfjs/web/standard_fonts/FoxitSerifItalic.pfb +0 -0
  548. data/pdfjs/web/standard_fonts/FoxitSymbol.pfb +0 -0
  549. data/pdfjs/web/standard_fonts/LICENSE_FOXIT +27 -0
  550. data/pdfjs/web/standard_fonts/LICENSE_LIBERATION +102 -0
  551. data/pdfjs/web/standard_fonts/LiberationSans-Bold.ttf +0 -0
  552. data/pdfjs/web/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  553. data/pdfjs/web/standard_fonts/LiberationSans-Italic.ttf +0 -0
  554. data/pdfjs/web/standard_fonts/LiberationSans-Regular.ttf +0 -0
  555. data/pdfjs/web/viewer.css +3029 -0
  556. data/pdfjs/web/viewer.html +433 -0
  557. data/pdfjs/web/viewer.js +13566 -0
  558. data/pdfjs/web/viewer.js.map +1 -0
  559. metadata +643 -0
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ class DestroyAnnotation < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form - A form object with the params.
10
+ def initialize(form, document)
11
+ @form = form
12
+ @document = document
13
+ end
14
+
15
+ def call
16
+ return broadcast(:invalid) if form.invalid?
17
+
18
+ begin
19
+ @old_section = annotation.section
20
+ transaction do
21
+ destroy_annotation!
22
+ end
23
+
24
+ destroy_old_section!
25
+ document.update_positions!
26
+
27
+ broadcast(:ok)
28
+ rescue ActiveRecord::RecordInvalid
29
+ broadcast(:invalid)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :form, :document
36
+
37
+ def destroy_annotation!
38
+ Decidim.traceability.perform_action!(
39
+ :delete,
40
+ annotation,
41
+ form.current_user
42
+ ) do
43
+ annotation.destroy!
44
+ end
45
+ end
46
+
47
+ # Destroys the old section if has no more annotations
48
+ def destroy_old_section!
49
+ return unless @old_section
50
+ return if @old_section.annotations.reload.any?
51
+
52
+ Decidim.traceability.perform_action!(
53
+ :delete,
54
+ @old_section,
55
+ form.current_user
56
+ ) do
57
+ @old_section.destroy!
58
+ end
59
+ end
60
+
61
+ def annotation
62
+ @annotation ||= document.annotations.find(form.id)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ class NotifySuggestionAnswer < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # suggestion - The suggestion to write the answer for.
10
+ # initial_state - The suggestion state before the current process.
11
+ def initialize(suggestion, initial_state)
12
+ @suggestion = suggestion
13
+ @initial_state = initial_state.to_s
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :noop when the answer is not published or the state didn't changed.
19
+ # - :ok when everything is valid.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ broadcast(:invalid) unless suggestion.has_answer? && suggestion.answered? && suggestion.answer_is_published?
24
+
25
+ notify_followers
26
+
27
+ broadcast(:ok)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :suggestion, :initial_state
33
+
34
+ def notify_followers
35
+ publish_event(
36
+ "decidim.events.participatory_documents.suggestion_answered",
37
+ Decidim::ParticipatoryDocuments::SuggestionAnswerEvent
38
+ )
39
+ end
40
+
41
+ def publish_event(event, event_class)
42
+ Decidim::EventsManager.publish(
43
+ event: event,
44
+ event_class: event_class,
45
+ resource: suggestion,
46
+ affected_users: [suggestion.author]
47
+ )
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ class PublishAnswers < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # component - The component that contains the answers.
10
+ # user - the Decidim::User that is publishing the answers.
11
+ # proposal_ids - the identifiers of the suggestions with the answers to be published.
12
+ def initialize(component, user, suggestion_ids)
13
+ @component = component
14
+ @user = user
15
+ @suggestion_ids = suggestion_ids
16
+ end
17
+
18
+ # Executes the command. Broadcasts these events:
19
+ #
20
+ # - :ok when everything is valid.
21
+ # - :invalid if there are not proposals to publish.
22
+ #
23
+ # Returns nothing.
24
+ def call
25
+ return broadcast(:invalid) unless suggestions.any?
26
+
27
+ suggestions.each do |suggestion|
28
+ suggestion.assign_attributes(answered_at: Time.current, answer_is_published: true)
29
+
30
+ if suggestion.answer_is_published_changed?
31
+ Decidim.traceability.perform_action!("publish_answer", suggestion, user) { suggestion.save! }
32
+ notify_user(suggestion)
33
+ end
34
+ end
35
+
36
+ broadcast(:ok)
37
+ end
38
+
39
+ private
40
+
41
+ def notify_user(suggestion)
42
+ suggestion.reload
43
+ return unless suggestion.has_answer?
44
+
45
+ NotifySuggestionAnswer.call(suggestion, nil)
46
+ end
47
+
48
+ attr_reader :component, :user, :suggestion_ids
49
+
50
+ def suggestions
51
+ @suggestions || Decidim::ParticipatoryDocuments::Suggestion
52
+ # .not_published
53
+ # .having_text_answer
54
+ .where(id: suggestion_ids)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ class PublishDocument < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # document - The document to publish.
10
+ def initialize(document)
11
+ @document = document
12
+ end
13
+
14
+ # Executes the command. Broadcasts these events:
15
+ #
16
+ # - :ok when everything is valid.
17
+ # Returns nothing.
18
+ def call
19
+ @document.publish!
20
+
21
+ broadcast(:ok)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ class UnassignSuggestionsFromValuator < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form - A form object with the params.
10
+ def initialize(form)
11
+ @form = form
12
+ end
13
+
14
+ # Executes the command. Broadcasts these events:
15
+ #
16
+ # - :ok when everything is valid.
17
+ # - :invalid if the form wasn't valid and we couldn't proceed.
18
+ #
19
+ # Returns nothing.
20
+ def call
21
+ return broadcast(:invalid) unless form.valid?
22
+
23
+ unassign_suggestions
24
+ broadcast(:ok)
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :form
30
+
31
+ def unassign_suggestions
32
+ transaction do
33
+ form.suggestions.flat_map do |suggestion|
34
+ assignment = find_assignment(suggestion)
35
+ unassign(assignment) if assignment
36
+ end
37
+ end
38
+ end
39
+
40
+ def find_assignment(suggestion)
41
+ Decidim::ParticipatoryDocuments::ValuationAssignment.find_by(
42
+ suggestion: suggestion,
43
+ valuator_role: form.valuator_role
44
+ )
45
+ end
46
+
47
+ def unassign(assignment)
48
+ Decidim.traceability.perform_action!(
49
+ :delete,
50
+ assignment,
51
+ form.current_user,
52
+ suggestion: assignment.suggestion.id
53
+ ) do
54
+ assignment.destroy!
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ class UpdateDocument < Decidim::Command
7
+ include ::Decidim::AttachmentAttributesMethods
8
+
9
+ def initialize(form, document)
10
+ @form = form
11
+ @document = document
12
+ @attached_to = document
13
+ end
14
+
15
+ def call
16
+ return broadcast(:invalid) if form.invalid?
17
+
18
+ begin
19
+ transaction do
20
+ destroy_sections!
21
+ update_document
22
+ end
23
+ broadcast(:ok, document)
24
+ rescue ActiveRecord::RecordNotDestroyed => e
25
+ # if sections contains annotations, can be deleted
26
+ # if sections contains suggestions, cannot be deleted
27
+ broadcast(:error, e.message)
28
+ rescue ActiveRecord::RecordInvalid
29
+ form.errors.add(:file, document.errors[:file]) if document.errors.include? :file
30
+ broadcast(:invalid)
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :form, :document
37
+
38
+ def attributes
39
+ {
40
+ title: form.title,
41
+ description: form.description,
42
+ box_color: form.box_color,
43
+ box_opacity: form.box_opacity
44
+ }.merge(attachment_attributes(:file))
45
+ end
46
+
47
+ def update_document
48
+ Decidim.traceability.update!(
49
+ document,
50
+ form.current_user,
51
+ **attributes
52
+ )
53
+ end
54
+
55
+ def destroy_sections!
56
+ return if form.file.blank?
57
+
58
+ raise ActiveRecord::RecordNotDestroyed, I18n.t("activemodel.errors.models.document.has_suggestions") if document.has_suggestions?
59
+
60
+ return unless document.sections.any?
61
+
62
+ document.annotations.each do |annotation|
63
+ Decidim.traceability.perform_action!(
64
+ "delete",
65
+ annotation,
66
+ current_user
67
+ ) do
68
+ annotation.destroy!
69
+ end
70
+ end
71
+
72
+ document.sections.each do |section|
73
+ Decidim.traceability.perform_action!(
74
+ "delete",
75
+ section,
76
+ current_user
77
+ ) do
78
+ section.destroy!
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ class UpdateOrCreateAnnotation < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form - A form object with the params.
10
+ def initialize(form, document)
11
+ @form = form
12
+ @document = document
13
+ end
14
+
15
+ def call
16
+ return broadcast(:invalid) if form.invalid?
17
+ return broadcast(:invalid) if document.nil?
18
+
19
+ begin
20
+ @old_section = annotation.present? ? annotation.section : nil
21
+
22
+ transaction do
23
+ create_section! if section.blank?
24
+ create_annotation! if annotation.blank?
25
+ annotation.assign_attributes(**attributes)
26
+ update_annotation! if annotation.changed?
27
+ end
28
+
29
+ destroy_old_section!
30
+ document.update_positions!
31
+
32
+ broadcast(:ok, annotation)
33
+ rescue ActiveRecord::RecordInvalid
34
+ broadcast(:invalid)
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ attr_reader :form, :document
41
+
42
+ def update_annotation!
43
+ @annotation = Decidim.traceability.update!(
44
+ annotation,
45
+ form.current_user,
46
+ **attributes
47
+ )
48
+ end
49
+
50
+ def create_annotation!
51
+ @annotation = Decidim.traceability.create!(
52
+ Decidim::ParticipatoryDocuments::Annotation,
53
+ form.current_user,
54
+ **attributes
55
+ )
56
+ end
57
+
58
+ def create_section!
59
+ @section = Decidim.traceability.create!(
60
+ Decidim::ParticipatoryDocuments::Section,
61
+ form.current_user,
62
+ document: document
63
+ )
64
+ end
65
+
66
+ # Destroys the old section if has no more annotations
67
+ def destroy_old_section!
68
+ return unless @old_section
69
+ return if @old_section.annotations.reload.any?
70
+
71
+ Decidim.traceability.perform_action!(
72
+ :delete,
73
+ @old_section,
74
+ form.current_user
75
+ ) do
76
+ @old_section.destroy!
77
+ end
78
+ end
79
+
80
+ def attributes
81
+ {
82
+ page_number: form.page_number,
83
+ rect: form.rect,
84
+ section: section
85
+ }
86
+ end
87
+
88
+ def section
89
+ @section ||= document.sections.find_by(id: form.section)
90
+ end
91
+
92
+ def annotation
93
+ @annotation ||= document.annotations.find_by(id: form.id)
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ class UpdateSection < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form - A form object with the params.
10
+ def initialize(form, document)
11
+ @form = form
12
+ @document = document
13
+ end
14
+
15
+ def call
16
+ return broadcast(:invalid) if form.invalid?
17
+
18
+ begin
19
+ transaction do
20
+ update_section
21
+ end
22
+ broadcast(:ok, section)
23
+ rescue ActiveRecord::RecordInvalid
24
+ broadcast(:invalid)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :form, :document
31
+
32
+ def update_section
33
+ @zone = Decidim.traceability.update!(
34
+ section,
35
+ form.current_user,
36
+ **attributes
37
+ )
38
+ end
39
+
40
+ def attributes
41
+ {
42
+ title: form.title
43
+ }.merge(document: document)
44
+ end
45
+
46
+ def section
47
+ @section ||= document.sections.find(form.id)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ # A command with all the business logic when a user updates a suggestion note.
7
+ class UpdateSuggestionNote < Decidim::Command
8
+ # Public: Initializes the command.
9
+ #
10
+ # form - A form object with the params.
11
+ # note - the suggestion note to update.
12
+ def initialize(notes_form, note)
13
+ @notes_form = notes_form
14
+ @note = note
15
+ end
16
+
17
+ def call
18
+ return broadcast(:invalid) if notes_form.invalid?
19
+
20
+ update_suggestion_note
21
+
22
+ broadcast(:ok, note)
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :notes_form, :note, :suggestion
28
+
29
+ def update_suggestion_note
30
+ note.body = notes_form.body
31
+ note.save!
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ class CreateSuggestion < Decidim::Command
6
+ include ::Decidim::AttachmentMethods
7
+
8
+ def initialize(form, suggestable)
9
+ @form = form
10
+ @suggestable = suggestable
11
+ end
12
+
13
+ def call
14
+ return broadcast(:invalid) if form.invalid?
15
+
16
+ begin
17
+ transaction do
18
+ create_suggestion
19
+ end
20
+ broadcast(:ok, suggestion)
21
+ rescue ActiveRecord::RecordInvalid => e
22
+ Rails.logger.info e.message
23
+ broadcast(:invalid, e.message)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :form, :suggestion, :suggestable
30
+
31
+ def create_suggestion
32
+ @suggestion = Decidim.traceability.create!(
33
+ Decidim::ParticipatoryDocuments::Suggestion,
34
+ form.current_user,
35
+ { body: { I18n.locale => form.body },
36
+ suggestable: suggestable,
37
+ author: form.current_user },
38
+ visibility: "public-only"
39
+ )
40
+
41
+ create_suggestion_attachment if form.file.present?
42
+ end
43
+
44
+ def create_suggestion_attachment
45
+ file = form.file
46
+ file_blob = ActiveStorage::Blob.create_after_upload!(
47
+ io: file.open,
48
+ filename: file.original_filename,
49
+ content_type: file.content_type
50
+ )
51
+
52
+ attachment = Decidim::Attachment.create!(
53
+ file: file_blob,
54
+ attached_to: suggestion,
55
+ content_type: file.content_type,
56
+ title: { I18n.locale => file.original_filename }
57
+ )
58
+
59
+ suggestion.file.attach(attachment.file.blob)
60
+
61
+ suggestion.save!
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryDocuments
5
+ module Admin
6
+ # This module adds custom javascript and css for the admin controllers related to participatory documents
7
+ module NeedsAdminSnippets
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ before_action :add_snippets
12
+
13
+ private
14
+
15
+ def add_snippets
16
+ return unless respond_to?(:snippets)
17
+
18
+ snippets.add(:head, helpers.stylesheet_pack_tag("decidim_participatory_documents_admin"))
19
+ snippets.add(:foot, helpers.javascript_pack_tag("decidim_participatory_documents_admin"))
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end