decidim-proposals 0.15.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/app/assets/config/decidim_proposals_manifest.js +1 -0
  4. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +1 -1
  5. data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +23 -0
  6. data/app/cells/decidim/proposals/collaborative_draft_cell.rb +0 -2
  7. data/app/cells/decidim/proposals/collaborative_draft_m_cell.rb +5 -1
  8. data/app/cells/decidim/proposals/highlighted_proposals/show.erb +3 -0
  9. data/app/cells/decidim/proposals/highlighted_proposals_cell.rb +25 -0
  10. data/app/cells/decidim/proposals/highlighted_proposals_for_component/show.erb +19 -0
  11. data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +34 -0
  12. data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +33 -0
  13. data/app/cells/decidim/proposals/participatory_text_proposal/show.erb +9 -0
  14. data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +77 -0
  15. data/app/cells/decidim/proposals/proposal_cell.rb +0 -2
  16. data/app/cells/decidim/proposals/proposal_m/footer.erb +1 -1
  17. data/app/cells/decidim/proposals/proposal_m_cell.rb +6 -1
  18. data/app/commands/decidim/proposals/accept_access_to_collaborative_draft.rb +3 -3
  19. data/app/commands/decidim/proposals/admin/answer_proposal.rb +2 -1
  20. data/app/commands/decidim/proposals/admin/create_proposal.rb +7 -7
  21. data/app/commands/decidim/proposals/admin/import_participatory_text.rb +8 -8
  22. data/app/commands/decidim/proposals/admin/update_proposal.rb +13 -6
  23. data/app/commands/decidim/proposals/admin/update_proposal_category.rb +1 -1
  24. data/app/commands/decidim/proposals/create_collaborative_draft.rb +6 -3
  25. data/app/commands/decidim/proposals/create_proposal.rb +25 -11
  26. data/app/commands/decidim/proposals/endorse_proposal.rb +1 -2
  27. data/app/commands/decidim/proposals/hashtags_methods.rb +36 -0
  28. data/app/commands/decidim/proposals/publish_collaborative_draft.rb +39 -34
  29. data/app/commands/decidim/proposals/publish_proposal.rb +13 -17
  30. data/app/commands/decidim/proposals/reject_access_to_collaborative_draft.rb +2 -3
  31. data/app/commands/decidim/proposals/request_access_to_collaborative_draft.rb +1 -2
  32. data/app/commands/decidim/proposals/update_collaborative_draft.rb +11 -8
  33. data/app/commands/decidim/proposals/update_proposal.rb +37 -13
  34. data/app/commands/decidim/proposals/withdraw_collaborative_draft.rb +3 -3
  35. data/app/commands/decidim/proposals/withdraw_proposal.rb +14 -1
  36. data/app/controllers/decidim/proposals/admin/participatory_texts_controller.rb +2 -1
  37. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +9 -1
  38. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +8 -0
  39. data/app/controllers/decidim/proposals/proposals_controller.rb +64 -27
  40. data/app/controllers/decidim/proposals/versions_controller.rb +5 -1
  41. data/app/events/decidim/proposals/accepted_proposal_event.rb +8 -0
  42. data/app/events/decidim/proposals/evaluating_proposal_event.rb +3 -0
  43. data/app/events/decidim/proposals/proposal_endorsed_event.rb +4 -0
  44. data/app/events/decidim/proposals/publish_proposal_event.rb +4 -0
  45. data/app/events/decidim/proposals/rejected_proposal_event.rb +8 -0
  46. data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +4 -0
  47. data/app/forms/decidim/proposals/admin/proposal_form.rb +49 -0
  48. data/app/forms/decidim/proposals/collaborative_draft_form.rb +2 -0
  49. data/app/forms/decidim/proposals/proposal_form.rb +32 -0
  50. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +19 -0
  51. data/app/helpers/decidim/proposals/application_helper.rb +48 -12
  52. data/app/helpers/decidim/proposals/control_version_helper.rb +61 -0
  53. data/app/helpers/decidim/proposals/participatory_texts_helper.rb +8 -0
  54. data/app/helpers/decidim/proposals/proposal_cells_helper.rb +7 -1
  55. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +8 -6
  56. data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +2 -2
  57. data/app/jobs/decidim/proposals/settings_change_job.rb +8 -6
  58. data/app/models/decidim/proposals/collaborative_draft.rb +3 -0
  59. data/app/models/decidim/proposals/proposal.rb +20 -8
  60. data/app/permissions/decidim/proposals/admin/permissions.rb +1 -1
  61. data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +2 -1
  62. data/app/presenters/decidim/proposals/collaborative_draft_presenter.rb +15 -2
  63. data/app/presenters/decidim/proposals/official_author_presenter.rb +4 -0
  64. data/app/presenters/decidim/proposals/proposal_presenter.rb +10 -14
  65. data/app/queries/decidim/proposals/metrics/endorsements_metric_manage.rb +54 -0
  66. data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +56 -0
  67. data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +64 -0
  68. data/app/services/decidim/proposals/proposal_search.rb +46 -5
  69. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +1 -1
  70. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +43 -2
  71. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +6 -2
  72. data/app/views/decidim/proposals/admin/proposals/edit.html.erb +1 -1
  73. data/app/views/decidim/proposals/admin/proposals/new.html.erb +1 -1
  74. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +81 -0
  75. data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +1 -49
  76. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +1 -29
  77. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +5 -5
  78. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +27 -3
  79. data/app/views/decidim/proposals/proposals/_filters.html.erb +5 -2
  80. data/app/views/decidim/proposals/proposals/_proposal.html.erb +5 -1
  81. data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +2 -2
  82. data/app/views/decidim/proposals/proposals/_vote_button.html.erb +39 -35
  83. data/app/views/decidim/proposals/proposals/_votes_count.html.erb +16 -12
  84. data/app/views/decidim/proposals/proposals/new.html.erb +1 -1
  85. data/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb +19 -0
  86. data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_vote_button.html.erb +46 -0
  87. data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_votes_count.html.erb +41 -0
  88. data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +10 -0
  89. data/app/views/decidim/proposals/proposals/participatory_texts/participatory_text.html.erb +15 -0
  90. data/app/views/decidim/proposals/proposals/show.html.erb +45 -4
  91. data/app/views/decidim/proposals/versions/_version.html.erb +2 -2
  92. data/app/views/decidim/proposals/versions/index.html.erb +1 -1
  93. data/app/views/decidim/proposals/versions/show.html.erb +2 -2
  94. data/config/locales/ca.yml +87 -33
  95. data/config/locales/de.yml +87 -36
  96. data/config/locales/en.yml +87 -33
  97. data/config/locales/es-PY.yml +87 -33
  98. data/config/locales/es.yml +88 -34
  99. data/config/locales/eu.yml +87 -33
  100. data/config/locales/fi-pl.yml +87 -33
  101. data/config/locales/fi.yml +87 -33
  102. data/config/locales/fr.yml +87 -33
  103. data/config/locales/gl.yml +87 -33
  104. data/config/locales/hu.yml +87 -33
  105. data/config/locales/id-ID.yml +84 -30
  106. data/config/locales/it.yml +87 -33
  107. data/config/locales/nl.yml +87 -33
  108. data/config/locales/pl.yml +87 -33
  109. data/config/locales/pt-BR.yml +87 -33
  110. data/config/locales/pt.yml +87 -33
  111. data/config/locales/ru.yml +21 -38
  112. data/config/locales/sv.yml +87 -33
  113. data/config/locales/tr-TR.yml +86 -32
  114. data/config/locales/uk.yml +21 -38
  115. data/db/migrate/20181026073215_add_created_in_meeting.rb +7 -0
  116. data/lib/decidim/proposals.rb +2 -0
  117. data/lib/decidim/proposals/component.rb +74 -0
  118. data/lib/decidim/proposals/doc_to_markdown.rb +40 -0
  119. data/lib/decidim/proposals/engine.rb +52 -35
  120. data/lib/decidim/proposals/odt_to_markdown.rb +46 -0
  121. data/lib/decidim/proposals/proposal_serializer.rb +29 -13
  122. data/lib/decidim/proposals/test/factories.rb +76 -0
  123. data/lib/decidim/proposals/version.rb +1 -1
  124. metadata +56 -20
  125. data/app/views/decidim/participatory_spaces/_highlighted_proposals.html.erb +0 -15
@@ -18,9 +18,22 @@ module Decidim
18
18
  end
19
19
  end
20
20
 
21
+ def collaborative_draft
22
+ __getobj__
23
+ end
24
+
21
25
  def collaborative_draft_path
22
- draft = __getobj__
23
- Decidim::ResourceLocatorPresenter.new(draft).path
26
+ Decidim::ResourceLocatorPresenter.new(collaborative_draft).path
27
+ end
28
+
29
+ def title(links: false, extras: true)
30
+ renderer = Decidim::ContentRenderers::HashtagRenderer.new(collaborative_draft.title)
31
+ renderer.render(links: links, extras: extras).html_safe
32
+ end
33
+
34
+ def body(links: false, extras: true)
35
+ renderer = Decidim::ContentRenderers::HashtagRenderer.new(collaborative_draft.body)
36
+ renderer.render(links: links, extras: extras).html_safe
24
37
  end
25
38
  end
26
39
  end
@@ -33,6 +33,10 @@ module Decidim
33
33
  def can_be_contacted?
34
34
  false
35
35
  end
36
+
37
+ def has_tooltip?
38
+ false
39
+ end
36
40
  end
37
41
  end
38
42
  end
@@ -34,24 +34,20 @@ module Decidim
34
34
  link_to title, proposal_path
35
35
  end
36
36
 
37
- def title
37
+ # Render the proposal title
38
+ #
39
+ # links - should render hashtags as links?
40
+ # extras - should include extra hashtags?
41
+ #
42
+ # Returns a String.
43
+ def title(links: false, extras: true)
38
44
  renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.title)
39
- renderer.render_without_link.html_safe
45
+ renderer.render(links: links, extras: extras).html_safe
40
46
  end
41
47
 
42
- def html_title
43
- renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.title)
44
- renderer.render.html_safe
45
- end
46
-
47
- def body
48
- renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.body)
49
- renderer.render_without_link.html_safe
50
- end
51
-
52
- def html_body
48
+ def body(links: false, extras: true)
53
49
  renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.body)
54
- renderer.render.html_safe
50
+ renderer.render(links: links, extras: extras).html_safe
55
51
  end
56
52
  end
57
53
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ module Metrics
6
+ class EndorsementsMetricManage < Decidim::MetricManage
7
+ def metric_name
8
+ "endorsements"
9
+ end
10
+
11
+ def save
12
+ return @registry if @registry
13
+
14
+ @registry = []
15
+ cumulative.each do |key, cumulative_value|
16
+ next if cumulative_value.zero?
17
+ quantity_value = quantity[key] || 0
18
+ category_id, space_type, space_id, proposal_id = key
19
+ record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
20
+ organization: @organization, decidim_category_id: category_id,
21
+ participatory_space_type: space_type, participatory_space_id: space_id,
22
+ related_object_type: "Decidim::Proposals::Proposal", related_object_id: proposal_id)
23
+ record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
24
+ @registry << record
25
+ end
26
+ @registry.each(&:save!)
27
+ @registry
28
+ end
29
+
30
+ private
31
+
32
+ def query
33
+ return @query if @query
34
+
35
+ components = Decidim::Component.where(participatory_space: retrieve_participatory_spaces).published
36
+ proposals = Decidim::Proposals::Proposal.where(component: components).except_withdrawn
37
+ @query = Decidim::Proposals::ProposalEndorsement.joins(proposal: :component)
38
+ .left_outer_joins(proposal: :category)
39
+ .where(proposal: proposals)
40
+ @query = @query.where("decidim_proposals_proposal_endorsements.created_at <= ?", end_time)
41
+ @query = @query.group("decidim_categorizations.id",
42
+ :participatory_space_type,
43
+ :participatory_space_id,
44
+ :decidim_proposal_id)
45
+ @query
46
+ end
47
+
48
+ def quantity
49
+ @quantity ||= query.where("decidim_proposals_proposal_endorsements.created_at >= ?", start_time).count
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ module Metrics
6
+ # Searches for unique Users following the next objects
7
+ # - Proposals
8
+ # - CollaborativeDrafts
9
+ class ProposalFollowersMetricMeasure < Decidim::MetricMeasure
10
+ def valid?
11
+ super && @resource.is_a?(Decidim::Component)
12
+ end
13
+
14
+ def calculate
15
+ cumulative_users = []
16
+ cumulative_users |= retrieve_proposals_followers.pluck(:decidim_user_id)
17
+ cumulative_users |= retrieve_drafts_followers.pluck(:decidim_user_id)
18
+
19
+ quantity_users = []
20
+ quantity_users |= retrieve_proposals_followers(true).pluck(:decidim_user_id)
21
+ quantity_users |= retrieve_drafts_followers(true).pluck(:decidim_user_id)
22
+
23
+ {
24
+ cumulative_users: cumulative_users.uniq,
25
+ quantity_users: quantity_users.uniq
26
+ }
27
+ end
28
+
29
+ private
30
+
31
+ def retrieve_proposals_followers(from_start = false)
32
+ @proposals_followers ||= Decidim::Follow.where(followable: retrieve_proposals).joins(:user)
33
+ .where("decidim_follows.created_at <= ?", end_time)
34
+
35
+ return @proposals_followers.where("decidim_follows.created_at >= ?", start_time) if from_start
36
+ @proposals_followers
37
+ end
38
+
39
+ def retrieve_drafts_followers(from_start = false)
40
+ @drafts_followers ||= Decidim::Follow.where(followable: retrieve_collaborative_drafts).joins(:user)
41
+ .where("decidim_follows.created_at <= ?", end_time)
42
+ return @drafts_followers.where("decidim_follows.created_at >= ?", start_time) if from_start
43
+ @drafts_followers
44
+ end
45
+
46
+ def retrieve_proposals
47
+ Decidim::Proposals::Proposal.where(component: @resource).except_withdrawn
48
+ end
49
+
50
+ def retrieve_collaborative_drafts
51
+ Decidim::Proposals::CollaborativeDraft.where(component: @resource).except_withdrawn
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ module Metrics
6
+ # Searches for Participants in the following actions
7
+ # - Create a proposal (Proposals)
8
+ # - Give support to a proposal (Proposals)
9
+ # - Endorse (Proposals)
10
+ class ProposalParticipantsMetricMeasure < Decidim::MetricMeasure
11
+ def valid?
12
+ super && @resource.is_a?(Decidim::Component)
13
+ end
14
+
15
+ def calculate
16
+ cumulative_users = []
17
+ cumulative_users |= retrieve_votes.pluck(:decidim_author_id)
18
+ cumulative_users |= retrieve_endorsements.pluck(:decidim_author_id)
19
+ cumulative_users |= retrieve_proposals.pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguosity must be called this way
20
+
21
+ quantity_users = []
22
+ quantity_users |= retrieve_votes(true).pluck(:decidim_author_id)
23
+ quantity_users |= retrieve_endorsements(true).pluck(:decidim_author_id)
24
+ quantity_users |= retrieve_proposals(true).pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguosity must be called this way
25
+
26
+ {
27
+ cumulative_users: cumulative_users.uniq,
28
+ quantity_users: quantity_users.uniq
29
+ }
30
+ end
31
+
32
+ private
33
+
34
+ def retrieve_proposals(from_start = false)
35
+ @proposals ||= Decidim::Proposals::Proposal.where(component: @resource).joins(:coauthorships)
36
+ .includes(:votes, :endorsements)
37
+ .where(decidim_coauthorships: { decidim_author_type: "Decidim::UserBaseEntity" })
38
+ .where("decidim_proposals_proposals.published_at <= ?", end_time)
39
+ .except_withdrawn
40
+
41
+ return @proposals.where("decidim_proposals_proposals.published_at >= ?", start_time) if from_start
42
+ @proposals
43
+ end
44
+
45
+ def retrieve_votes(from_start = false)
46
+ @votes ||= Decidim::Proposals::ProposalVote.joins(:proposal).where(proposal: retrieve_proposals).joins(:author)
47
+ .where("decidim_proposals_proposal_votes.created_at <= ?", end_time)
48
+
49
+ return @votes.where("decidim_proposals_proposal_votes.created_at >= ?", start_time) if from_start
50
+ @votes
51
+ end
52
+
53
+ def retrieve_endorsements(from_start = false)
54
+ @endorsements ||= Decidim::Proposals::ProposalEndorsement.joins(:proposal).where(proposal: retrieve_proposals)
55
+ .where("decidim_proposals_proposal_endorsements.created_at <= ?", end_time)
56
+ .where(decidim_author_type: "Decidim::UserBaseEntity")
57
+
58
+ return @endorsements.where("decidim_proposals_proposal_endorsements.created_at >= ?", start_time) if from_start
59
+ @endorsements
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -21,12 +21,29 @@ module Decidim
21
21
  end
22
22
 
23
23
  # Handle the origin filter
24
- # The 'official' proposals doesn't have an author id
25
24
  def search_origin
26
- if origin == "official"
27
- query.where.not(coauthorships_count: 0).joins(:coauthorships).where(decidim_coauthorships: { decidim_author_type: "Decidim::Organization" })
28
- elsif origin == "citizens"
29
- query.where.not(coauthorships_count: 0).joins(:coauthorships).where.not(decidim_coauthorships: { decidim_author_type: "Decidim::Organization" })
25
+ case origin
26
+ when "official"
27
+ query
28
+ .where.not(coauthorships_count: 0)
29
+ .joins(:coauthorships)
30
+ .where(decidim_coauthorships: { decidim_author_type: "Decidim::Organization" })
31
+ when "citizens"
32
+ query
33
+ .where.not(coauthorships_count: 0)
34
+ .joins(:coauthorships)
35
+ .where.not(decidim_coauthorships: { decidim_author_type: "Decidim::Organization" })
36
+ when "user_group"
37
+ query
38
+ .where.not(coauthorships_count: 0)
39
+ .joins(:coauthorships)
40
+ .where(decidim_coauthorships: { decidim_author_type: "Decidim::UserBaseEntity" })
41
+ .where.not(decidim_coauthorships: { decidim_user_group_id: nil })
42
+ when "meeting"
43
+ query
44
+ .where.not(coauthorships_count: 0)
45
+ .joins(:coauthorships)
46
+ .where(decidim_coauthorships: { decidim_author_type: "Decidim::Meetings::Meeting" })
30
47
  else # Assume 'all'
31
48
  query
32
49
  end
@@ -63,6 +80,18 @@ module Decidim
63
80
  end
64
81
  end
65
82
 
83
+ # Handle the amendment type filter
84
+ def search_type
85
+ case type
86
+ when "proposals"
87
+ query.where.not(id: query.joins(:amendable).pluck(:id))
88
+ when "amendments"
89
+ query.where(id: query.joins(:amendable).pluck(:id))
90
+ else
91
+ query
92
+ end
93
+ end
94
+
66
95
  # Filters Proposals by the name of the classes they are linked to. By default,
67
96
  # returns all Proposals. When a `related_to` param is given, then it camelcases item
68
97
  # to find the real class name and checks the links for the Proposals.
@@ -85,6 +114,18 @@ module Decidim
85
114
 
86
115
  query.where(id: from).or(query.where(id: to))
87
116
  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
88
129
  end
89
130
  end
90
131
  end
@@ -5,7 +5,7 @@
5
5
  <%= cell(
6
6
  "decidim/collapsible_list",
7
7
  proposals,
8
- cell_options: { context: { current_user: current_user } },
8
+ cell_options: {},
9
9
  list_class: "row small-up-1 medium-up-2 large-up-3 card-grid",
10
10
  size: proposals.count
11
11
  ) %>
@@ -5,13 +5,52 @@
5
5
 
6
6
  <div class="card-section">
7
7
  <div class="row column hashtags__container">
8
- <%= form.text_field :title, class: "js-hashtags", hashtaggable: true %>
8
+ <%= form.text_field :title, class: "js-hashtags", hashtaggable: true, value: form_presenter.title(extras: false).strip %>
9
9
  </div>
10
10
 
11
11
  <div class="row column hashtags__container">
12
- <%= form.text_area :body, rows: 10, class: "js-hashtags", hashtaggable: true %>
12
+ <%= form.text_area :body, rows: 10, class: "js-hashtags", hashtaggable: true, value: form_presenter.body(extras: false).strip %>
13
13
  </div>
14
14
 
15
+ <% if @form.component_automatic_hashtags.any? %>
16
+ <div class="field">
17
+ <%= form.label :automatic_hashtags %>
18
+ <div class="checkboxes hashtags">
19
+ <% @form.component_automatic_hashtags.each do |hashtag| %>
20
+ <label>
21
+ <%= check_box_tag "", "", { checked: true }, { disabled: true } %>#<%= hashtag %>
22
+ </label>
23
+ <% end %>
24
+ </div>
25
+ </div>
26
+ <% end %>
27
+
28
+ <% if @form.component_suggested_hashtags.any? %>
29
+ <div class="field">
30
+ <%= form.label :suggested_hashtags %>
31
+ <div class="checkboxes hashtags">
32
+ <%= form.collection_check_boxes :suggested_hashtags, @form.component_suggested_hashtags.map {|hashtag| [hashtag.downcase, "##{hashtag}"]}, :first, :last do |option|
33
+ option.label { option.check_box(checked: @form.suggested_hashtag_checked?(option.value)) + option.text }
34
+ end %>
35
+ </div>
36
+ </div>
37
+ <% end %>
38
+
39
+ <% if @form.meetings %>
40
+ <div class="meeting-fields">
41
+ <div class="row column">
42
+ <%= form.check_box :created_in_meeting, label: t(".created_in_meeting") %>
43
+ </div>
44
+
45
+ <div class="row column" id="proposal_meeting">
46
+ <%= form.select :meeting_id,
47
+ options_for_select(@form.meetings&.map { |meeting| [present(meeting).title, meeting.id] }, selected: meetings_as_authors_selected ),
48
+ { include_blank: true, label: t(".select_a_meeting") },
49
+ { multiple: false, class: "chosen-select" } %>
50
+ </div>
51
+ </div>
52
+ <% end %>
53
+
15
54
  <% if component_settings.geocoding_enabled? %>
16
55
  <div class="row column">
17
56
  <%= form.text_field :address %>
@@ -48,3 +87,5 @@
48
87
  <% end %>
49
88
  </div>
50
89
  </div>
90
+
91
+ <%= javascript_include_tag "decidim/proposals/admin/proposals_form" %>
@@ -23,7 +23,9 @@
23
23
  </td>
24
24
  <% end %>
25
25
  <td>
26
+ <%= t("decidim/amendment", scope: "activerecord.models", count: 1) if proposal.emendation? %>
26
27
  <strong class="<%= proposal_state_css_class proposal.state %>">
28
+ <%= t("decidim/amendment", scope: "activerecord.models", count: 1) if proposal.emendation? %>
27
29
  <%= humanize_proposal_state proposal.state %>
28
30
  </strong>
29
31
  </td>
@@ -59,8 +61,10 @@
59
61
  <%= icon_link_to "chat", proposal_proposal_notes_path(proposal_id: proposal.id), t("actions.private_notes", scope: "decidim.proposals"), class: "action-icon--index-notes" %>
60
62
  <% end %>
61
63
 
62
- <% if allowed_to? :create, :proposal_answer %>
63
- <%= icon_link_to "comment-square", edit_proposal_proposal_answer_path(proposal_id: proposal.id, id: proposal.id), t("actions.answer", scope: "decidim.proposals"), class: "action-icon--edit-answer" %>
64
+ <% if allowed_to? :create, :proposal_answer and !proposal.emendation? %>
65
+ <%= icon_link_to "comment-square", edit_proposal_proposal_answer_path(proposal_id: proposal.id, id: proposal.id), t("actions.answer", scope: "decidim.proposals"), class: " icon--small" %>
66
+ <% else %>
67
+ <%= icon "comment-square", scope: "decidim.proposals.admin", class: "action-icon action-icon--disabled" %>
64
68
  <% end %>
65
69
 
66
70
  <%= resource_permissions_link(proposal) %>
@@ -1,4 +1,4 @@
1
- <%= decidim_form_for(@form, html: { class: "form edit_proposal" }) do |f| %>
1
+ <%= decidim_form_for(@form, html: { class: "form edit_proposal proposal_form_admin" }) do |f| %>
2
2
  <%= render partial: "form", object: f, locals: { title: t(".title") } %>
3
3
 
4
4
  <div class="button--double form-general-submit">
@@ -1,4 +1,4 @@
1
- <%= decidim_form_for(@form, html: { class: "form new_proposal" }) do |f| %>
1
+ <%= decidim_form_for(@form, html: { class: "form new_proposal proposal_form_admin" }) do |f| %>
2
2
  <%= render partial: "form", object: f, locals: { title: t(".title") } %>
3
3
 
4
4
  <div class="button--double form-general-submit">
@@ -0,0 +1,81 @@
1
+ <div class="field hashtags__container">
2
+ <%= form.text_field :title, class: "js-hashtags", hashtaggable: true, value: form_presenter.title %>
3
+ </div>
4
+
5
+ <div class="field hashtags__container">
6
+ <%= form.text_area :body, rows: 10, class: "js-hashtags", hashtaggable: true, value: form_presenter.body(extras: false).strip %>
7
+ </div>
8
+
9
+ <% if @form.component_automatic_hashtags.any? %>
10
+ <div class="field">
11
+ <%= form.label :automatic_hashtags %>
12
+ <div class="checkboxes hashtags">
13
+ <% @form.component_automatic_hashtags.each do |hashtag| %>
14
+ <label>
15
+ <%= check_box_tag "", "", { checked: true }, { disabled: true } %>#<%= hashtag %>
16
+ </label>
17
+ <% end %>
18
+ </div>
19
+ </div>
20
+ <% end %>
21
+
22
+ <% if @form.component_suggested_hashtags.any? %>
23
+ <div class="field">
24
+ <%= form.label :suggested_hashtags %>
25
+ <div class="checkboxes hashtags">
26
+ <%= form.collection_check_boxes :suggested_hashtags, @form.component_suggested_hashtags.map {|hashtag| [hashtag.downcase, "##{hashtag}"]}, :first, :last do |option|
27
+ option.label { option.check_box(checked: @form.suggested_hashtag_checked?(option.value)) + option.text }
28
+ end %>
29
+ </div>
30
+ </div>
31
+ <% end %>
32
+
33
+ <% if component_settings.geocoding_enabled? %>
34
+ <div class="field">
35
+ <%= form.check_box :has_address, checked: form_has_address? %>
36
+ </div>
37
+
38
+ <div class="field" id="address_input">
39
+ <%= form.text_field :address %>
40
+ </div>
41
+ <% end %>
42
+
43
+ <% if @form.categories&.any? %>
44
+ <div class="field">
45
+ <%= form.categories_select :category_id, @form.categories, prompt: t("decidim.proposals.collaborative_drafts.edit.select_a_category") %>
46
+ </div>
47
+ <% end %>
48
+
49
+ <% if current_participatory_space.has_subscopes? %>
50
+ <div class="field">
51
+ <%= scopes_picker_field form, :scope_id %>
52
+ </div>
53
+ <% end %>
54
+
55
+ <% if current_organization.user_groups_enabled? && Decidim::UserGroups::ManageableUserGroups.for(current_user).verified.any? %>
56
+ <div class="field">
57
+ <%= user_group_select_field form, :user_group_id %>
58
+ </div>
59
+ <% end %>
60
+
61
+ <% if component_settings.attachments_allowed? %>
62
+ <fieldset>
63
+ <legend><%= t("attachment_legend", scope: "decidim.proposals.collaborative_drafts.edit") %></legend>
64
+ <%= form.fields_for :attachment, @form.attachment do |nested_form| %>
65
+ <div class="field">
66
+ <%= nested_form.text_field :title %>
67
+ </div>
68
+
69
+ <div class="field">
70
+ <%= nested_form.upload :file, optional: false %>
71
+ <% if @form.errors[:attachment].present? %>
72
+ <% @form.errors[:attachment].each do |message| %>
73
+ <small class="form-error is-visible">
74
+ <%= message %>
75
+ </small>
76
+ <% end %>
77
+ <% end %>
78
+ </div>
79
+ <% end %>
80
+ </fieldset>
81
+ <% end %>