decidim-challenges 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +49 -0
  4. data/Rakefile +9 -0
  5. data/app/cells/decidim/challenges/challenge_cell.rb +21 -0
  6. data/app/cells/decidim/challenges/challenge_g/show.erb +47 -0
  7. data/app/cells/decidim/challenges/challenge_g_cell.rb +69 -0
  8. data/app/cells/decidim/problems/problem_cell.rb +21 -0
  9. data/app/cells/decidim/problems/problem_g/show.erb +35 -0
  10. data/app/cells/decidim/problems/problem_g_cell.rb +61 -0
  11. data/app/cells/decidim/solutions/solution_cell.rb +21 -0
  12. data/app/cells/decidim/solutions/solution_g/show.erb +30 -0
  13. data/app/cells/decidim/solutions/solution_g_cell.rb +84 -0
  14. data/app/commands/decidim/challenges/admin/create_challenge.rb +67 -0
  15. data/app/commands/decidim/challenges/admin/destroy_challenge.rb +49 -0
  16. data/app/commands/decidim/challenges/admin/export_challenge_surveys.rb +45 -0
  17. data/app/commands/decidim/challenges/admin/publish_challenge.rb +40 -0
  18. data/app/commands/decidim/challenges/admin/unpublish_challenge.rb +40 -0
  19. data/app/commands/decidim/challenges/admin/update_challenge.rb +72 -0
  20. data/app/commands/decidim/challenges/admin/update_surveys.rb +43 -0
  21. data/app/commands/decidim/challenges/survey_challenge.rb +67 -0
  22. data/app/commands/decidim/command_utils.rb +20 -0
  23. data/app/commands/decidim/problems/admin/create_problem.rb +66 -0
  24. data/app/commands/decidim/problems/admin/destroy_problem.rb +49 -0
  25. data/app/commands/decidim/problems/admin/publish_problem.rb +40 -0
  26. data/app/commands/decidim/problems/admin/unpublish_problem.rb +40 -0
  27. data/app/commands/decidim/problems/admin/update_problem.rb +69 -0
  28. data/app/commands/decidim/solutions/admin/create_solution.rb +65 -0
  29. data/app/commands/decidim/solutions/admin/destroy_solution.rb +43 -0
  30. data/app/commands/decidim/solutions/admin/publish_solution.rb +40 -0
  31. data/app/commands/decidim/solutions/admin/unpublish_solution.rb +40 -0
  32. data/app/commands/decidim/solutions/admin/update_solution.rb +67 -0
  33. data/app/commands/decidim/solutions/create_solution.rb +67 -0
  34. data/app/controllers/concerns/decidim/challenges/admin/filterable.rb +27 -0
  35. data/app/controllers/concerns/decidim/challenges/orderable_challenges.rb +37 -0
  36. data/app/controllers/concerns/decidim/problems/admin/filterable.rb +27 -0
  37. data/app/controllers/concerns/decidim/problems/orderable_problems.rb +37 -0
  38. data/app/controllers/concerns/decidim/solutions/admin/filterable.rb +27 -0
  39. data/app/controllers/concerns/decidim/solutions/orderable_solutions.rb +37 -0
  40. data/app/controllers/concerns/decidim/with_default_filters.rb +23 -0
  41. data/app/controllers/concerns/decidim/with_sdgs.rb +19 -0
  42. data/app/controllers/decidim/challenges/admin/application_controller.rb +15 -0
  43. data/app/controllers/decidim/challenges/admin/challenge_publications_controller.rb +53 -0
  44. data/app/controllers/decidim/challenges/admin/challenges_controller.rb +108 -0
  45. data/app/controllers/decidim/challenges/admin/survey_form_controller.rb +43 -0
  46. data/app/controllers/decidim/challenges/admin/surveys_controller.rb +104 -0
  47. data/app/controllers/decidim/challenges/application_controller.rb +13 -0
  48. data/app/controllers/decidim/challenges/challenges_controller.rb +70 -0
  49. data/app/controllers/decidim/challenges/surveys_controller.rb +61 -0
  50. data/app/controllers/decidim/problems/admin/application_controller.rb +15 -0
  51. data/app/controllers/decidim/problems/admin/problem_publications_controller.rb +53 -0
  52. data/app/controllers/decidim/problems/admin/problems_controller.rb +102 -0
  53. data/app/controllers/decidim/problems/application_controller.rb +13 -0
  54. data/app/controllers/decidim/problems/problems_controller.rb +62 -0
  55. data/app/controllers/decidim/sdgs/admin/application_controller.rb +15 -0
  56. data/app/controllers/decidim/sdgs/admin/sdgs_controller.rb +18 -0
  57. data/app/controllers/decidim/sdgs/application_controller.rb +13 -0
  58. data/app/controllers/decidim/sdgs/sdgs_controller.rb +24 -0
  59. data/app/controllers/decidim/solutions/admin/application_controller.rb +15 -0
  60. data/app/controllers/decidim/solutions/admin/solution_publications_controller.rb +53 -0
  61. data/app/controllers/decidim/solutions/admin/solutions_controller.rb +106 -0
  62. data/app/controllers/decidim/solutions/application_controller.rb +13 -0
  63. data/app/controllers/decidim/solutions/solutions_controller.rb +115 -0
  64. data/app/forms/decidim/challenges/admin/challenge_surveys_form.rb +35 -0
  65. data/app/forms/decidim/challenges/admin/challenges_form.rb +78 -0
  66. data/app/forms/decidim/problems/admin/problems_form.rb +90 -0
  67. data/app/forms/decidim/solutions/admin/solutions_form.rb +71 -0
  68. data/app/forms/decidim/solutions/solutions_form.rb +50 -0
  69. data/app/helpers/decidim/challenges/application_helper.rb +25 -0
  70. data/app/helpers/decidim/challenges/challenge_cells_helper.rb +57 -0
  71. data/app/helpers/decidim/challenges/challenges_helper.rb +39 -0
  72. data/app/helpers/decidim/problems/application_helper.rb +10 -0
  73. data/app/helpers/decidim/problems/problem_cells_helper.rb +23 -0
  74. data/app/helpers/decidim/problems/problems_helper.rb +24 -0
  75. data/app/helpers/decidim/sdgs/sdgs_helper.rb +28 -0
  76. data/app/helpers/decidim/show_filters_helper.rb +13 -0
  77. data/app/helpers/decidim/solutions/application_helper.rb +27 -0
  78. data/app/helpers/decidim/solutions/solution_cells_helper.rb +56 -0
  79. data/app/helpers/decidim/solutions/solutions_helper.rb +21 -0
  80. data/app/models/decidim/application_record.rb +8 -0
  81. data/app/models/decidim/challenges/challenge.rb +82 -0
  82. data/app/models/decidim/challenges/survey.rb +19 -0
  83. data/app/models/decidim/problems/problem.rb +118 -0
  84. data/app/models/decidim/sdgs/sdg.rb +47 -0
  85. data/app/models/decidim/solutions/application_record.rb +10 -0
  86. data/app/models/decidim/solutions/solution.rb +69 -0
  87. data/app/packs/entrypoints/decidim_challenges.js +4 -0
  88. data/app/packs/entrypoints/decidim_challenges.scss +1 -0
  89. data/app/packs/entrypoints/decidim_problems.js +1 -0
  90. data/app/packs/entrypoints/decidim_problems.scss +1 -0
  91. data/app/packs/entrypoints/decidim_sdgs.js +6 -0
  92. data/app/packs/entrypoints/decidim_sdgs.scss +3 -0
  93. data/app/packs/entrypoints/decidim_shared.js +1 -0
  94. data/app/packs/entrypoints/decidim_shared.scss +1 -0
  95. data/app/packs/entrypoints/decidim_solutions.js +4 -0
  96. data/app/packs/entrypoints/decidim_solutions.scss +1 -0
  97. data/app/packs/fonts/Oswald-Medium.ttf +0 -0
  98. data/app/packs/images/decidim/challenges/decidim_challenges_icon.svg +1 -0
  99. data/app/packs/images/decidim/sdgs/ods-01.svg +11 -0
  100. data/app/packs/images/decidim/sdgs/ods-02.svg +11 -0
  101. data/app/packs/images/decidim/sdgs/ods-03.svg +11 -0
  102. data/app/packs/images/decidim/sdgs/ods-04.svg +12 -0
  103. data/app/packs/images/decidim/sdgs/ods-05.svg +12 -0
  104. data/app/packs/images/decidim/sdgs/ods-06.svg +20 -0
  105. data/app/packs/images/decidim/sdgs/ods-07.svg +18 -0
  106. data/app/packs/images/decidim/sdgs/ods-08.svg +13 -0
  107. data/app/packs/images/decidim/sdgs/ods-09.svg +25 -0
  108. data/app/packs/images/decidim/sdgs/ods-10.svg +13 -0
  109. data/app/packs/images/decidim/sdgs/ods-11.svg +41 -0
  110. data/app/packs/images/decidim/sdgs/ods-12.svg +11 -0
  111. data/app/packs/images/decidim/sdgs/ods-13.svg +57 -0
  112. data/app/packs/images/decidim/sdgs/ods-14.svg +14 -0
  113. data/app/packs/images/decidim/sdgs/ods-15.svg +11 -0
  114. data/app/packs/images/decidim/sdgs/ods-16.svg +14 -0
  115. data/app/packs/images/decidim/sdgs/ods-17.svg +39 -0
  116. data/app/packs/images/decidim/sdgs/sdg-wheel.png +0 -0
  117. data/app/packs/images/decidim/sdgs/un_emblem_square.png +0 -0
  118. data/app/packs/src/decidim/challenges/add_challenge.js +3 -0
  119. data/app/packs/src/decidim/challenges/admin/challenges_form.js +3 -0
  120. data/app/packs/src/decidim/sdgs/filter.js +75 -0
  121. data/app/packs/stylesheets/decidim/challenges/challenges.scss +3 -0
  122. data/app/packs/stylesheets/decidim/problems/problems.scss +3 -0
  123. data/app/packs/stylesheets/decidim/sdgs/ods.scss +185 -0
  124. data/app/packs/stylesheets/decidim/sdgs/sdgs_filter/button.scss +27 -0
  125. data/app/packs/stylesheets/decidim/sdgs/sdgs_filter/modal.scss +60 -0
  126. data/app/packs/stylesheets/decidim/shared/_cards.scss +52 -0
  127. data/app/packs/stylesheets/decidim/shared/base.scss +9 -0
  128. data/app/packs/stylesheets/decidim/solutions/solutions.scss +3 -0
  129. data/app/permissions/decidim/challenges/admin/permissions.rb +88 -0
  130. data/app/permissions/decidim/challenges/permissions.rb +27 -0
  131. data/app/permissions/decidim/problems/admin/permissions.rb +52 -0
  132. data/app/permissions/decidim/problems/permissions.rb +16 -0
  133. data/app/permissions/decidim/solutions/admin/permissions.rb +58 -0
  134. data/app/permissions/decidim/solutions/permissions.rb +17 -0
  135. data/app/presenters/decidim/challenges/challenge_presenter.rb +134 -0
  136. data/app/presenters/decidim/problems/problem_presenter.rb +108 -0
  137. data/app/presenters/decidim/solutions/solution_presenter.rb +198 -0
  138. data/app/serializers/decidim/challenges/data_serializer.rb +46 -0
  139. data/app/serializers/decidim/challenges/survey_serializer.rb +37 -0
  140. data/app/types/decidim/challenges/challenge_type.rb +28 -0
  141. data/app/types/decidim/challenges/challenges_type.rb +32 -0
  142. data/app/types/decidim/problems/problem_type.rb +29 -0
  143. data/app/types/decidim/problems/problems_type.rb +32 -0
  144. data/app/types/decidim/solutions/solution_type.rb +25 -0
  145. data/app/types/decidim/solutions/solutions_type.rb +32 -0
  146. data/app/views/decidim/challenges/admin/challenges/_form.html.erb +78 -0
  147. data/app/views/decidim/challenges/admin/challenges/edit.html.erb +24 -0
  148. data/app/views/decidim/challenges/admin/challenges/index.html.erb +88 -0
  149. data/app/views/decidim/challenges/admin/challenges/new.html.erb +18 -0
  150. data/app/views/decidim/challenges/admin/surveys/_form.html.erb +9 -0
  151. data/app/views/decidim/challenges/admin/surveys/edit.html.erb +39 -0
  152. data/app/views/decidim/challenges/admin/surveys/index.html.erb +49 -0
  153. data/app/views/decidim/challenges/admin/surveys/show.html.erb +43 -0
  154. data/app/views/decidim/challenges/challenges/_challenge.html.erb +1 -0
  155. data/app/views/decidim/challenges/challenges/_challenges.html.erb +11 -0
  156. data/app/views/decidim/challenges/challenges/_related_problems.html.erb +14 -0
  157. data/app/views/decidim/challenges/challenges/_sidebar_data.html.erb +60 -0
  158. data/app/views/decidim/challenges/challenges/index.html.erb +29 -0
  159. data/app/views/decidim/challenges/challenges/index.js.erb +5 -0
  160. data/app/views/decidim/challenges/challenges/show.html.erb +41 -0
  161. data/app/views/decidim/problems/admin/problems/_form.html.erb +79 -0
  162. data/app/views/decidim/problems/admin/problems/edit.html.erb +24 -0
  163. data/app/views/decidim/problems/admin/problems/index.html.erb +93 -0
  164. data/app/views/decidim/problems/admin/problems/new.html.erb +18 -0
  165. data/app/views/decidim/problems/problems/_problem.html.erb +1 -0
  166. data/app/views/decidim/problems/problems/_problems.html.erb +11 -0
  167. data/app/views/decidim/problems/problems/_sidebar_data.html.erb +70 -0
  168. data/app/views/decidim/problems/problems/index.html.erb +28 -0
  169. data/app/views/decidim/problems/problems/index.js.erb +5 -0
  170. data/app/views/decidim/problems/problems/show.html.erb +38 -0
  171. data/app/views/decidim/sdgs/sdgs/_objectives.html.erb +320 -0
  172. data/app/views/decidim/sdgs/sdgs/_ods.html.erb +132 -0
  173. data/app/views/decidim/sdgs/sdgs/index.html.erb +64 -0
  174. data/app/views/decidim/sdgs/sdgs_filter/_filter_selector.html.erb +7 -0
  175. data/app/views/decidim/sdgs/sdgs_filter/_modal.html.erb +35 -0
  176. data/app/views/decidim/shared/_related_solutions.html.erb +14 -0
  177. data/app/views/decidim/solutions/admin/solutions/_documents.html.erb +13 -0
  178. data/app/views/decidim/solutions/admin/solutions/_form.html.erb +70 -0
  179. data/app/views/decidim/solutions/admin/solutions/_photos.html.erb +13 -0
  180. data/app/views/decidim/solutions/admin/solutions/edit.html.erb +24 -0
  181. data/app/views/decidim/solutions/admin/solutions/index.html.erb +97 -0
  182. data/app/views/decidim/solutions/admin/solutions/new.html.erb +18 -0
  183. data/app/views/decidim/solutions/admin/solutions/show.html.erb +114 -0
  184. data/app/views/decidim/solutions/solutions/_form.html.erb +22 -0
  185. data/app/views/decidim/solutions/solutions/_sidebar_data.html.erb +114 -0
  186. data/app/views/decidim/solutions/solutions/_solution.html.erb +1 -0
  187. data/app/views/decidim/solutions/solutions/_solutions.html.erb +13 -0
  188. data/app/views/decidim/solutions/solutions/index.html.erb +37 -0
  189. data/app/views/decidim/solutions/solutions/index.js.erb +5 -0
  190. data/app/views/decidim/solutions/solutions/new.html.erb +20 -0
  191. data/app/views/decidim/solutions/solutions/show.html.erb +72 -0
  192. data/config/assets.rb +27 -0
  193. data/config/i18n-tasks.yml +10 -0
  194. data/config/locales/ca.yml +1244 -0
  195. data/config/locales/cs.yml +668 -0
  196. data/config/locales/en.yml +1245 -0
  197. data/config/locales/es.yml +1250 -0
  198. data/config/locales/oc.yml +1229 -0
  199. data/db/migrate/20201014125000_create_decidim_challenges_challenges.rb +23 -0
  200. data/db/migrate/20201103155100_create_decidim_problems_problems.rb +25 -0
  201. data/db/migrate/20201116111200_create_decidim_solutions_solutions.rb +21 -0
  202. data/db/migrate/20210413083244_create_decidim_challenges_surveys.rb +14 -0
  203. data/db/migrate/20210413083507_add_survey_attributes_to_challenges.rb +7 -0
  204. data/db/migrate/20210413083604_add_questionnaire_to_existing_challenges.rb +15 -0
  205. data/db/migrate/20210413112229_add_challenge_reference_to_solutions.rb +7 -0
  206. data/db/migrate/20210427091033_remove_require_null_in_problems_for_solutions.rb +7 -0
  207. data/db/migrate/20220407110503_add_card_image_to_challenges.rb +7 -0
  208. data/db/migrate/20240919094714_add_public_fields_to_solutions.rb +10 -0
  209. data/lib/decidim/challenges/admin.rb +10 -0
  210. data/lib/decidim/challenges/admin_engine.rb +37 -0
  211. data/lib/decidim/challenges/component.rb +65 -0
  212. data/lib/decidim/challenges/engine.rb +39 -0
  213. data/lib/decidim/challenges/test/factories.rb +59 -0
  214. data/lib/decidim/challenges/version.rb +14 -0
  215. data/lib/decidim/challenges.rb +13 -0
  216. data/lib/decidim/problems/admin.rb +10 -0
  217. data/lib/decidim/problems/admin_engine.rb +25 -0
  218. data/lib/decidim/problems/component.rb +51 -0
  219. data/lib/decidim/problems/engine.rb +31 -0
  220. data/lib/decidim/problems/test/factories.rb +39 -0
  221. data/lib/decidim/sdgs/admin.rb +10 -0
  222. data/lib/decidim/sdgs/admin_engine.rb +28 -0
  223. data/lib/decidim/sdgs/component.rb +44 -0
  224. data/lib/decidim/sdgs/engine.rb +23 -0
  225. data/lib/decidim/sdgs/test/factories.rb +13 -0
  226. data/lib/decidim/solutions/admin.rb +10 -0
  227. data/lib/decidim/solutions/admin_engine.rb +25 -0
  228. data/lib/decidim/solutions/component.rb +52 -0
  229. data/lib/decidim/solutions/engine.rb +31 -0
  230. data/lib/decidim/solutions/test/factories.rb +28 -0
  231. metadata +316 -0
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Solutions
5
+ class SolutionsType < Decidim::Api::Types::BaseObject
6
+ implements Decidim::Core::ComponentInterface
7
+
8
+ graphql_name "Solutions"
9
+ description "A solutions component of a participatory space."
10
+
11
+ field :solutions, SolutionType.connection_type, null: true, connection: true
12
+
13
+ def solutions
14
+ SolutionsTypeHelper.base_scope(object).includes(:component)
15
+ end
16
+
17
+ field(:solution, SolutionType, null: true) do
18
+ argument :id, GraphQL::Types::ID, required: true
19
+ end
20
+
21
+ def solution(**args)
22
+ SolutionsTypeHelper.base_scope(object).find_by(id: args[:id])
23
+ end
24
+ end
25
+
26
+ module SolutionsTypeHelper
27
+ def self.base_scope(component)
28
+ Solution.where(component:).published
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,78 @@
1
+ <div class="form__wrapper">
2
+ <div class="card pt-4">
3
+ <div class="card-section">
4
+ <div class="row column hashtags__container">
5
+ <%= form.translated :text_field, :title, autofocus: true, class: "js-hashtags", hashtaggable: true, aria: { label: :title } %>
6
+ </div>
7
+
8
+ <div class="row column hashtags__container">
9
+ <%= form.translated :editor, :local_description %>
10
+ </div>
11
+
12
+ <div class="row column hashtags__container">
13
+ <%= form.translated :editor, :global_description %>
14
+ </div>
15
+
16
+ <div class="row column hashtags__container">
17
+ <%= form.text_field :tags %>
18
+ </div>
19
+
20
+ <div class="row column">
21
+ <%= scopes_select_field form, :decidim_scope_id, root: nil %>
22
+ </div>
23
+
24
+ <% if params[:component_id] %>
25
+ <% if Decidim::Component.where(participatory_space: Decidim::Component.find(params[:component_id]).participatory_space).pluck(:manifest_name).include? 'sdgs' %>
26
+ <div class="row column hashtags__container">
27
+ <%= form.select :sdg_code,
28
+ @form.select_sdg_collection,
29
+ selected: [t_sdg(@form.sdg_code), @form.sdg_code],
30
+ label: t("models.challenge.fields.sdg", scope: "decidim.challenges.admin") %>
31
+ </div>
32
+ <% end %>
33
+ <% end %>
34
+
35
+ <div class="row column">
36
+ <%= form.select :state,
37
+ @form.select_states_collection,
38
+ selected: [I18n.t(@form.try(:state), scope: 'decidim.challenges.states'), Decidim::Challenges::Challenge::states[@form.try(:state)]],
39
+ label: t("models.challenge.fields.state", scope: "decidim.challenges.admin") %>
40
+ </div>
41
+
42
+ <div class="row column hashtags__container">
43
+ <%= form.text_field :collaborating_entities %>
44
+ </div>
45
+
46
+ <div class="row column hashtags__container">
47
+ <%= form.text_field :coordinating_entities %>
48
+ </div>
49
+
50
+ <% if component_settings.allow_card_image? %>
51
+ <div class="card-divider">
52
+ <h2 class="card-title"><%= t(".images") %></h2>
53
+ </div>
54
+
55
+ <div class="row">
56
+ <div class="columns">
57
+ <%= form.upload :card_image, button_class: "button button__sm button__transparent-secondary" %>
58
+ </div>
59
+ </div>
60
+ <% end %>
61
+
62
+ <div class="card-divider">
63
+ <h2 class="card-title"><%= t(".duration") %></h2>
64
+ </div>
65
+
66
+ <div class="card-section">
67
+ <div class="row">
68
+ <div class="columns">
69
+ <%= form.date_field :start_date, autocomplete: "off" %>
70
+ </div>
71
+
72
+ <div class="columns">
73
+ <%= form.date_field :end_date, autocomplete: "off" %>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
@@ -0,0 +1,24 @@
1
+ <% add_decidim_page_title(t(".title")) %>
2
+ <div class="item_show__header">
3
+ <h1 class="item_show__header-title">
4
+ <%= t(".title") %>
5
+ </h1>
6
+ </div>
7
+ <div class="item__edit item__edit-1col">
8
+ <div class="item__edit-form">
9
+ <%= decidim_form_for(@form, html: { class: "form-defaults form edit_challenge challenge_form_admin" }) do |f| %>
10
+ <%= render partial: "form", object: f, locals: { title: t(".title") } %>
11
+ <div class="item__edit-sticky">
12
+ <div class="item__edit-sticky-container">
13
+ <%= f.submit t(".update"), class: "button button__sm button__secondary" %>
14
+
15
+ <% if challenge.published? %>
16
+ <%= link_to t("actions.unpublish", scope: "decidim.challenges.admin"), challenge_publish_path(challenge), method: :delete, class: "button button__sm button__secondary" %>
17
+ <% else %>
18
+ <%= link_to t("actions.publish", scope: "decidim.challenges.admin"), challenge_publish_path(challenge), method: :post, class: "button button__sm button__secondary" %>
19
+ <% end %>
20
+ </div>
21
+ </div>
22
+ <% end %>
23
+ </div>
24
+ </div>
@@ -0,0 +1,88 @@
1
+ <% add_decidim_page_title(t(".title")) %>
2
+ <div class="card">
3
+ <div class="item_show__header">
4
+ <h1 class="item_show__header-title">
5
+ <div>
6
+ <%= t(".title") %>
7
+ <span id="js-selected-challenges-count" class="component-counter component-counter--inline" title="<%= t("decidim.challenges.admin.challenges.index.selected") %>"></span>
8
+ </div>
9
+ <div class="flex items-center gap-x-4">
10
+ <% if allowed_to? :create, :challenge %>
11
+ <%= link_to t("actions.new_challenge", scope: "decidim.challenges.admin"),
12
+ new_challenge_path,
13
+ class: "button button__sm button__secondary" %>
14
+ <% end %>
15
+
16
+ <%= render partial: "decidim/admin/components/resource_action" %>
17
+ </div>
18
+ </h1>
19
+ </div>
20
+
21
+ <div class="table-scroll mt-16">
22
+ <table class="table-list">
23
+ <thead>
24
+ <tr>
25
+ <th>
26
+ <%= t("models.challenge.fields.title", scope: "decidim.challenges.admin") %>
27
+ </th>
28
+ <th>
29
+ <%= t("models.challenge.fields.created_at", scope: "decidim.challenges.admin") %>
30
+ </th>
31
+ <th>
32
+ <%= t("models.challenge.fields.state", scope: "decidim.challenges.admin") %>
33
+ </th>
34
+ <th>
35
+ <%= t("models.challenge.fields.start_date", scope: "decidim.challenges.admin") %>
36
+ </th>
37
+ <th>
38
+ <%= t("models.challenge.fields.end_date", scope: "decidim.challenges.admin") %>
39
+ </th>
40
+ <th>
41
+ <%= t("models.challenge.fields.published", scope: "decidim.challenges.admin") %>
42
+ </th>
43
+ <th class="actions"><%= t("actions.title", scope: "decidim.challenges.admin") %></th>
44
+ </tr>
45
+ </thead>
46
+ <tbody>
47
+ <% @challenges.each do |challenge| %>
48
+ <tr>
49
+ <td>
50
+ <%= translated_attribute(challenge.title) %>
51
+ </td>
52
+ <td>
53
+ <%= l(challenge.created_at, format: :decidim_short) if challenge.created_at %>
54
+ </td>
55
+ <td>
56
+ <%= I18n.t(challenge.state, scope: "decidim.challenges.states") %>
57
+ </td>
58
+ <td>
59
+ <%= challenge.start_date %>
60
+ </td>
61
+ <td>
62
+ <%= challenge.end_date %>
63
+ </td>
64
+ <td>
65
+ <% if challenge.published? %>
66
+ <strong class="text-success"><%= t("index.published", scope: "decidim.challenges") %></strong>
67
+ <% else %>
68
+ <strong class="text-alert"><%= t("index.not_published", scope: "decidim.challenges") %></strong>
69
+ <% end %>
70
+ </td>
71
+ <td class="table-list__actions">
72
+ <% if allowed_to? :edit, :challenge %>
73
+ <%= icon_link_to "pencil-line", edit_challenge_path(challenge), t("actions.configure", scope: "decidim.challenges.admin"), class: "action-icon--new" %>
74
+ <%= icon_link_to "group-line", edit_challenge_surveys_path(challenge), t("actions.survey", scope: "decidim.challenges.admin"), class: "action-icon--registrations" %>
75
+ <% end %>
76
+ <%= icon_link_to "eye-line", resource_locator(challenge).path, t("actions.view", scope: "decidim.challenges.admin"), class: "action-icon--preview", target: :blank %>
77
+ <% if allowed_to? :destroy, :challenge, challenge: challenge %>
78
+ <%= icon_link_to "close-circle-line", challenge, t("actions.destroy", scope: "decidim.challenges.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.challenges.admin", name: translated_attribute(challenge.title)) } %>
79
+ <% end %>
80
+ </td>
81
+ </tr>
82
+ <% end %>
83
+ </tbody>
84
+ </table>
85
+ </div>
86
+ </div>
87
+
88
+ <%= decidim_paginate @challenges %>
@@ -0,0 +1,18 @@
1
+ <% add_decidim_page_title(t(".title")) %>
2
+ <div class="item_show__header">
3
+ <h1 class="item_show__header-title">
4
+ <%= t(".title") %>
5
+ </h1>
6
+ </div>
7
+ <div class="item__edit item__edit-1col">
8
+ <div class="item__edit-form">
9
+ <%= decidim_form_for(@form, html: { class: "form-defaults form new_challenge challenge_form_admin" }) do |f| %>
10
+ <%= render partial: "form", object: f, locals: { title: t(".title") } %>
11
+ <div class="item__edit-sticky">
12
+ <div class="item__edit-sticky-container">
13
+ <%= f.submit t(".create"), class: "button button__sm button__secondary" %>
14
+ </div>
15
+ </div>
16
+ <% end %>
17
+ </div>
18
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="form__wrapper">
2
+ <div class="card pt-4">
3
+ <div class="card-section">
4
+ <div class="row column">
5
+ <%= form.check_box :survey_enabled %>
6
+ </div>
7
+ </div>
8
+ </div>
9
+ </div>
@@ -0,0 +1,39 @@
1
+ <% add_decidim_page_title(t("decidim.forms.admin.questionnaires.edit.title")) %>
2
+
3
+ <% if templates_defined? && choose_template? %>
4
+ <%= render partial: "decidim/templates/admin/questionnaire_templates/choose", locals: { target: questionnaire, form_title: t("decidim.forms.admin.questionnaires.edit.title") } %>
5
+ <% else %>
6
+ <div class="item_show__header">
7
+ <h1 class="item_show__header-title">
8
+ <%= edit_questionnaire_title %>
9
+
10
+ <%= link_to t("decidim.challenges.admin.surveys.form.edit"), edit_challenge_surveys_form_path(challenge_id: @challenge.id), class: "button button__sm button__secondary" %>
11
+ <% unless template? questionnaire.questionnaire_for %>
12
+ <% if allowed_to? :preview, :questionnaire %>
13
+ <%= link_to t("preview", scope: "decidim.forms.admin.questionnaires.form"), public_url, class: "button button__sm button__secondary", target: :_blank, data: { "external-link": false } %>
14
+ <% end %>
15
+ <% if questionnaire.answers.any? %>
16
+ <%= export_dropdown(current_component, questionnaire.id) if allowed_to? :export_answers, :questionnaire %>
17
+ <% if allowed_to? :show, :questionnaire_answers %>
18
+ <%= link_to t("actions.show", scope: "decidim.forms.admin.questionnaires"), questionnaire_participants_url, class: "button button__sm button__secondary new whitespace-nowrap" %>
19
+ <% end %>
20
+ <% else %>
21
+ <button class="button button__sm button__secondary whitespace-nowrap" disabled><%= t("empty", scope: "decidim.forms.admin.questionnaires.answers") %></button>
22
+ <% end %>
23
+ <% end %>
24
+ </h1>
25
+ </div>
26
+
27
+ <div class="item__edit item__edit-1col">
28
+ <div class="item__edit-form">
29
+ <%= decidim_form_for(@form, url: challenge_surveys_path, method: :put, html: { class: "form-defaults form edit_questionnaire" }) do |form| %>
30
+ <%= render partial: "form", object: form %>
31
+ <div class="item__edit-sticky">
32
+ <div class="item__edit-sticky-container">
33
+ <%= form.submit t(".save"), class: "button button__sm button__secondary" %>
34
+ </div>
35
+ </div>
36
+ <% end %>
37
+ </div>
38
+ </div>
39
+ <% end %>
@@ -0,0 +1,49 @@
1
+ <div class="card" id="answers">
2
+ <div class="item_show__header">
3
+ <h1 class="item_show__header-title">
4
+ <%= t ".title", total: @total %>
5
+ <%= link_to t("actions.back", scope: "decidim.forms.admin.questionnaires"), questionnaire_url, class: "button button__sm button__secondary new" %>
6
+ </h1>
7
+ </div>
8
+ <div class="table-scroll">
9
+ <table class="table-list">
10
+ <thead>
11
+ <tr>
12
+ <th>#</th>
13
+ <th><%= first_table_th(@participants.first) %></th>
14
+ <th><%= t("user_status", scope: "decidim.forms.user_answers_serializer") %></th>
15
+ <th><%= t("ip_hash", scope: "decidim.forms.user_answers_serializer") %></th>
16
+ <th><%= t("completion", scope: "decidim.forms.user_answers_serializer") %></th>
17
+ <th><%= t("created_at", scope: "decidim.forms.user_answers_serializer") %></th>
18
+ <th></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% @participants.each_with_index do |participant, idx| %>
23
+ <tr>
24
+ <td><%= idx + 1 + page_offset %></td>
25
+ <td>
26
+ <% if allowed_to? :show, :questionnaire_answers %>
27
+ <%= link_to first_table_td(participant), questionnaire_participant_answers_url(participant.session_token) %>
28
+ <% else %>
29
+ <%= first_table_td(participant) %></td>
30
+ <% end %>
31
+ <td><%= participant.status %></td>
32
+ <td><%= participant.ip_hash %></td>
33
+ <td><%= display_percentage(participant.completion) %></td>
34
+ <td><%= l participant.answered_at, format: :short %></td>
35
+ <td class="table-list__actions">
36
+ <% if allowed_to? :show, :questionnaire_answers %>
37
+ <%= icon_link_to "eye-line", questionnaire_participant_answers_url(participant.session_token), t("actions.show", scope: "decidim.forms.admin.questionnaires.answers"), class: "action-icon--eye" %>
38
+ <% end %>
39
+ <% if allowed_to? :export_response, :questionnaire_answers %>
40
+ <%= icon_link_to "download-line", questionnaire_export_response_url(participant.session_token), t("actions.export", scope: "decidim.forms.admin.questionnaires.answers"), class: "action-icon--data-transfer-download" %>
41
+ <% end %>
42
+ </td>
43
+ </tr>
44
+ <% end %>
45
+ </tbody>
46
+ </table>
47
+ <%= decidim_paginate @query %>
48
+ </div>
49
+ </div>
@@ -0,0 +1,43 @@
1
+ <div class="card" id="answers">
2
+ <div class="item_show__header">
3
+ <h1 class="item_show__header-title">
4
+ <%= t ".title", number: current_idx %>
5
+
6
+ <%= link_to t("actions.next", scope: "decidim.forms.admin.questionnaires.answers").html_safe, next_url, rel: "next", class: "button button__sm button__secondary next" unless last? %>
7
+ <%= link_to t("actions.previous", scope: "decidim.forms.admin.questionnaires.answers").html_safe, prev_url, rel: "prev", class: "button button__sm button__secondary prev" unless first? %>
8
+ <%= link_to t("actions.export", scope: "decidim.forms.admin.questionnaires.answers"), questionnaire_export_response_url(@participant.session_token), class: "button button__sm button__secondary export" %>
9
+ <%= link_to t("actions.back", scope: "decidim.forms.admin.questionnaires.answers"), questionnaire_participants_url, class: "button button__sm button__secondary back" %>
10
+ </h1>
11
+ </div>
12
+ <div class="card-section">
13
+ <div class="table">
14
+ <table class="table-list">
15
+ <thead>
16
+ <tr>
17
+ <th><%= t("session_token", scope: "decidim.forms.user_answers_serializer") %></th>
18
+ <th><%= t("user_status", scope: "decidim.forms.user_answers_serializer") %></th>
19
+ <th><%= t("ip_hash", scope: "decidim.forms.user_answers_serializer") %></th>
20
+ <th><%= t("completion", scope: "decidim.forms.user_answers_serializer") %></th>
21
+ <th><%= t("created_at", scope: "decidim.forms.user_answers_serializer") %></th>
22
+ <th></th>
23
+ </tr>
24
+ </thead>
25
+ <tbody>
26
+ <tr>
27
+ <td><%= @participant.session_token %></td>
28
+ <td><%= @participant.status %></td>
29
+ <td><%= @participant.ip_hash %></td>
30
+ <td><%= display_percentage(@participant.completion) %></td>
31
+ <td><%= l @participant.answered_at, format: :short %></td>
32
+ </tr>
33
+ </tbody>
34
+ </table>
35
+ </div>
36
+ <dl class="p-4 [&_ul]:list-disc [&_ul]:pl-4">
37
+ <% @participant.answers.each do |answer| %>
38
+ <dt class="font-semibold"><%= answer.question %></dt>
39
+ <dd><%= answer.body %></dd>
40
+ <% end %>
41
+ </dl>
42
+ </div>
43
+ </div>
@@ -0,0 +1 @@
1
+ <%= card_for challenge, highlight: true, size: :g %>
@@ -0,0 +1,11 @@
1
+ <% if @challenges.empty? %>
2
+ <%= cell("decidim/announcement", params[:filter].present? ? t(".empty_filters") : t(".empty")) %>
3
+ <% else %>
4
+ <h2 class="h5 md:h3 decorator"><%= t("decidim.challenges.challenges.count.challenges_count", count: @challenges.total_count) %></h2>
5
+
6
+ <%= order_selector available_orders, i18n_scope: "decidim.challenges.challenges.orders" %>
7
+
8
+ <%= render @challenges %>
9
+
10
+ <%= decidim_paginate @challenges %>
11
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <section id="problems">
2
+ <h2 class="h4 flex items-center gap-2 mb-4">
3
+ <%= resource_type_icon "Decidim::Amendment", class: "fill-tertiary w-6 h-6" %>
4
+ <%= t("decidim.problems.problems.count.problems_count", count: problems.count) %>
5
+ </h2>
6
+
7
+ <div id="problems-list">
8
+ <% problems.each do |problem| %>
9
+ <%= link_to resource_locator(problem).path, class: "card__link" do %>
10
+ <%= translated_attribute problem.title %>
11
+ <% end %>
12
+ <% end %>
13
+ </div>
14
+ </section>
@@ -0,0 +1,60 @@
1
+ <section class="layout-aside__section layout-aside__buttons mb-4">
2
+ <% if @challenge.survey_enabled %>
3
+ <%= link_to t('surveys.answer', scope: "decidim.challenges"), answer_challenge_survey_path(@challenge), class: "button button__lg w-full button__secondary" %>
4
+ <% end %>
5
+
6
+ <% if solutions_component&.settings&.creation_enabled? %>
7
+ <%= action_authorized_link_to :create, new_solution_path, class: "button button__lg w-full button__secondary", data: { "redirect_url": new_solution_path } do %>
8
+ <%= t("decidim.challenges.challenges.show.new_solution") %>
9
+ <% end %>
10
+ <% end %>
11
+ </section>
12
+
13
+ <div class="rounded p-4 bg-background mb-4 divide-y divide-gray-3 [&>*]:py-4 first:[&>*]:pt-0 last:[&>*]:pb-0">
14
+ <div class="text-gray-2 space-y-1.5">
15
+ <div class="text-sm flex flex-col items-center gap-1">
16
+ <p class="uppercase text-xs"><%= t("status", scope: "activemodel.attributes.challenge") %></p>
17
+ <p class="uppercase mb-4"><%= t(@challenge.state, scope: "decidim.challenges.states") %></p>
18
+ </div>
19
+
20
+ <% if @challenge_scope.present? %>
21
+ <div class="text-sm flex flex-col items-center gap-1">
22
+ <p class="uppercase text-xs"><%= t("scope", scope: "activemodel.attributes.challenge") %></p>
23
+ <p class="uppercase mb-4"><%= translated_attribute(@challenge_scope.name) %></p>
24
+ </div>
25
+ <% end %>
26
+
27
+ <% if @challenge.coordinating_entities.present? %>
28
+ <div class="text-sm flex flex-col items-center gap-1">
29
+ <p class="uppercase text-xs"><%= t("coordinating_entities", scope: "activemodel.attributes.challenge") %></p>
30
+ <p class="uppercase mb-4"><%= present(@challenge).coordinating_entities %></p>
31
+ </div>
32
+ <% end %>
33
+
34
+ <% if @challenge.collaborating_entities.present? %>
35
+ <div class="text-sm flex flex-col items-center gap-1">
36
+ <p class="uppercase text-xs"><%= t("collaborating_entities", scope: "activemodel.attributes.challenge") %></p>
37
+ <p class="uppercase mb-4"><%= present(@challenge).collaborating_entities %></p>
38
+ </div>
39
+ <% end %>
40
+ </div>
41
+
42
+ <% if has_sdgs? %>
43
+ <div class="text-sm flex flex-col items-center gap-1">
44
+ <p class="uppercase text-xs text-center"><%= t("sdg", scope: "activemodel.attributes.challenge") %></p>
45
+ <div class="ods challenges flex items-center">
46
+ <div class="text-container show">
47
+ <p><%= t(@sdg + ".logo.line1", scope: "decidim.components.sdgs") %></p>
48
+ <p><%= t(@sdg + ".logo.line2", scope: "decidim.components.sdgs") %></p>
49
+ </div>
50
+ <%= image_pack_tag "media/images/ods-#{@sdg_index}.svg", alt: "Logo ODS #{@sdg_index}", class: "challenge--view" %>
51
+ </div>
52
+ </div>
53
+ <% end %>
54
+ </div>
55
+
56
+ <section class="layout-aside__section actions__secondary">
57
+ <%= resource_reference(current_participatory_space) %>
58
+ <%= render partial: "decidim/shared/follow_button", class: "text-center", locals: { followable: current_participatory_space, large: false } %>
59
+ <%= cell "decidim/share_button", nil %>
60
+ </section>
@@ -0,0 +1,29 @@
1
+ <% add_decidim_page_title(t("name", scope: "decidim.components.challenges")) %>
2
+
3
+ <%= append_stylesheet_pack_tag "decidim_challenges" %>
4
+
5
+ <% content_for :aside do %>
6
+ <h1 id="challenges-count" class="title-decorator"><%= component_name %></h1>
7
+
8
+ <% unless @component_settings.hide_filters? %>
9
+ <%= render layout: "decidim/shared/filters", locals: { filter_sections:, search_variable: :search_text_cont, skip_to_id: "challenges" } do %>
10
+ <%= hidden_field_tag :order, order, id: nil, class: "order_filter" %>
11
+ <% end %>
12
+
13
+ <% if has_sdgs? %>
14
+ <%= filter_form_for filter do |form| %>
15
+ <%= sdgs_filter_selector(form) %>
16
+ <% end %>
17
+ <% end %>
18
+ <% end %>
19
+ <% end %>
20
+
21
+ <%= render layout: "layouts/decidim/shared/layout_two_col" do %>
22
+ <%= render partial: "decidim/shared/component_announcement" %>
23
+
24
+ <section id="challenges" class="layout-main__section layout-main__heading">
25
+ <%= render partial: "challenges" %>
26
+ </section>
27
+ <% end %>
28
+
29
+ <%= render partial: "decidim/sdgs/sdgs_filter/modal" %>
@@ -0,0 +1,5 @@
1
+ var $challenges = $('#challenges');
2
+ var $orderFilterInput = $('.order_filter');
3
+
4
+ $challenges.html('<%= j(render partial: "challenges").strip.html_safe %>');
5
+ $orderFilterInput.val('<%= order %>');
@@ -0,0 +1,41 @@
1
+ <%= append_stylesheet_pack_tag "decidim_sdgs" %>
2
+ <%= append_stylesheet_pack_tag "decidim_challenges" %>
3
+
4
+ <%= render layout: "layouts/decidim/shared/layout_item", locals: { back_path: challenges_path } do %>
5
+ <section class="layout-main__section layout-main__heading">
6
+ <h1 class="h2 decorator">
7
+ <%= present(@challenge).title(links: true, html_escape: true) %>
8
+ </h1>
9
+ </section>
10
+
11
+ <section class="layout-main__section content-block__description">
12
+ <%= render partial: "decidim/shared/share_modal" %>
13
+
14
+ <h3 class="h4"><%= t("local_description", scope: "activemodel.attributes.challenge") %></h3>
15
+ <div class="rich-text-display">
16
+ <p><%= present(@challenge).local_description %></p>
17
+ </div>
18
+
19
+ <h3 class="h4"><%= t("global_description", scope: "activemodel.attributes.challenge") %></h3>
20
+ <div class="rich-text-display">
21
+ <p><%= present(@challenge).global_description %></p>
22
+ </div>
23
+
24
+ <% if present(@challenge).tags.present? %>
25
+ <h3 class="h4"><%= t("tags", scope: "activemodel.attributes.challenge") %></h3>
26
+ <p class="tags"><%= present(@challenge).tags %></p>
27
+ <% end %>
28
+
29
+ <% if @challenge.problems.present? %>
30
+ <%= render partial: "related_problems", locals: {problems: @challenge.problems} %>
31
+ <% end %>
32
+
33
+ <% if challenge_associated_solutions(@challenge).present? %>
34
+ <%= render partial: "decidim/shared/related_solutions", locals: {solutions: challenge_associated_solutions(@challenge)} %>
35
+ <% end %>
36
+ </section>
37
+
38
+ <% content_for :aside do %>
39
+ <%= render partial: "sidebar_data" %>
40
+ <% end %>
41
+ <% end %>
@@ -0,0 +1,79 @@
1
+ <div class="form__wrapper">
2
+ <div class="card pt-4">
3
+ <div class="card-section">
4
+ <div class="row column hashtags__container">
5
+ <%= form.translated :text_field, :title, autofocus: true, class: "js-hashtags", hashtaggable: true, aria: { label: :title } %>
6
+ </div>
7
+
8
+ <div class="row column hashtags__container">
9
+ <%= form.translated :editor, :description %>
10
+ </div>
11
+
12
+ <div class="row column hashtags__container">
13
+ <%= form.text_field :tags %>
14
+ </div>
15
+
16
+ <div class="row column hashtags__container">
17
+ <%= form.text_field :causes %>
18
+ </div>
19
+
20
+ <div class="row column hashtags__container">
21
+ <%= form.text_field :groups_affected %>
22
+ </div>
23
+
24
+ <div class="row column">
25
+ <%= scopes_select_field form, :decidim_sectorial_scope_id, root: nil %>
26
+ </div>
27
+
28
+ <div class="row column">
29
+ <%= scopes_select_field form, :decidim_technological_scope_id, root: nil %>
30
+ </div>
31
+
32
+ <div class="row column">
33
+ <%= form.select :state,
34
+ @form.select_states_collection,
35
+ selected: [I18n.t(@form.try(:state), scope: 'decidim.problems.states'), Decidim::Problems::Problem::states[@form.try(:state)]],
36
+ label: t("models.problem.fields.state", scope: "decidim.problems.admin") %>
37
+ </div>
38
+
39
+ <div class="row column hashtags__container">
40
+ <%= form.text_field :proposing_entities %>
41
+ </div>
42
+
43
+ <div class="row column hashtags__container">
44
+ <%= form.text_field :collaborating_entities %>
45
+ </div>
46
+ </div>
47
+
48
+ <div class="card-divider">
49
+ <h2 class="card-title"><%= t(".challenge") %></h2>
50
+ </div>
51
+
52
+ <div class="card-section">
53
+
54
+ <div class="row column">
55
+ <%= form.select :decidim_challenges_challenge_id,
56
+ @form.select_challenge_collection,
57
+ selected: @form.try(:decidim_challenges_challenge_id) ? [translated_attribute(Decidim::Challenges::Challenge.find(@form.try(:decidim_challenges_challenge_id)).title), @form.try(:decidim_challenges_challenge_id)] : '',
58
+ label: t("models.problem.fields.challenge", scope: "decidim.problems.admin"),
59
+ include_blank: "" %>
60
+ </div>
61
+ </div>
62
+
63
+ <div class="card-divider">
64
+ <h2 class="card-title"><%= t(".duration") %></h2>
65
+ </div>
66
+
67
+ <div class="card-section">
68
+ <div class="row">
69
+ <div class="columns xlarge-6">
70
+ <%= form.date_field :start_date, autocomplete: "off" %>
71
+ </div>
72
+
73
+ <div class="columns xlarge-6">
74
+ <%= form.date_field :end_date, autocomplete: "off" %>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>