decidim-proposals 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +6 -0
  3. data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +3 -0
  4. data/app/cells/decidim/proposals/collaborative_draft_cell.rb +1 -1
  5. data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +2 -2
  6. data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +1 -1
  7. data/app/cells/decidim/proposals/proposal_cell.rb +1 -1
  8. data/app/cells/decidim/proposals/proposal_m_cell.rb +2 -2
  9. data/app/commands/decidim/proposals/admin/create_proposal.rb +4 -2
  10. data/app/commands/decidim/proposals/admin/publish_participatory_text.rb +6 -1
  11. data/app/commands/decidim/proposals/admin/update_participatory_text.rb +10 -2
  12. data/app/commands/decidim/proposals/admin/update_proposal.rb +4 -2
  13. data/app/commands/decidim/proposals/create_proposal.rb +6 -2
  14. data/app/commands/decidim/proposals/publish_collaborative_draft.rb +2 -2
  15. data/app/commands/decidim/proposals/update_proposal.rb +25 -9
  16. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
  17. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -10
  18. data/app/controllers/decidim/proposals/proposals_controller.rb +3 -17
  19. data/app/controllers/decidim/proposals/{proposal_widgets_controller.rb → widgets_controller.rb} +2 -2
  20. data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +3 -1
  21. data/app/forms/decidim/proposals/admin/participatory_text_proposal_form.rb +8 -1
  22. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +20 -13
  23. data/app/forms/decidim/proposals/admin/proposal_form.rb +9 -2
  24. data/app/forms/decidim/proposals/proposal_form.rb +21 -12
  25. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +2 -0
  26. data/app/helpers/decidim/proposals/application_helper.rb +13 -8
  27. data/app/helpers/decidim/proposals/proposals_helper.rb +1 -1
  28. data/app/models/decidim/proposals/collaborative_draft.rb +2 -2
  29. data/app/models/decidim/proposals/participatory_text.rb +3 -0
  30. data/app/models/decidim/proposals/proposal.rb +13 -40
  31. data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +6 -1
  32. data/app/presenters/decidim/proposals/official_author_presenter.rb +1 -29
  33. data/app/presenters/decidim/proposals/proposal_presenter.rb +43 -6
  34. data/app/queries/decidim/proposals/similar_proposals.rb +4 -4
  35. data/app/services/decidim/proposals/collaborative_draft_search.rb +6 -16
  36. data/app/services/decidim/proposals/diff_renderer.rb +15 -5
  37. data/app/services/decidim/proposals/proposal_builder.rb +8 -2
  38. data/app/services/decidim/proposals/proposal_search.rb +7 -58
  39. data/app/types/decidim/proposals/proposal_type.rb +2 -2
  40. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +6 -6
  41. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +2 -11
  42. data/app/views/decidim/proposals/admin/proposals/index.html.erb +2 -2
  43. data/app/views/decidim/proposals/admin/proposals/show.html.erb +1 -1
  44. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +5 -5
  45. data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +1 -1
  46. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -1
  47. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +46 -18
  48. data/app/views/decidim/proposals/proposals/_filters.html.erb +1 -1
  49. data/app/views/decidim/proposals/proposals/index.html.erb +0 -2
  50. data/app/views/decidim/proposals/proposals/show.html.erb +3 -3
  51. data/config/locales/am-ET.yml +1 -0
  52. data/config/locales/bg.yml +237 -0
  53. data/config/locales/ca.yml +12 -4
  54. data/config/locales/cs.yml +9 -1
  55. data/config/locales/da.yml +1 -0
  56. data/config/locales/de.yml +3 -0
  57. data/config/locales/en.yml +8 -0
  58. data/config/locales/eo.yml +1 -0
  59. data/config/locales/es-MX.yml +8 -0
  60. data/config/locales/es-PY.yml +8 -0
  61. data/config/locales/es.yml +22 -14
  62. data/config/locales/et.yml +1 -0
  63. data/config/locales/eu.yml +0 -15
  64. data/config/locales/fi-plain.yml +8 -0
  65. data/config/locales/fi.yml +9 -1
  66. data/config/locales/fr-CA.yml +30 -0
  67. data/config/locales/fr.yml +36 -6
  68. data/config/locales/gl.yml +0 -15
  69. data/config/locales/hr.yml +1 -0
  70. data/config/locales/id-ID.yml +0 -15
  71. data/config/locales/is.yml +274 -0
  72. data/config/locales/it.yml +6 -0
  73. data/config/locales/ja-JP.yml +5 -26
  74. data/config/locales/ja.yml +889 -0
  75. data/config/locales/ko-KR.yml +1 -0
  76. data/config/locales/ko.yml +1 -0
  77. data/config/locales/lt.yml +1 -0
  78. data/config/locales/{lv-LV.yml → lv.yml} +0 -0
  79. data/config/locales/mt.yml +1 -0
  80. data/config/locales/nl.yml +9 -1
  81. data/config/locales/om-ET.yml +1 -0
  82. data/config/locales/pl.yml +377 -374
  83. data/config/locales/pt-BR.yml +0 -15
  84. data/config/locales/pt.yml +1 -0
  85. data/config/locales/ro-RO.yml +1 -0
  86. data/config/locales/so-SO.yml +1 -0
  87. data/config/locales/sv.yml +49 -26
  88. data/config/locales/ti-ER.yml +1 -0
  89. data/config/locales/tr-TR.yml +0 -15
  90. data/config/locales/vi-VN.yml +1 -0
  91. data/config/locales/vi.yml +1 -0
  92. data/config/locales/zh-CN.yml +885 -0
  93. data/config/locales/zh-TW.yml +1 -0
  94. data/db/migrate/20200120215928_move_proposal_endorsements_to_core_endorsements.rb +2 -0
  95. data/db/migrate/20200120230130_drop_proposal_endorsements.rb +8 -0
  96. data/db/migrate/20200708091228_move_proposals_fields_to_i18n.rb +80 -0
  97. data/db/migrate/20200827154156_add_commentable_counter_cache_to_proposals.rb +12 -0
  98. data/db/migrate/20200915151348_fix_proposals_data_to_ensure_title_and_body_are_hashes.rb +37 -0
  99. data/db/migrate/20201002085508_fix_proposals_data.rb +37 -0
  100. data/lib/decidim/content_renderers/proposal_renderer.rb +3 -1
  101. data/lib/decidim/proposals/component.rb +9 -6
  102. data/lib/decidim/proposals/engine.rb +1 -1
  103. data/lib/decidim/proposals/markdown_to_proposals.rb +2 -2
  104. data/lib/decidim/proposals/proposal_serializer.rb +3 -3
  105. data/lib/decidim/proposals/test/capybara_proposals_picker.rb +2 -2
  106. data/lib/decidim/proposals/test/factories.rb +44 -18
  107. data/lib/decidim/proposals/version.rb +1 -1
  108. metadata +46 -22
@@ -5,6 +5,8 @@ module Decidim
5
5
  # A service to encapsualte all the logic when searching and filtering
6
6
  # collaborative drafts in a participatory process.
7
7
  class CollaborativeDraftSearch < ResourceSearch
8
+ text_search_fields :title, :body
9
+
8
10
  # Public: Initializes the service.
9
11
  # component - A Decidim::Component to get the drafts from.
10
12
  # page - The page number to paginate the results.
@@ -14,6 +16,9 @@ module Decidim
14
16
  end
15
17
 
16
18
  # Handle the search_text filter
19
+ #
20
+ # We can't use the search from `ResourceFilter` since these fields aren't
21
+ # translated.
17
22
  def search_search_text
18
23
  query
19
24
  .where("title ILIKE ?", "%#{search_text}%")
@@ -24,22 +29,7 @@ module Decidim
24
29
  def search_state
25
30
  return query if state.member?("all")
26
31
 
27
- open_drafts = state.member?("open") ? query.open : nil
28
- withdrawn = state.member?("withdrawn") ? query.withdrawn : nil
29
- published = state.member?("published") ? query.published : nil
30
-
31
- query
32
- .where(id: open_drafts)
33
- .or(query.where(id: withdrawn))
34
- .or(query.where(id: published))
35
- end
36
-
37
- def search_category_id
38
- super
39
- end
40
-
41
- def search_scope_id
42
- super
32
+ apply_scopes(%w(open withdrawn published), state)
43
33
  end
44
34
 
45
35
  # Filters drafts by the name of the classes they are linked to. By default,
@@ -8,8 +8,8 @@ module Decidim
8
8
  # Lists which attributes will be diffable and how they should be rendered.
9
9
  def attribute_types
10
10
  {
11
- title: :string,
12
- body: :string,
11
+ title: :i18n,
12
+ body: :i18n,
13
13
  decidim_category_id: :category,
14
14
  decidim_scope_id: :scope,
15
15
  address: :string,
@@ -24,13 +24,15 @@ module Decidim
24
24
  return parse_scope_changeset(attribute, values, type, diff) if type == :scope
25
25
 
26
26
  values = parse_values(attribute, values)
27
+ old_value = values[0]
28
+ new_value = values[1]
27
29
 
28
30
  diff.update(
29
31
  attribute => {
30
32
  type: type,
31
33
  label: I18n.t(attribute, scope: i18n_scope),
32
- old_value: values[0],
33
- new_value: values[1]
34
+ old_value: old_value,
35
+ new_value: new_value
34
36
  }
35
37
  )
36
38
  end
@@ -40,7 +42,15 @@ module Decidim
40
42
  # Returns and Array of two Strings.
41
43
  def parse_values(attribute, values)
42
44
  values = [amended_previous_value(attribute), values[1]] if proposal&.emendation?
43
- values = values.map { |value| normalize_line_endings(value) } if attribute == :body
45
+ if attribute == :body
46
+ values = values.map do |value|
47
+ if value.is_a?(Hash)
48
+ value.values.map { |subvalue| normalize_line_endings(subvalue) }
49
+ else
50
+ normalize_line_endings(value)
51
+ end
52
+ end
53
+ end
44
54
  values
45
55
  end
46
56
 
@@ -102,8 +102,14 @@ module Decidim
102
102
 
103
103
  def copy_attachments(original_proposal, proposal)
104
104
  original_proposal.attachments.each do |attachment|
105
- new_attachment = Decidim::Attachment.new(attachment.attributes.slice("content_type", "description", "file", "file_size", "title", "weight"))
106
- new_attachment.attached_to = proposal
105
+ new_attachment = Decidim::Attachment.new(
106
+ {
107
+ # Attached to needs to be always defined before the file is set
108
+ attached_to: proposal
109
+ }.merge(
110
+ attachment.attributes.slice("content_type", "description", "file", "file_size", "title", "weight")
111
+ )
112
+ )
107
113
 
108
114
  if File.exist?(attachment.file.file.path)
109
115
  new_attachment.file = File.open(attachment.file.file.path)
@@ -5,52 +5,30 @@ module Decidim
5
5
  # A service to encapsualte all the logic when searching and filtering
6
6
  # proposals in a participatory process.
7
7
  class ProposalSearch < ResourceSearch
8
+ text_search_fields :title, :body
9
+
8
10
  # Public: Initializes the service.
9
11
  # component - A Decidim::Component to get the proposals from.
10
12
  # page - The page number to paginate the results.
11
13
  # per_page - The number of proposals to return per page.
12
14
  def initialize(options = {})
13
- @component = options[:component]
14
- @current_user = options[:current_user]
15
-
16
15
  base = options[:state]&.member?("withdrawn") ? Proposal.withdrawn : Proposal.except_withdrawn
17
16
  super(base, options)
18
17
  end
19
18
 
20
- # Handle the search_text filter
21
- def search_search_text
22
- query
23
- .where("decidim_proposals_proposals.title ILIKE ?", "%#{search_text}%")
24
- .or(query.where("decidim_proposals_proposals.body ILIKE ?", "%#{search_text}%"))
25
- end
26
-
27
- # Handle the origin filter
28
- def search_origin
29
- official = origin.member?("official") ? query.official_origin : nil
30
- citizens = origin.member?("citizens") ? query.citizens_origin : nil
31
- user_group = origin.member?("user_group") ? query.user_group_origin : nil
32
- meeting = origin.member?("meeting") ? query.meeting_origin : nil
33
-
34
- query
35
- .where(id: official)
36
- .or(query.where(id: citizens))
37
- .or(query.where(id: user_group))
38
- .or(query.where(id: meeting))
39
- end
40
-
41
19
  # Handle the activity filter
42
20
  def search_activity
43
21
  case activity
44
22
  when "voted"
45
23
  query
46
24
  .includes(:votes)
47
- .where(decidim_proposals_proposal_votes: { decidim_author_id: @current_user })
25
+ .where(decidim_proposals_proposal_votes: { decidim_author_id: user })
48
26
  when "my_proposals"
49
27
  query
50
28
  .where.not(coauthorships_count: 0)
51
29
  .joins(:coauthorships)
52
30
  .where(decidim_coauthorships: { decidim_author_type: "Decidim::UserBaseEntity" })
53
- .where(decidim_coauthorships: { decidim_author_id: @current_user })
31
+ .where(decidim_coauthorships: { decidim_author_id: user })
54
32
  else # Assume 'all'
55
33
  query
56
34
  end
@@ -60,16 +38,7 @@ module Decidim
60
38
  def search_state
61
39
  return query if state.member? "withdrawn"
62
40
 
63
- accepted = state.member?("accepted") ? query.accepted : nil
64
- rejected = state.member?("rejected") ? query.rejected : nil
65
- evaluating = state.member?("evaluating") ? query.evaluating : nil
66
- not_answered = state.member?("not_answered") ? query.state_not_published : nil
67
-
68
- query
69
- .where(id: accepted)
70
- .or(query.where(id: rejected))
71
- .or(query.where(id: evaluating))
72
- .or(query.where(id: not_answered))
41
+ apply_scopes(%w(accepted rejected evaluating state_not_published), state)
73
42
  end
74
43
 
75
44
  # Handle the amendment type filter
@@ -78,20 +47,12 @@ module Decidim
78
47
  when "proposals"
79
48
  query.only_amendables
80
49
  when "amendments"
81
- query.only_visible_emendations_for(@current_user, @component)
50
+ query.only_visible_emendations_for(user, component)
82
51
  else # Assume 'all'
83
- query.amendables_and_visible_emendations_for(@current_user, @component)
52
+ query.amendables_and_visible_emendations_for(user, component)
84
53
  end
85
54
  end
86
55
 
87
- def search_category_id
88
- super
89
- end
90
-
91
- def search_scope_id
92
- super
93
- end
94
-
95
56
  # Filters Proposals by the name of the classes they are linked to. By default,
96
57
  # returns all Proposals. When a `related_to` param is given, then it camelcases item
97
58
  # to find the real class name and checks the links for the Proposals.
@@ -114,18 +75,6 @@ module Decidim
114
75
 
115
76
  query.where(id: from).or(query.where(id: to))
116
77
  end
117
-
118
- # We overwrite the `results` method to ensure we only return unique
119
- # results. We can't use `#uniq` because it returns an Array and we're
120
- # adding scopes in the controller, and `#distinct` doesn't work here
121
- # because in the later scopes we're ordering by `RANDOM()` in a DB level,
122
- # and `SELECT DISTINCT` doesn't work with `RANDOM()` sorting, so we need
123
- # to perform two queries.
124
- #
125
- # The correct behaviour is backed by tests.
126
- def results
127
- Proposal.where(id: super.pluck(:id))
128
- end
129
78
  end
130
79
  end
131
80
  end
@@ -21,8 +21,8 @@ module Decidim
21
21
  ]
22
22
 
23
23
  field :id, !types.ID
24
- field :title, !types.String, "This proposal's title"
25
- field :body, types.String, "This proposal's body"
24
+ field :title, Decidim::Core::TranslatedFieldType, "The title for this title"
25
+ field :body, Decidim::Core::TranslatedFieldType, "The description for this body"
26
26
  field :address, types.String, "The physical address (location) of this proposal"
27
27
  field :coordinates, Decidim::Core::CoordinatesType, "Physical coordinates for this proposal" do
28
28
  resolve ->(proposal, _args, _ctx) {
@@ -5,11 +5,11 @@
5
5
 
6
6
  <div class="card-section">
7
7
  <div class="row column hashtags__container">
8
- <%= form.text_field :title, class: "js-hashtags", value: form_presenter.title(extras: false).strip %>
8
+ <%= form.translated :text_field, :title, class: "js-hashtags", value: form_presenter.title(extras: false).strip, hashtaggable: true %>
9
9
  </div>
10
10
 
11
11
  <div class="row column hashtags__container">
12
- <%= form.editor :body, hashtaggable: true, value: form_presenter.body(extras: false).strip %>
12
+ <%= form.translated :editor, :body, hashtaggable: true, value: form_presenter.body(extras: false).strip %>
13
13
  </div>
14
14
 
15
15
  <% if @form.component_automatic_hashtags.any? %>
@@ -51,9 +51,9 @@
51
51
  </div>
52
52
  <% end %>
53
53
 
54
- <% if component_settings.geocoding_enabled? %>
54
+ <% if @form.geocoding_enabled? %>
55
55
  <div class="row column">
56
- <%= form.text_field :address %>
56
+ <%= form.geocoding_field :address %>
57
57
  </div>
58
58
  <% end %>
59
59
 
@@ -63,9 +63,9 @@
63
63
  </div>
64
64
  <% end %>
65
65
 
66
- <% if current_participatory_space.has_subscopes? %>
66
+ <% if current_component.has_subscopes? %>
67
67
  <div class="row column">
68
- <%= scopes_picker_field form, :scope_id %>
68
+ <%= scopes_picker_field form, :scope_id, root: current_component.scope %>
69
69
  </div>
70
70
  <% end %>
71
71
 
@@ -16,16 +16,7 @@
16
16
  <%= translated_attribute proposal.category.name %>
17
17
  <% end %>
18
18
  </td>
19
- <% if current_participatory_space.scopes_enabled? %>
20
- <td>
21
- <% if proposal.scope %>
22
- <%= translated_attribute proposal.scope.name %>
23
- <% else %>
24
- <%= t("decidim.scopes.global") %>
25
- <% end %>
26
- </td>
27
- <% end %>
28
-
19
+ <%= td_resource_scope_for(proposal.scope) %>
29
20
  <td>
30
21
  <strong class="<%= proposal_state_css_class proposal.state %>">
31
22
  <%= t("decidim/amendment", scope: "activerecord.models", count: 1) if proposal.emendation? %>
@@ -51,7 +42,7 @@
51
42
 
52
43
  <% if current_component.settings.comments_enabled? and !current_settings.comments_blocked? %>
53
44
  <td>
54
- <%= proposal.comments.count %>
45
+ <%= proposal.comments_count %>
55
46
  </td>
56
47
  <% end %>
57
48
 
@@ -27,7 +27,7 @@
27
27
  <%= sort_link(query, :category_name, t("models.proposal.fields.category", scope: "decidim.proposals") ) %>
28
28
  </th>
29
29
 
30
- <% if current_participatory_space.scopes_enabled? %>
30
+ <% if resource_with_scopes_enabled? %>
31
31
  <th>
32
32
  <%= sort_link(query, :scope_name, t("models.proposal.fields.scope", scope: "decidim.proposals") ) %>
33
33
  </th>
@@ -51,7 +51,7 @@
51
51
 
52
52
  <% if current_component.settings.comments_enabled? and !current_settings.comments_blocked? %>
53
53
  <th>
54
- <%= sort_link(query, :commentable_comments_count, t("models.proposal.fields.comments", scope: "decidim.proposals") ) %>
54
+ <%= sort_link(query, :comments_count, t("models.proposal.fields.comments", scope: "decidim.proposals") ) %>
55
55
  </th>
56
56
  <% end %>
57
57
 
@@ -63,7 +63,7 @@
63
63
  </div>
64
64
 
65
65
  <div class="row column">
66
- <strong><%= t ".comments_count" %>:</strong> <%= proposal.comments.count %>
66
+ <strong><%= t ".comments_count" %>:</strong> <%= proposal.comments_count %>
67
67
  <ul id="proposal-comments-alignment-count">
68
68
  <li><strong><%= t ".comments_positive_count" %>:</strong> <%= proposal.comments.positive.count %></li>
69
69
  <li><strong><%= t ".comments_neutral_count" %>:</strong> <%= proposal.comments.neutral.count %></li>
@@ -32,13 +32,13 @@
32
32
  </div>
33
33
  <% end %>
34
34
 
35
- <% if component_settings.geocoding_enabled? %>
35
+ <% if @form.geocoding_enabled? %>
36
36
  <div class="field">
37
37
  <%= form.check_box :has_address, checked: form_has_address? %>
38
38
  </div>
39
39
 
40
40
  <div class="field" id="address_input">
41
- <%= form.text_field :address %>
41
+ <%= form.geocoding_field :address %>
42
42
  </div>
43
43
  <% end %>
44
44
 
@@ -48,13 +48,13 @@
48
48
  </div>
49
49
  <% end %>
50
50
 
51
- <% if current_participatory_space.has_subscopes? %>
51
+ <% if current_component.has_subscopes? %>
52
52
  <div class="field">
53
- <%= scopes_picker_field form, :scope_id %>
53
+ <%= scopes_picker_field form, :scope_id, root: current_component.scope %>
54
54
  </div>
55
55
  <% end %>
56
56
 
57
- <% if current_organization.user_groups_enabled? && Decidim::UserGroups::ManageableUserGroups.for(current_user).verified.any? %>
57
+ <% if current_organization.user_groups_enabled? && Decidim::UserGroups::ManageableUserGroups.for(current_user).verified.any? %>
58
58
  <div class="field">
59
59
  <%= user_group_select_field form, :user_group_id %>
60
60
  </div>
@@ -20,7 +20,7 @@
20
20
  <%= form.collection_radio_buttons :related_to, linked_classes_filter_values_for(Decidim::Proposals::CollaborativeDraft), :first, :last, { legend_title: t(".related_to") }, "aria-controls": "collaborative_drafts" %>
21
21
  <% end %>
22
22
 
23
- <% if current_participatory_space.has_subscopes? %>
23
+ <% if current_component.has_subscopes? %>
24
24
  <%= form.check_boxes_tree :scope_id, filter_scopes_values, legend_title: t(".scope"), "aria-controls": "collaborative_drafts" %>
25
25
  <% end %>
26
26
 
@@ -104,7 +104,7 @@
104
104
  <li class="card-data__item">
105
105
  <%= link_to "#comments" do %>
106
106
  <%= with_tooltip t("decidim.proposals.models.collaborative_draft.fields.comments") do %>
107
- <%= icon("comment-square", class: "icon--small", role: "img", "aria-hidden": true) + " " + "#{@collaborative_draft.comments.count}" %>
107
+ <%= icon("comment-square", class: "icon--small", role: "img", "aria-hidden": true) + " " + "#{@collaborative_draft.comments_count}" %>
108
108
  <% end %>
109
109
  <% end %>
110
110
  </li>
@@ -32,13 +32,13 @@
32
32
  </div>
33
33
  <% end %>
34
34
 
35
- <% if component_settings.geocoding_enabled? %>
35
+ <% if @form.geocoding_enabled? %>
36
36
  <div class="field">
37
37
  <%= form.check_box :has_address, checked: form_has_address? %>
38
38
  </div>
39
39
 
40
40
  <div class="field" id="address_input">
41
- <%= form.text_field :address %>
41
+ <%= form.geocoding_field :address %>
42
42
  </div>
43
43
  <% end %>
44
44
 
@@ -48,9 +48,9 @@
48
48
  </div>
49
49
  <% end %>
50
50
 
51
- <% if current_participatory_space.has_subscopes? %>
51
+ <% if current_component.has_subscopes? %>
52
52
  <div class="field">
53
- <%= scopes_picker_field form, :scope_id %>
53
+ <%= scopes_picker_field form, :scope_id, root: current_component.scope %>
54
54
  </div>
55
55
  <% end %>
56
56
 
@@ -61,23 +61,51 @@
61
61
  <% end %>
62
62
 
63
63
  <% if component_settings.attachments_allowed? && @proposal %>
64
+ <fieldset>
65
+ <legend><%= t("gallery_legend", scope: "decidim.proposals.proposals.edit") %></legend>
66
+
67
+ <% if @form.photos.any? %>
68
+ <% @form.photos.each do |photo| %>
69
+ <div class="callout gallery__item" data-closable>
70
+ <%= image_tag photo.thumbnail_url, class: "thumbnail", alt: photo.file.file.filename %>
71
+ <%= form.hidden_field :photos, multiple: true, value: photo.id, id: "photo-#{photo.id}" %>
72
+ <button class="close-button"
73
+ aria-label="<%= t("delete_image", scope: "decidim.proposals.proposals.edit") %>"
74
+ title="<%= t("delete_image", scope: "decidim.proposals.proposals.edit") %>"
75
+ type="button"
76
+ data-close>
77
+ <span aria-hidden="true">&times;</span>
78
+ </button>
79
+ </div>
80
+ <% end %>
81
+ <% end %>
82
+
83
+ <div class="row column">
84
+ <%= form.file_field :add_photos, multiple: false, label: t("add_images", scope: "decidim.proposals.proposals.edit") %>
85
+ </div>
86
+ </fieldset>
87
+
64
88
  <fieldset>
65
89
  <legend><%= t("attachment_legend", scope: "decidim.proposals.proposals.edit") %></legend>
66
- <%= form.fields_for :attachment, @form.attachment do |nested_form| %>
67
- <div class="field">
68
- <%= nested_form.text_field :title %>
69
- </div>
70
90
 
71
- <div class="field">
72
- <%= nested_form.upload :file, optional: false %>
73
- <% if @form.errors[:attachment].present? %>
74
- <% @form.errors[:attachment].each do |message| %>
75
- <small class="form-error is-visible">
76
- <%= message %>
77
- </small>
78
- <% end %>
79
- <% end %>
80
- </div>
91
+ <% if @form.documents.any? %>
92
+ <% @form.documents.each do |document| %>
93
+ <div class="callout" data-closable>
94
+ <%= link_to translated_attribute(document.title), document.url %>
95
+ <small><%= document.file_type %> <%= number_to_human_size(document.file_size) %></small>
96
+ <%= form.hidden_field :documents, multiple: true, value: document.id, id: "document-#{document.id}" %>
97
+ <button class="close-button"
98
+ aria-label="<%= t("delete_document", scope: "decidim.proposals.proposals.edit") %>"
99
+ title="<%= t("delete_document", scope: "decidim.proposals.proposals.edit") %>"
100
+ type="button" data-close>
101
+ <span aria-hidden="true">&times;</span>
102
+ </button>
103
+ </div>
104
+ <% end %>
81
105
  <% end %>
106
+
107
+ <div class="row column">
108
+ <%= form.file_field :add_documents, multiple: true, label: t("add_documents", scope: "decidim.proposals.proposals.edit") %>
109
+ </div>
82
110
  </fieldset>
83
111
  <% end %>