decidim-initiatives 0.19.1 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -0
  3. data/app/assets/config/admin_decidim_initiatives_manifest.js +2 -1
  4. data/app/assets/images/decidim/gamification/badges/initiatives.svg +1 -87
  5. data/app/assets/images/decidim/initiatives/icon.svg +1 -3
  6. data/app/assets/javascripts/decidim/initiatives/admin/initiatives_types.js.es6 +38 -0
  7. data/app/assets/stylesheet/decidim/initiatives/initiatives-votes.css.scss +0 -1
  8. data/app/assets/stylesheet/decidim/initiatives/initiatives.scss +6 -8
  9. data/app/assets/stylesheet/decidim/initiatives/popularity_item.css.scss +0 -1
  10. data/app/assets/stylesheet/decidim/initiatives/print-initiative.css.scss +0 -3
  11. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +4 -3
  12. data/app/cells/decidim/initiatives/initiative_m/footer.erb +1 -1
  13. data/app/cells/decidim/initiatives/initiative_m_cell.rb +25 -0
  14. data/app/cells/decidim/initiatives_votes/vote/show.erb +12 -9
  15. data/app/cells/decidim/initiatives_votes/vote_cell.rb +7 -0
  16. data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +8 -2
  17. data/app/commands/decidim/initiatives/admin/send_initiative_to_technical_validation.rb +17 -0
  18. data/app/commands/decidim/initiatives/admin/update_initiative.rb +29 -10
  19. data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +10 -6
  20. data/app/commands/decidim/initiatives/attachment_methods.rb +37 -0
  21. data/app/commands/decidim/initiatives/create_initiative.rb +25 -3
  22. data/app/commands/decidim/initiatives/unvote_initiative.rb +4 -10
  23. data/app/commands/decidim/initiatives/vote_initiative.rb +47 -31
  24. data/app/controllers/concerns/decidim/initiatives/admin/filterable.rb +51 -0
  25. data/app/controllers/concerns/decidim/initiatives/orderable.rb +3 -1
  26. data/app/controllers/concerns/decidim/initiatives/single_initiative_type.rb +26 -0
  27. data/app/controllers/decidim/initiatives/admin/answers_controller.rb +2 -3
  28. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +28 -15
  29. data/app/controllers/decidim/initiatives/create_initiative_controller.rb +43 -9
  30. data/app/controllers/decidim/initiatives/initiative_signatures_controller.rb +19 -23
  31. data/app/controllers/decidim/initiatives/initiative_votes_controller.rb +11 -5
  32. data/app/controllers/decidim/initiatives/initiatives_controller.rb +28 -13
  33. data/app/controllers/decidim/initiatives/initiatives_type_scopes_controller.rb +9 -1
  34. data/app/controllers/decidim/initiatives/versions_controller.rb +20 -0
  35. data/app/controllers/decidim/initiatives/{initiative_widgets_controller.rb → widgets_controller.rb} +2 -2
  36. data/app/events/decidim/initiatives/admin/initiative_sent_to_technical_validation_event.rb +21 -0
  37. data/app/events/decidim/initiatives/admin/support_threshold_reached_event.rb +13 -0
  38. data/app/forms/decidim/initiatives/admin/initiative_form.rb +50 -8
  39. data/app/forms/decidim/initiatives/admin/initiative_type_form.rb +28 -6
  40. data/app/forms/decidim/initiatives/admin/initiative_type_scope_form.rb +0 -1
  41. data/app/forms/decidim/initiatives/initiative_form.rb +69 -2
  42. data/app/forms/decidim/initiatives/vote_form.rb +133 -76
  43. data/app/helpers/decidim/initiatives/application_helper.rb +104 -0
  44. data/app/helpers/decidim/initiatives/create_initiative_helper.rb +10 -11
  45. data/app/helpers/decidim/initiatives/initiative_helper.rb +13 -0
  46. data/app/helpers/decidim/initiatives/initiatives_helper.rb +10 -0
  47. data/app/jobs/decidim/initiatives/export_initiatives_job.rb +25 -0
  48. data/app/mailers/decidim/initiatives/initiatives_mailer.rb +0 -21
  49. data/app/models/concerns/decidim/initiatives/has_area.rb +30 -0
  50. data/app/models/decidim/initiative.rb +200 -51
  51. data/app/models/decidim/initiatives_type.rb +14 -14
  52. data/app/models/decidim/initiatives_type_scope.rb +9 -2
  53. data/app/models/decidim/initiatives_vote.rb +19 -23
  54. data/app/permissions/decidim/initiatives/admin/permissions.rb +21 -10
  55. data/app/permissions/decidim/initiatives/permissions.rb +38 -14
  56. data/app/presenters/decidim/initiatives/initiative_stats_presenter.rb +1 -5
  57. data/app/queries/decidim/initiatives/admin/manageable_initiatives.rb +7 -39
  58. data/app/serializers/decidim/initiatives/initiative_serializer.rb +32 -0
  59. data/app/services/decidim/initiatives/diff_renderer.rb +18 -0
  60. data/app/services/decidim/initiatives/initiative_search.rb +59 -15
  61. data/app/services/decidim/initiatives/status_change_notifier.rb +4 -5
  62. data/app/types/decidim/initiatives/initiative_api_type.rb +26 -0
  63. data/app/types/decidim/initiatives/initiative_committee_member_type.rb +18 -0
  64. data/app/types/decidim/initiatives/initiative_type.rb +42 -0
  65. data/app/views/decidim/initiatives/admin/answers/_info_initiative.html.erb +1 -1
  66. data/app/views/decidim/initiatives/admin/exports/_dropdown.html.erb +8 -0
  67. data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +60 -15
  68. data/app/views/decidim/initiatives/admin/initiatives/_initiative_attachments.erb +43 -0
  69. data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb +12 -9
  70. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +10 -45
  71. data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +55 -12
  72. data/app/views/decidim/initiatives/admin/initiatives_types/_initiative_type_scopes.html.erb +28 -25
  73. data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +61 -16
  74. data/app/views/decidim/initiatives/create_initiative/finish.html.erb +17 -10
  75. data/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +2 -1
  76. data/app/views/decidim/initiatives/create_initiative/promotal_committee.html.erb +1 -1
  77. data/app/views/decidim/initiatives/create_initiative/select_initiative_type.html.erb +1 -2
  78. data/app/views/decidim/initiatives/create_initiative/show_similar_initiatives.html.erb +1 -1
  79. data/app/views/decidim/initiatives/initiative_signatures/fill_personal_data.html.erb +1 -1
  80. data/app/views/decidim/initiatives/initiative_signatures/update_buttons_and_counters.js.erb +1 -1
  81. data/app/views/decidim/initiatives/initiative_votes/update_buttons_and_counters.js.erb +1 -1
  82. data/app/views/decidim/initiatives/initiatives/_author.html.erb +1 -1
  83. data/app/views/decidim/initiatives/initiatives/_filters.html.erb +16 -28
  84. data/app/views/decidim/initiatives/initiatives/_index_header.html.erb +39 -5
  85. data/app/views/decidim/initiatives/initiatives/_initiatives.html.erb +11 -1
  86. data/app/views/decidim/initiatives/initiatives/_interactions.html.erb +2 -3
  87. data/app/views/decidim/initiatives/initiatives/_progress_bar.html.erb +24 -9
  88. data/app/views/decidim/initiatives/initiatives/_tags.html.erb +4 -1
  89. data/app/views/decidim/initiatives/initiatives/_vote_cabin.html.erb +1 -13
  90. data/app/views/decidim/initiatives/initiatives/index.html.erb +1 -1
  91. data/app/views/decidim/initiatives/initiatives/show.html.erb +5 -6
  92. data/app/views/decidim/initiatives/initiatives_type_scopes/search.html.erb +1 -1
  93. data/app/views/decidim/initiatives/versions/index.html.erb +8 -0
  94. data/app/views/decidim/initiatives/versions/show.html.erb +10 -0
  95. data/app/views/layouts/decidim/_initiative_creation_header.html.erb +3 -1
  96. data/app/views/layouts/decidim/_initiative_header.html.erb +2 -1
  97. data/app/views/layouts/decidim/_initiative_signature_creation_header.html.erb +1 -1
  98. data/app/views/layouts/decidim/admin/initiative.html.erb +1 -1
  99. data/app/views/layouts/decidim/initiative.html.erb +1 -0
  100. data/app/views/layouts/decidim/initiative_creation.html.erb +1 -2
  101. data/app/views/layouts/decidim/initiative_signature_creation.html.erb +2 -2
  102. data/config/locales/am-ET.yml +1 -0
  103. data/config/locales/ar.yml +17 -21
  104. data/config/locales/bg-BG.yml +13 -0
  105. data/config/locales/bg.yml +13 -0
  106. data/config/locales/ca.yml +101 -22
  107. data/config/locales/cs.yml +111 -32
  108. data/config/locales/da-DK.yml +1 -0
  109. data/config/locales/da.yml +1 -0
  110. data/config/locales/de.yml +75 -21
  111. data/config/locales/el-GR.yml +1 -0
  112. data/config/locales/el.yml +525 -0
  113. data/config/locales/en.yml +103 -24
  114. data/config/locales/eo.yml +1 -0
  115. data/config/locales/es-MX.yml +100 -21
  116. data/config/locales/es-PY.yml +100 -21
  117. data/config/locales/es.yml +104 -25
  118. data/config/locales/et-EE.yml +1 -0
  119. data/config/locales/et.yml +1 -0
  120. data/config/locales/eu.yml +4 -21
  121. data/config/locales/fi-plain.yml +100 -21
  122. data/config/locales/fi.yml +118 -39
  123. data/config/locales/fr-CA.yml +557 -0
  124. data/config/locales/fr.yml +102 -23
  125. data/config/locales/ga-IE.yml +1 -0
  126. data/config/locales/gl.yml +4 -21
  127. data/config/locales/hr-HR.yml +1 -0
  128. data/config/locales/hr.yml +1 -0
  129. data/config/locales/hu.yml +31 -24
  130. data/config/locales/id-ID.yml +4 -21
  131. data/config/locales/is-IS.yml +251 -0
  132. data/config/locales/is.yml +251 -0
  133. data/config/locales/it.yml +117 -61
  134. data/config/locales/ja-JP.yml +529 -0
  135. data/config/locales/ja.yml +549 -0
  136. data/config/locales/ko-KR.yml +1 -0
  137. data/config/locales/ko.yml +1 -0
  138. data/config/locales/lt-LT.yml +1 -0
  139. data/config/locales/lt.yml +1 -0
  140. data/config/locales/lv.yml +525 -0
  141. data/config/locales/mt-MT.yml +1 -0
  142. data/config/locales/mt.yml +1 -0
  143. data/config/locales/nl.yml +77 -21
  144. data/config/locales/no.yml +368 -9
  145. data/config/locales/om-ET.yml +1 -0
  146. data/config/locales/pl.yml +260 -189
  147. data/config/locales/pt-BR.yml +5 -22
  148. data/config/locales/pt.yml +231 -179
  149. data/config/locales/ro-RO.yml +533 -0
  150. data/config/locales/ru.yml +4 -21
  151. data/config/locales/sk-SK.yml +468 -0
  152. data/config/locales/sk.yml +458 -0
  153. data/config/locales/sl.yml +24 -0
  154. data/config/locales/so-SO.yml +1 -0
  155. data/config/locales/sr-CS.yml +8 -0
  156. data/config/locales/sv.yml +102 -31
  157. data/config/locales/ti-ER.yml +1 -0
  158. data/config/locales/tr-TR.yml +4 -21
  159. data/config/locales/uk.yml +4 -21
  160. data/config/locales/vi-VN.yml +1 -0
  161. data/config/locales/vi.yml +1 -0
  162. data/config/locales/zh-CN.yml +549 -0
  163. data/config/locales/zh-TW.yml +1 -0
  164. data/db/migrate/20190925145648_add_promoting_committee_option.rb +7 -0
  165. data/db/migrate/20191002082220_move_signature_type_to_initative_type.rb +38 -0
  166. data/db/migrate/20191106144259_add_settings_to_initiatives_types.rb +8 -0
  167. data/db/migrate/20191107134847_add_scopes_to_initiatives_votes.rb +28 -0
  168. data/db/migrate/20191116170841_allow_multiple_initiative_votes_counter_caches.rb +32 -0
  169. data/db/migrate/20191118105634_allow_multiple_offline_votes.rb +34 -0
  170. data/db/migrate/20200320105920_index_foreign_keys_in_decidim_initiatives.rb +8 -0
  171. data/db/migrate/20200320105921_index_foreign_keys_in_decidim_initiatives_votes.rb +8 -0
  172. data/db/migrate/20200417120551_add_custom_signature_end_time_option.rb +7 -0
  173. data/db/migrate/20200424110930_add_attachments_enabled_option.rb +7 -0
  174. data/db/migrate/20200514085422_add_area_to_initiatives.rb +7 -0
  175. data/db/migrate/20200514102631_add_area_enabled_option_to_initiatives.rb +7 -0
  176. data/db/migrate/20200528151456_remove_user_groups_from_initiative_votes.rb +7 -0
  177. data/db/migrate/20200827154214_add_commentable_counter_cache_to_initiatives.rb +9 -0
  178. data/db/seeds/city.jpeg +0 -0
  179. data/db/seeds/city2.jpeg +0 -0
  180. data/lib/decidim/api/initiative_type_interface.rb +13 -0
  181. data/lib/decidim/initiatives.rb +0 -14
  182. data/lib/decidim/initiatives/admin_engine.rb +6 -1
  183. data/lib/decidim/initiatives/api.rb +7 -0
  184. data/lib/decidim/initiatives/engine.rb +11 -2
  185. data/lib/decidim/initiatives/participatory_space.rb +20 -1
  186. data/lib/decidim/initiatives/query_extensions.rb +40 -0
  187. data/lib/decidim/initiatives/test/factories.rb +69 -8
  188. data/lib/decidim/initiatives/version.rb +1 -1
  189. data/lib/tasks/decidim_initiatives.rake +1 -3
  190. metadata +96 -20
  191. data/app/views/decidim/initiatives/initiative_widgets/show.html.erb +0 -4
  192. data/app/views/decidim/initiatives/initiatives/_supports.html.erb +0 -22
  193. data/app/views/decidim/initiatives/initiatives/signature_identities.html.erb +0 -42
  194. data/app/views/decidim/initiatives/initiatives_mailer/notify_validating_request.html.erb +0 -3
@@ -16,7 +16,9 @@ module Decidim
16
16
  def base_query
17
17
  Decidim::Initiative
18
18
  .includes(scoped_type: [:scope])
19
+ .joins("JOIN decidim_users ON decidim_users.id = decidim_initiatives.decidim_author_id")
19
20
  .where(organization: options[:organization])
21
+ .published
20
22
  end
21
23
 
22
24
  # Handle the search_text filter
@@ -29,22 +31,38 @@ module Decidim
29
31
  "%#{search_text}%"
30
32
  )
31
33
  )
34
+ .or(
35
+ query.where(
36
+ "cast(decidim_initiatives.id as text) ILIKE ?", "%#{search_text}%"
37
+ )
38
+ )
39
+ .or(
40
+ query.where(
41
+ "decidim_users.name ILIKE ? OR decidim_users.nickname ILIKE ?", "%#{search_text}%", "%#{search_text}%"
42
+ )
43
+ )
32
44
  end
33
45
 
34
46
  # Handle the state filter
35
47
  def search_state
36
- case state
37
- when "closed"
38
- query.closed
39
- else # Assume open
40
- query.open
41
- end
48
+ accepted = state.member?("accepted") ? query.accepted : nil
49
+ rejected = state.member?("rejected") ? query.rejected : nil
50
+ answered = state.member?("answered") ? query.answered : nil
51
+ open = state.member?("open") ? query.open : nil
52
+ closed = state.member?("closed") ? query.closed : nil
53
+
54
+ query
55
+ .where(id: accepted)
56
+ .or(query.where(id: rejected))
57
+ .or(query.where(id: answered))
58
+ .or(query.where(id: open))
59
+ .or(query.where(id: closed))
42
60
  end
43
61
 
44
- def search_type
45
- return query if type == "all"
62
+ def search_type_id
63
+ return query if type_ids.include?("all")
46
64
 
47
- types = InitiativesTypeScope.where(decidim_initiatives_types_id: type).pluck(:id)
65
+ types = InitiativesTypeScope.where(decidim_initiatives_types_id: type_ids).pluck(:id)
48
66
 
49
67
  query.where(scoped_type: types)
50
68
  end
@@ -58,13 +76,39 @@ module Decidim
58
76
  end
59
77
 
60
78
  def search_scope_id
61
- return if scope_id.nil?
79
+ return query if scope_ids.include?("all")
62
80
 
63
- query
64
- .joins(:scoped_type)
65
- .where(
66
- "decidim_initiatives_type_scopes.decidim_scopes_id": scope_id
67
- )
81
+ clean_scope_ids = scope_ids
82
+
83
+ conditions = []
84
+ conditions << "decidim_initiatives_type_scopes.decidim_scopes_id IS NULL" if clean_scope_ids.delete("global")
85
+ conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any?
86
+
87
+ query.joins(:scoped_type).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i))
88
+ end
89
+
90
+ def search_area_id
91
+ return query if area_ids.include?("all")
92
+
93
+ query.where(decidim_area_id: area_ids)
94
+ end
95
+
96
+ private
97
+
98
+ # Private: Returns an array with checked type ids.
99
+ def type_ids
100
+ [type_id].flatten
101
+ end
102
+
103
+ # Private: Returns an array with checked scope ids.
104
+ def scope_ids
105
+ [scope_id].flatten
106
+ end
107
+
108
+ # Private: Returns an array with checked area ids, handling area_types which are coded as its
109
+ # areas ids joined by _.
110
+ def area_ids
111
+ area_id.map { |id| id.split("_") }.flatten.uniq
68
112
  end
69
113
  end
70
114
  end
@@ -38,12 +38,11 @@ module Decidim
38
38
  .deliver_later
39
39
  end
40
40
 
41
+ # Does nothing
41
42
  def notify_validating_initiative
42
- initiative.organization.admins.each do |user|
43
- Decidim::Initiatives::InitiativesMailer
44
- .notify_validating_request(initiative, user)
45
- .deliver_later
46
- end
43
+ # It has been moved into SendInitiativeToTechnicalValidation command as a standard notification
44
+ # It would be great to move the functionality of this class, which is invoked on Initiative#after_save,
45
+ # to the corresponding commands to follow the architecture of Decidim.
47
46
  end
48
47
 
49
48
  def notify_validating_result
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ InitiativeApiType = GraphQL::ObjectType.define do
6
+ name "InitiativeType"
7
+ description "An initiative type"
8
+
9
+ field :id, !types.ID, "The internal ID for this initiative type"
10
+ field :title, Decidim::Core::TranslatedFieldType, "Initiative type name"
11
+ field :description, Decidim::Core::TranslatedFieldType, "This is the initiative type description"
12
+ field :createdAt, Decidim::Core::DateTimeType, "The date this initiative type was created", property: :created_at
13
+ field :updatedAt, Decidim::Core::DateTimeType, "The date this initiative type was updated", property: :updated_at
14
+ field :bannerImage, types.String, "Banner image", property: :banner_image
15
+ field :collectUserExtraFields, types.Boolean, "Collect participant personal data on signature", property: :collect_user_extra_fields
16
+ field :extraFieldsLegalInformation, types.String, "Legal information about the collection of personal data", property: :extra_fields_legal_information
17
+ field :minimumCommitteeMembers, types.Int, "Minimum of committee members", property: :minimum_committee_members
18
+ field :validateSmsCodeOnVotes, types.Boolean, "Add SMS code validation step to signature process", property: :validate_sms_code_on_votes
19
+ field :undoOnlineSignaturesEnabled, types.Boolean, "Enable participants to undo their online signatures", property: :undo_online_signatures_enabled
20
+ field :promotingComitteeEnabled, types.Boolean, "If promoting committee is enabled", property: :promoting_committee_enabled
21
+ field :signatureType, types.String, "Signature type of the initiative", property: :signature_type
22
+
23
+ field :initiatives, !types[Decidim::Initiatives::InitiativeType], "The initiatives that have this type"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ # This type represents a initiative committee member.
6
+ InitiativeCommitteeMemberType = GraphQL::ObjectType.define do
7
+ name "InitiativeCommitteeMemberType"
8
+ description "A initiative committee member"
9
+
10
+ field :id, !types.ID, "Internal ID for this member of the committee"
11
+ field :user, Decidim::Core::UserType, "The decidim user for this initiative committee member"
12
+
13
+ field :state, types.Int, "Type of the committee member"
14
+ field :createdAt, Decidim::Core::DateTimeType, "The date this initiative committee member was created", property: :created_at
15
+ field :updatedAt, Decidim::Core::DateTimeType, "The date this initiative committee member was updated", property: :updated_at
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ # This type represents a Initiative.
6
+ InitiativeType = GraphQL::ObjectType.define do
7
+ interfaces [
8
+ -> { Decidim::Core::ParticipatorySpaceInterface },
9
+ -> { Decidim::Core::ScopableInterface },
10
+ -> { Decidim::Core::AttachableInterface },
11
+ -> { Decidim::Core::AuthorInterface },
12
+ -> { Decidim::Initiatives::InitiativeTypeInterface }
13
+ ]
14
+
15
+ name "Initiative"
16
+ description "A initiative"
17
+
18
+ field :description, Decidim::Core::TranslatedFieldType, "The description of this initiative."
19
+ field :slug, !types.String
20
+ field :hashtag, types.String, "The hashtag for this initiative"
21
+ field :createdAt, !Decidim::Core::DateTimeType, "The time this initiative was created", property: :created_at
22
+ field :updatedAt, !Decidim::Core::DateTimeType, "The time this initiative was updated", property: :updated_at
23
+ field :publishedAt, !Decidim::Core::DateTimeType, "The time this initiative was published", property: :published_at
24
+ field :reference, !types.String, "Reference prefix for this initiative"
25
+ field :state, types.String, "Current status of the initiative"
26
+ field :signatureType, types.String, "Signature type of the initiative", property: :signature_type
27
+ field :signatureStartDate, !Decidim::Core::DateType, "The signature start date", property: :signature_start_date
28
+ field :signatureEndDate, !Decidim::Core::DateType, "The signature end date", property: :signature_end_date
29
+ field :offlineVotes, types.Int, "The number of offline votes in this initiative", property: :offline_votes
30
+ field :initiativeVotesCount, types.Int, "The number of votes in this initiative", property: :initiative_votes_count
31
+ field :initiativeSupportsCount, types.Int, "The number of supports in this initiative", property: :initiative_supports_count
32
+
33
+ field :author, !Decidim::Core::AuthorInterface, "The initiative author" do
34
+ resolve lambda { |obj, _args, _ctx|
35
+ obj.user_group || obj.author
36
+ }
37
+ end
38
+
39
+ field :committeeMembers, types[Decidim::Initiatives::InitiativeCommitteeMemberType], property: :committee_members
40
+ end
41
+ end
42
+ end
@@ -17,7 +17,7 @@
17
17
  <strong><%= t ".state" %>: </strong> <%= I18n.t(initiative.state, scope: "decidim.initiatives.admin_states") %>
18
18
  </div>
19
19
  <div class="row column">
20
- <strong><%= t ".initiative_votes_count" %>: </strong> <%= initiative.initiative_votes_count %>
20
+ <strong><%= t ".initiative_votes_count" %>: </strong> <%= initiative.online_votes_count %>
21
21
  </div>
22
22
  </div>
23
23
  </div>
@@ -0,0 +1,8 @@
1
+ <span class="exports dropdown tiny button button--simple" data-toggle="export-dropdown"><%= t "actions.export", scope: "decidim.admin" %></span>
2
+ <div class="dropdown-pane" id="export-dropdown" data-dropdown data-position=bottom data-alignment=right data-auto-focus="true" data-close-on-click="true">
3
+ <ul class="vertical menu add-components">
4
+ <% %w{CSV JSON}.each do |format| %>
5
+ <li class="exports--format--<%= format.downcase %> exports--initiatives"><%= link_to t("decidim.admin.exports.export_as", name: t("decidim.initiatives.admin.exports.initiatives"), export_format: format.upcase), export_initiatives_path(format: format) %></li>
6
+ <% end %>
7
+ </ul>
8
+ </div>
@@ -3,6 +3,28 @@
3
3
  <h2 class="card-title"><%= t ".title" %></h2>
4
4
  </div>
5
5
 
6
+ <div class="card-section">
7
+ <div class="row column">
8
+ <%= form.translated :text_field, :title, autofocus: true, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
9
+ </div>
10
+
11
+ <div class="row column">
12
+ <%= form.translated :editor, :description, toolbar: :full, lines: 8, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
13
+ </div>
14
+
15
+ <div class="row column">
16
+ <div class="columns xlarge-6">
17
+ <%= form.text_field :hashtag, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
22
+
23
+ <div class="card">
24
+ <div class="card-divider">
25
+ <h2 class="card-title"><%= t ".settings" %></h2>
26
+ </div>
27
+
6
28
  <div class="card-section">
7
29
  <div class="row">
8
30
  <div class="columns xlarge-6">
@@ -13,15 +35,8 @@
13
35
  </div>
14
36
  </div>
15
37
 
16
- <div class="row column">
17
- <%= form.translated :text_field, :title, autofocus: true, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
18
- </div>
19
-
20
- <div class="row column">
21
- <%= form.translated :editor, :description, toolbar: :full, lines: 8, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
22
- </div>
23
-
24
38
  <div class="row">
39
+ <% unless single_initiative_type? %>
25
40
  <div class="columns xlarge-6">
26
41
  <%= form.select :type_id,
27
42
  initiative_type_options,
@@ -29,14 +44,14 @@
29
44
  {
30
45
  disabled: !@form.signature_type_updatable?,
31
46
  "data-scope-selector": "initiative_decidim_scope_id",
32
- "data-scope-id": form.object.decidim_scope_id,
47
+ "data-scope-id": form.object.decidim_scope_id.to_s,
33
48
  "data-scope-search-url": decidim_initiatives.initiative_type_scopes_search_url,
34
49
  "data-signature-types-selector": "initiative_signature_type",
35
50
  "data-signature-type": current_initiative.signature_type,
36
51
  "data-signature-types-search-url": decidim_initiatives.initiative_type_signature_types_search_url
37
52
  } %>
38
53
  </div>
39
-
54
+ <% end %>
40
55
  <div class="columns xlarge-6">
41
56
  <%= form.select :decidim_scope_id, [], {}, { disabled: !@form.signature_type_updatable? } %>
42
57
  </div>
@@ -54,24 +69,54 @@
54
69
  </div>
55
70
  <% end %>
56
71
 
57
- <div class="row">
58
- <div class="columns xlarge-6">
59
- <%= form.text_field :hashtag, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
72
+ <% if can_edit_custom_signature_end_date?(current_initiative) %>
73
+ <div class="row column">
74
+ <%= form.date_field :signature_end_date, disabled: !allowed_to?(:update, :initiative, initiative: current_initiative) %>
60
75
  </div>
76
+ <% end %>
61
77
 
78
+ <% if current_initiative.area_enabled? %>
79
+ <div class="field">
80
+ <%= form.areas_select :area_id,
81
+ areas_for_select(current_organization),
82
+ {
83
+ selected: current_initiative.decidim_area_id,
84
+ include_blank: current_initiative.decidim_area_id.blank? || current_initiative.created?
85
+ },
86
+ disabled: !@form.area_updatable? %>
87
+ </div>
88
+ <% end %>
89
+
90
+ <div class="row">
62
91
  <div class="columns xlarge-6">
63
92
  <%= form.select :signature_type, [], {}, { disabled: !@form.signature_type_updatable? } %>
64
93
  </div>
65
94
  </div>
66
95
 
67
- <% if current_initiative.accepts_offline_votes? && current_user.admin? %>
96
+ <% if current_initiative.accepts_offline_votes? && current_user.admin? %>
68
97
  <div class="row">
69
98
  <div class="columns xlarge-6">
70
- <%= form.number_field :offline_votes, min: 1 %>
99
+ <% @form.offline_votes.each do |scope_id, (votes, scope_name)| %>
100
+ <%= label_tag "initiative_offline_votes_#{scope_id}", t("activemodel.attributes.initiative.offline_votes_for_scope", scope_name: translated_attribute(scope_name)) %>
101
+ <%= number_field_tag "initiative[offline_votes][#{scope_id}]", votes, min: 0, id: "initiative_offline_votes_#{scope_id}" %>
102
+ <% end %>
71
103
  </div>
72
104
  </div>
73
105
  <% end %>
74
106
  </div>
75
107
  </div>
108
+ <div class="card">
109
+ <div class="card-divider">
110
+ <h2 class="card-title"><%= t ".attachments" %></h2>
111
+ </div>
112
+
113
+ <div class="card-section">
114
+ <div class="row">
115
+ <% if allowed_to?(:read, :attachment, initiative: current_participatory_space) %>
116
+ <%= render partial: "initiative_attachments", locals: { current_initiative: current_initiative, current_participatory_space: current_participatory_space } %>
117
+ <% end %>
118
+ </div>
119
+ </div>
120
+ </div>
76
121
 
77
122
  <%= javascript_include_tag "decidim/initiatives/scoped_type" %>
@@ -0,0 +1,43 @@
1
+ <div class="row column">
2
+ <div class="columns xlarge-12">
3
+ <% if current_initiative.documents.any? %>
4
+ <div class="row column">
5
+ <strong><%= t ".documents" %>:</strong>
6
+ <ul id="documents">
7
+ <% current_initiative.documents.each do |document| %>
8
+ <li>
9
+ <%= link_to translated_attribute(document.title), document.url %>
10
+ <small><%= document.file_type %> <%= number_to_human_size(document.file_size) %></small>
11
+ </li>
12
+ <% end %>
13
+ </ul>
14
+ </div>
15
+ <% end %>
16
+
17
+ <% if current_initiative.photos.any? %>
18
+ <div class="row column">
19
+ <strong><%= t(".photos") %>:</strong>
20
+ <div id="photos" class="gallery row">
21
+ <% current_initiative.photos.each do |photo| %>
22
+ <%= link_to photo.big_url, target: "_blank", rel: "noopener" do %>
23
+ <%= image_tag photo.thumbnail_url, class: "thumbnail", alt: strip_tags(translated_attribute(photo.title)) %>
24
+ <% end %>
25
+ <% end %>
26
+ </div>
27
+ </div>
28
+ <% end %>
29
+ </div>
30
+ <div class="columns xlarge-12">
31
+ <% if allowed_to?(:update, :initiative, initiative: current_initiative) %>
32
+ <%= aria_selected_link_to t(".edit"),
33
+ decidim_admin_initiatives.initiative_attachments_path(current_participatory_space),
34
+ class: "button" %>
35
+ <%= aria_selected_link_to t(".new"),
36
+ decidim_admin_initiatives.new_initiative_attachment_path(current_participatory_space),
37
+ class: "button" %>
38
+ <% else %>
39
+ <%= link_to t(".edit"), "#", class: "button muted disabled" %>
40
+ <%= link_to t(".new"), "#", class: "button muted disabled" %>
41
+ <% end %>
42
+ </div>
43
+ </div>
@@ -41,33 +41,36 @@
41
41
  <br>
42
42
  <div class="initiatives-votes-table" style="width: 100%; display: block; border: 1pt solid black;">
43
43
  <div class="initiatives-votes-table-header" style="background-color: lightgray; display: inline-block; width: 100%; font-size: 12pt; font-weight: bold; border-bottom: 1pt solid black;">
44
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
44
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
45
45
  <%= t("models.initiatives_votes.fields.initiative_id", scope: "decidim.admin") %>
46
46
  </div>
47
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
47
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
48
48
  <%= t("models.initiatives_votes.fields.initiative_title", scope: "decidim.admin") %>
49
49
  </div>
50
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
50
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
51
51
  <%= t("models.initiatives_votes.fields.name_and_surname", scope: "decidim.admin") %>
52
52
  </div>
53
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
53
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
54
54
  <%= t("models.initiatives_votes.fields.document_number", scope: "decidim.admin") %>
55
55
  </div>
56
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
56
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
57
57
  <%= t("models.initiatives_votes.fields.date_of_birth", scope: "decidim.admin") %>
58
58
  </div>
59
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
59
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
60
60
  <%= t("models.initiatives_votes.fields.postal_code", scope: "decidim.admin") %>
61
61
  </div>
62
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
62
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
63
63
  <%= t("models.initiatives_votes.fields.time_and_date", scope: "decidim.admin") %>
64
64
  </div>
65
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
65
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
66
66
  <%= t("models.initiatives_votes.fields.timestamp", scope: "decidim.admin") %>
67
67
  </div>
68
- <div class="initiatives-votes-table-cell w11" style="width: 10.8%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
68
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
69
69
  <%= t("models.initiatives_votes.fields.hash", scope: "decidim.admin") %>
70
70
  </div>
71
+ <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
72
+ <%= t("models.initiatives_votes.fields.scope", scope: "decidim.admin") %>
73
+ </div>
71
74
  </div>
72
75
  <% @votes.each do |vote| %>
73
76
  <%= cell "decidim/initiatives_votes/vote", vote %>
@@ -1,50 +1,13 @@
1
- <div class="filters row">
2
- <div class="column medium-3">
3
- <span class="dropdown-menu-inverted_label"><%= t(".filter_by") %> :</span>
4
- <ul class="dropdown menu dropdown-inverted" data-dropdown-menu data-close-on-click-inside="false">
5
- <li class="is-dropdown-submenu-parent">
6
- <a href="#">
7
- <% if @state.present? %>
8
- <%= t(".filter.#{@state}") %>
9
- <% else %>
10
- <%= t(".filter.all") %>
11
- <% end %>
12
- </a>
13
- <ul class="menu is-dropdown-submenu">
14
- <li><%= link_to t(".filter.created"), url_for(state: "created", q: @query) %></li>
15
- <li><%= link_to t(".filter.validating"), url_for(state: "validating", q: @query) %></li>
16
- <li><%= link_to t(".filter.discarded"), url_for(state: "discarded", q: @query) %></li>
17
- <li><%= link_to t(".filter.published"), url_for(state: "published", q: @query) %></li>
18
- <li><%= link_to t(".filter.rejected"), url_for(state: "rejected", q: @query) %></li>
19
- <li><%= link_to t(".filter.accepted"), url_for(state: "accepted", q: @query) %></li>
20
- <li><%= link_to t(".filter.all"), url_for(q: @query) %></li>
21
- </ul>
22
- </li>
23
- </ul>
24
- </div>
25
- <div class="column medium-4">
26
- <%= form_tag "", method: :get do %>
27
- <div class="filters__search">
28
- <div class="input-group">
29
- <%= search_field_tag :q, @query,label: false, class: "input-group-field", placeholder: t(".search") %>
30
- <%= hidden_field_tag :state, @state %>
31
- <div class="input-group-button">
32
- <button type="submit" class="button button--muted">
33
- <%= icon "magnifying-glass", aria_label: t(".search") %>
34
- </button>
35
- </div>
36
- </div>
37
- </div>
38
- <% end %>
39
- </div>
40
- </div>
41
-
42
- <div class="card" id="initiatives">
1
+ <div class="card with-overflow" id="initiatives">
43
2
  <div class="card-divider">
44
3
  <h2 class="card-title">
45
4
  <%= t "decidim.admin.titles.initiatives" %>
5
+ <div class="button--title">
6
+ <%= render partial: "decidim/initiatives/admin/exports/dropdown" if allowed_to? :export, :initiatives %>
7
+ </div>
46
8
  </h2>
47
9
  </div>
10
+ <%= admin_filter_selector(:initiatives) %>
48
11
  <div class="card-section">
49
12
  <div class="table-scroll">
50
13
  <table class="table-list">
@@ -53,8 +16,9 @@
53
16
  <th><%= t("models.initiatives.fields.id", scope: "decidim.admin") %></th>
54
17
  <th><%= t("models.initiatives.fields.title", scope: "decidim.admin") %></th>
55
18
  <th><%= t("models.initiatives.fields.state", scope: "decidim.admin") %></th>
56
- <th><%= t("models.initiatives.fields.supports_count", scope: "decidim.admin") %></th>
57
- <th><%= t("models.initiatives.fields.created_at", scope: "decidim.admin") %></th>
19
+ <th><%= sort_link(query, :supports_count, t("models.initiatives.fields.supports_count", scope: "decidim.admin"), default_order: :desc) %></th>
20
+ <th><%= sort_link(query, :created_at, t("models.initiatives.fields.created_at", scope: "decidim.admin"), default_order: :desc) %></th>
21
+ <th><%= sort_link(query, :published_at, t("models.initiatives.fields.published_at", scope: "decidim.admin"), default_order: :desc) %></th>
58
22
  <th class="actions"><%= t ".actions_title" %></th>
59
23
  </tr>
60
24
  </thead>
@@ -73,6 +37,7 @@
73
37
  <td><%= humanize_admin_state initiative.state %></td>
74
38
  <td><%= initiative.supports_count %>/<%= initiative.scoped_type.supports_required %></td>
75
39
  <td><%= l initiative.created_at, format: :short %></td>
40
+ <td><%= initiative.published_at? ? l(initiative.published_at, format: :short) : "" %></td>
76
41
  <td class="table-list__actions">
77
42
  <% if allowed_to? :preview, :initiative, initiative: initiative %>
78
43
  <%= icon_link_to "eye",
@@ -92,7 +57,7 @@
92
57
  <% if allowed_to?(:answer, :initiative, initiative: initiative) %>
93
58
  <%= icon_link_to "comment-square", edit_initiative_answer_path(initiative.slug), t("actions.answer", scope: "decidim.initiatives"), class: "action-icon action-icon--answer" %>
94
59
  <% else %>
95
- <%= icon "comment-square", scope: "decidim.admin", class: "action-icon action-icon--disabled" %>
60
+ <%= icon "comment-square", scope: "decidim.admin", class: "action-icon action-icon--disabled", role: "img", "aria-hidden": true %>
96
61
  <% end %>
97
62
 
98
63
  <% if allowed_to? :read, :initiative, initiative: initiative %>