decidim-plans 0.16.6 → 0.16.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/app/assets/javascripts/decidim/plans/admin/plans.js.es6 +93 -1
  4. data/app/assets/javascripts/decidim/plans/multifield/dynamic_fields.component.js.es6 +39 -0
  5. data/app/assets/javascripts/decidim/plans/multifield.js.es6 +1 -0
  6. data/app/cells/decidim/plans/plan_m/tags.erb +1 -0
  7. data/app/cells/decidim/plans/plan_m_cell.rb +1 -1
  8. data/app/cells/decidim/plans/tags/show.erb +7 -0
  9. data/app/cells/decidim/plans/tags/taggings.erb +3 -0
  10. data/app/cells/decidim/plans/tags_cell.rb +52 -0
  11. data/app/commands/decidim/plans/admin/answer_plan.rb +3 -0
  12. data/app/commands/decidim/plans/admin/create_tag.rb +44 -0
  13. data/app/commands/decidim/plans/admin/destroy_tag.rb +44 -0
  14. data/app/commands/decidim/plans/admin/update_plan_taggings.rb +53 -0
  15. data/app/commands/decidim/plans/admin/update_tag.rb +47 -0
  16. data/app/commands/decidim/plans/close_plan.rb +9 -1
  17. data/app/commands/decidim/plans/reopen_plan.rb +9 -1
  18. data/app/controllers/decidim/plans/admin/plans_controller.rb +32 -2
  19. data/app/controllers/decidim/plans/admin/tags_controller.rb +126 -0
  20. data/app/controllers/decidim/plans/plans_controller.rb +7 -2
  21. data/app/forms/decidim/plans/admin/tag_form.rb +22 -0
  22. data/app/forms/decidim/plans/admin/taggings_form.rb +20 -0
  23. data/app/helpers/decidim/plans/attached_proposals_helper.rb +18 -2
  24. data/app/helpers/decidim/plans/plan_cells_helper.rb +1 -1
  25. data/app/models/decidim/plans/plan.rb +14 -0
  26. data/app/models/decidim/plans/plan_tagging.rb +13 -0
  27. data/app/models/decidim/plans/tag.rb +20 -0
  28. data/app/permissions/decidim/plans/admin/permissions.rb +14 -4
  29. data/app/permissions/decidim/plans/permissions.rb +3 -1
  30. data/app/presenters/decidim/plans/plan_presenter.rb +4 -0
  31. data/app/queries/decidim/plans/component_plan_tags.rb +35 -0
  32. data/app/queries/decidim/plans/organization_tags.rb +25 -0
  33. data/app/services/decidim/plans/plan_search.rb +6 -0
  34. data/app/views/decidim/plans/admin/plans/_plan-tr.html.erb +13 -2
  35. data/app/views/decidim/plans/admin/plans/index.html.erb +9 -0
  36. data/app/views/decidim/plans/admin/plans/taggings.html.erb +67 -0
  37. data/app/views/decidim/plans/admin/tags/_form.html.erb +21 -0
  38. data/app/views/decidim/plans/admin/tags/edit.html.erb +7 -0
  39. data/app/views/decidim/plans/admin/tags/index.html.erb +52 -0
  40. data/app/views/decidim/plans/admin/tags/new.html.erb +7 -0
  41. data/app/views/decidim/plans/plans/_evaluation_modal.html.erb +22 -0
  42. data/app/views/decidim/plans/plans/_filters.html.erb +4 -0
  43. data/app/views/decidim/plans/plans/show.html.erb +9 -1
  44. data/app/views/decidim/plans/shared/_attachments.html.erb +2 -2
  45. data/app/views/decidim/plans/shared/_tags.html.erb +1 -0
  46. data/config/locales/en.yml +57 -2
  47. data/config/locales/fi.yml +57 -2
  48. data/config/locales/sv.yml +57 -2
  49. data/db/migrate/20190329161710_fix_plan_closing_workflow_states.rb +13 -0
  50. data/db/migrate/20190331141058_create_decidim_plans_tags_and_plan_taggings.rb +17 -0
  51. data/lib/decidim/content_parsers/plan_parser.rb +82 -0
  52. data/lib/decidim/content_renderers/plan_renderer.rb +33 -0
  53. data/lib/decidim/plans/admin_engine.rb +3 -0
  54. data/lib/decidim/plans/component.rb +11 -2
  55. data/lib/decidim/plans/engine.rb +6 -0
  56. data/lib/decidim/plans/test/factories.rb +17 -0
  57. data/lib/decidim/plans/version.rb +1 -1
  58. data/lib/decidim/plans.rb +8 -0
  59. metadata +29 -2
@@ -15,7 +15,7 @@ module Decidim
15
15
  include Orderable
16
16
  include Paginable
17
17
 
18
- helper_method :attached_proposals_picker_field
18
+ helper_method :attached_proposals_picker_field, :available_tags
19
19
 
20
20
  before_action :authenticate_user!, only: [:new, :create, :edit, :update, :withdraw, :preview, :publish, :close, :destroy]
21
21
  before_action :check_draft, only: [:new]
@@ -185,6 +185,10 @@ module Decidim
185
185
  redirect_to preview_plan_path(@plan)
186
186
  end
187
187
 
188
+ def available_tags
189
+ @available_tags ||= ComponentPlanTags.new(current_component).query
190
+ end
191
+
188
192
  def search_klass
189
193
  PlanSearch
190
194
  end
@@ -197,7 +201,8 @@ module Decidim
197
201
  category_id: "",
198
202
  state: "except_rejected",
199
203
  scope_id: nil,
200
- related_to: ""
204
+ related_to: "",
205
+ tag_id: []
201
206
  }
202
207
  end
203
208
 
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Plans
5
+ module Admin
6
+ # A form object to be used when admin users want to create a plan.
7
+ class TagForm < Decidim::Form
8
+ include TranslatableAttributes
9
+ include Decidim::ApplicationHelper
10
+
11
+ mimic :tag
12
+
13
+ alias organization current_organization
14
+
15
+ translatable_attribute :name, String
16
+ attribute :back_to_plan, Boolean
17
+
18
+ validates :name, translatable_presence: true
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Plans
5
+ module Admin
6
+ # A form object to be used when admin users want to create a plan.
7
+ class TaggingsForm < Decidim::Form
8
+ include Decidim::ApplicationHelper
9
+
10
+ mimic :tagging
11
+
12
+ attribute :tags, Array[Integer]
13
+
14
+ def map_model(plan)
15
+ self.tags = plan.tags.map { |tag| tag.id }
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -34,10 +34,26 @@ module Decidim
34
34
  .find_resource_manifest(:proposals)
35
35
  .try(:resource_scope, current_component)
36
36
  &.order(title: :asc)
37
- &.where("title ilike ?", "%#{params[:term]}%")
38
37
  &.where("state IS NULL OR state != ?", "rejected")
39
38
  &.where&.not(published_at: nil)
40
- render json: query.all.collect { |p| [present(p).title, p.id] }
39
+
40
+ # In case the search term starts with a hash character and contains
41
+ # only numbers, the user wants to search with the ID.
42
+ query = if params[:term] =~ /^#[0-9]+$/
43
+ idterm = params[:term].sub(/#/, "")
44
+ query&.where(
45
+ "id::text like ?",
46
+ "%#{idterm}%"
47
+ )
48
+ else
49
+ query&.where("title ilike ?", "%#{params[:term]}%")
50
+ end
51
+
52
+ proposals_list = query.all.collect do |p|
53
+ ["#{present(p).title} (##{p.id})", p.id]
54
+ end
55
+
56
+ render json: proposals_list
41
57
  end
42
58
  end
43
59
  end
@@ -14,7 +14,7 @@ module Decidim
14
14
  include Decidim::TranslatableAttributes
15
15
  include Decidim::CardHelper
16
16
 
17
- delegate :title, :state, :answered?, :withdrawn?, to: :model
17
+ delegate :title, :state, :closed?, :answered?, :withdrawn?, to: :model
18
18
 
19
19
  def has_actions?
20
20
  false
@@ -37,6 +37,12 @@ module Decidim
37
37
 
38
38
  has_many :contents, foreign_key: :decidim_plan_id, dependent: :destroy
39
39
 
40
+ has_many :taggings,
41
+ class_name: "Decidim::Plans::PlanTagging",
42
+ foreign_key: :decidim_plan_id,
43
+ dependent: :destroy
44
+ has_many :tags, through: :taggings
45
+
40
46
  scope :open, -> { where(state: "open") }
41
47
  scope :accepted, -> { where(state: "accepted") }
42
48
  scope :rejected, -> { where(state: "rejected") }
@@ -106,6 +112,14 @@ module Decidim
106
112
  closed_at.present?
107
113
  end
108
114
 
115
+ # Public: Checks if the plan has been closed AND not yet answered. This is
116
+ # interpreted as the plan waiting to be evaluated.
117
+ #
118
+ # Returns Boolean.
119
+ def waiting_for_evaluation?
120
+ closed? && !answered?
121
+ end
122
+
109
123
  # Public: Checks if the organization has given an answer for the plan.
110
124
  #
111
125
  # Returns Boolean.
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Plans
5
+ # A plan tagging is a record that maps the plans with the tags.
6
+ class PlanTagging < Plans::ApplicationRecord
7
+ belongs_to :plan, class_name: "Decidim::Plans::Plan", foreign_key: :decidim_plan_id
8
+ belongs_to :tag, class_name: "Decidim::Plans::Tag", foreign_key: :decidim_plans_tag_id
9
+
10
+ validates :plan, :tag, presence: true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Plans
5
+ # A tag is a record that allows providing metadata for the items to be
6
+ # tagged, i.e. the "taggables". In this context, only plans are taggable.
7
+ class Tag < Plans::ApplicationRecord
8
+ belongs_to :organization,
9
+ foreign_key: "decidim_organization_id",
10
+ class_name: "Decidim::Organization"
11
+ has_many :plan_taggings, foreign_key: :decidim_plans_tag_id, dependent: :destroy
12
+
13
+ validates :organization, presence: true
14
+
15
+ def plan_taggings_count
16
+ PlanTagging.where(tag: self).count
17
+ end
18
+ end
19
+ end
20
+ end
@@ -16,14 +16,16 @@ module Decidim
16
16
  return permission_action if permission_action.subject != :plan &&
17
17
  permission_action.subject != :plans &&
18
18
  permission_action.subject != :section &&
19
- permission_action.subject != :sections
19
+ permission_action.subject != :sections &&
20
+ permission_action.subject != :plan_tag &&
21
+ permission_action.subject != :plan_tags
20
22
 
21
23
  case permission_action.action
22
- when :create, :export_budgets
24
+ when :read, :create, :export_budgets
23
25
  permission_action.allow!
24
26
  when :edit, :update, :destroy
25
- permission_action.allow! if plan.present? || section.present?
26
- when :close
27
+ permission_action.allow! if plan.present? || section.present? || tag.present?
28
+ when :close, :edit_taggings
27
29
  permission_action.allow! if plan.present?
28
30
  end
29
31
 
@@ -36,6 +38,14 @@ module Decidim
36
38
  @plan ||= context.fetch(:plan, nil)
37
39
  end
38
40
 
41
+ def section
42
+ @section ||= context.fetch(:section, nil)
43
+ end
44
+
45
+ def tag
46
+ @tag ||= context.fetch(:tag, nil)
47
+ end
48
+
39
49
  def admin_plan_answering_is_enabled?
40
50
  current_settings.try(:plan_answering_enabled) &&
41
51
  component_settings.try(:plan_answering_enabled)
@@ -47,7 +47,7 @@ module Decidim
47
47
  end
48
48
 
49
49
  def can_edit_plan?
50
- toggle_allow(plan.open? && !plan.closed? && plan.editable_by?(user))
50
+ toggle_allow(plan.open? && plan.editable_by?(user))
51
51
  end
52
52
 
53
53
  def can_withdraw_plan?
@@ -59,6 +59,8 @@ module Decidim
59
59
  end
60
60
 
61
61
  def can_close_plan?
62
+ return toggle_allow(false) unless component_settings.closing_allowed?
63
+
62
64
  toggle_allow(plan && plan.created_by?(user))
63
65
  end
64
66
 
@@ -44,6 +44,10 @@ module Decidim
44
44
 
45
45
  "<dl>#{fields.join("\n")}</dl>".html_safe
46
46
  end
47
+
48
+ def display_mention
49
+ link_to title, plan_path
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Plans
5
+ # This query class filters all assemblies given an organization.
6
+ class ComponentPlanTags < Rectify::Query
7
+ def initialize(component)
8
+ @component = component
9
+ end
10
+
11
+ def query
12
+ q = Decidim::Plans::Tag.joins(
13
+ "LEFT JOIN decidim_plans_plan_taggings ON decidim_plans_plan_taggings.decidim_plans_tag_id = decidim_plans_tags.id"
14
+ ).joins(
15
+ "LEFT JOIN decidim_plans_plans ON decidim_plans_plans.id = decidim_plans_plan_taggings.decidim_plan_id"
16
+ ).where(
17
+ decidim_plans_tags: {
18
+ decidim_organization_id: @component.organization.id
19
+ },
20
+ decidim_plans_plans: {
21
+ decidim_component_id: @component.id
22
+ }
23
+ ).having("COUNT(decidim_plans_plan_taggings.id) > 0")
24
+ .group("decidim_plans_tags.id")
25
+ .order(Arel.sql("name ->> '#{current_locale}' ASC"))
26
+ end
27
+
28
+ private
29
+
30
+ def current_locale
31
+ I18n.locale.to_s
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Plans
5
+ # This query class filters all assemblies given an organization.
6
+ class OrganizationTags < Rectify::Query
7
+ def initialize(organization)
8
+ @organization = organization
9
+ end
10
+
11
+ def query
12
+ q = Decidim::Plans::Tag.where(
13
+ organization: @organization
14
+ )
15
+ q.order(Arel.sql("name ->> '#{current_locale}' ASC"))
16
+ end
17
+
18
+ private
19
+
20
+ def current_locale
21
+ I18n.locale.to_s
22
+ end
23
+ end
24
+ end
25
+ end
@@ -76,6 +76,12 @@ module Decidim
76
76
  query.where(id: from).or(query.where(id: to))
77
77
  end
78
78
 
79
+ def search_tag_id
80
+ return query unless tag_id.is_a? Array
81
+
82
+ query.joins(:tags).where(decidim_plans_tags: { id: tag_id })
83
+ end
84
+
79
85
  private
80
86
 
81
87
  # Internal: builds the needed query to search for a text in the organization's
@@ -19,6 +19,13 @@
19
19
  <% end %>
20
20
  </td>
21
21
  <% end %>
22
+ <td>
23
+ <% plan.tags.each do |tag| %>
24
+ <span class="label secondary">
25
+ <%= translated_attribute(tag.name) %>
26
+ </span>
27
+ <% end %>
28
+ </td>
22
29
  <td>
23
30
  <strong class="<%= plan_state_css_class plan.state %>">
24
31
  <%= humanize_plan_state plan.state %>
@@ -32,7 +39,7 @@
32
39
  <% end %>
33
40
 
34
41
  <td>
35
- <%= l plan.created_at, format: :decidim_short %>
42
+ <%= l plan.published_at, format: :decidim_short %>
36
43
  </td>
37
44
 
38
45
  <td class="table-list__actions">
@@ -40,7 +47,7 @@
40
47
  <%= icon_link_to "pencil", edit_plan_path(plan), t("actions.edit_plan", scope: "decidim.plans"), class: "action-icon--edit-plan" %>
41
48
  <% end %>
42
49
 
43
- <% if allowed_to? :close, :plan, plan: plan %>
50
+ <% if !plan.answered? && allowed_to?(:close, :plan, plan: plan) %>
44
51
  <% if plan.closed? %>
45
52
  <%= icon_link_to "action-undo", reopen_plan_path(plan), t("actions.reopen_plan", scope: "decidim.plans"), method: :post, class: "action-icon--reopen-plan" %>
46
53
  <% else %>
@@ -48,6 +55,10 @@
48
55
  <% end %>
49
56
  <% end %>
50
57
 
58
+ <% if allowed_to? :edit_taggings, :plan, plan: plan %>
59
+ <%= icon_link_to "tag", taggings_plan_path(plan), t("actions.plan_taggings", scope: "decidim.plans"), class: "action-icon--plan-taggings" %>
60
+ <% end %>
61
+
51
62
  <% if allowed_to? :create, :plan_answer %>
52
63
  <%= icon_link_to "comment-square", edit_plan_plan_answer_path(plan_id: plan.id, id: plan.id), t("actions.answer", scope: "decidim.plans"), class: " icon--small" %>
53
64
  <% else %>
@@ -29,6 +29,10 @@
29
29
  </th>
30
30
  <% end %>
31
31
 
32
+ <th>
33
+ <%= t("models.plan.fields.tags", scope: "decidim.plans")%>
34
+ </th>
35
+
32
36
  <th>
33
37
  <%= sort_link(query, :state, t("models.plan.fields.state", scope: "decidim.plans") ) %>
34
38
  </th>
@@ -61,4 +65,9 @@
61
65
  <%= paginate plans, theme: "decidim" %>
62
66
  </div>
63
67
  </div>
68
+ <div class="card-divider">
69
+ <strong><%= t ".published_plans" %>:&nbsp;</strong><span><%= counts[:published] %></span>
70
+ <span>&nbsp;|&nbsp;</span>
71
+ <strong><%= t ".draft_plans" %>:&nbsp;</strong><span><%= counts[:drafts] %></span>
72
+ </div>
64
73
  </div>
@@ -0,0 +1,67 @@
1
+ <div class="card" id="add-translations-search">
2
+ <div class="card-divider">
3
+ <h2 class="card-title flex--sbc">
4
+ <div>
5
+ <%= link_to "#{translated_attribute(plan.title)}", plans_path %>
6
+ &gt;
7
+ <%= t(".title") %>
8
+ </div>
9
+
10
+ <div class="flex--cc flex-gap--1">
11
+ <%= link_to t("actions.back", scope: "decidim.plans"), plans_path, class: "button hollow tiny button--simple" %>
12
+ <%= link_to t("actions.manage_tags", scope: "decidim.plans"), plan_tags_path(plan), class: "button tiny button--simple" if allowed_to? :create, :plan_tags %>
13
+ </div>
14
+ </h2>
15
+ </div>
16
+ <div class="card-section">
17
+ <div class="filters row" id="add-tags-search">
18
+ <div class="column medium-4">
19
+ <%= form_tag plan_tags_path(plan), method: :get do %>
20
+ <div class="filters__search">
21
+ <%= search_field_tag :term, nil, label: false, id: "data_picker-autocomplete", class: "input-group-field", placeholder: t(".search"), data: {
22
+ no_results_text: t(".no_results", name: "{{term}}"),
23
+ no_results_url: "#{new_plan_tag_path(plan, name: '', back_to_plan: 1)}{{term}}"
24
+ } %>
25
+ </div>
26
+ <% end %>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </div>
31
+
32
+ <%= decidim_form_for(@form, url: update_taggings_plan_path(plan), html: { class: "form translations-form update_taggings plan_taggings_form_admin" }) do |f| %>
33
+ <div class="card hide" id="plan-tags-results" data-results="<%= plan.tags.collect { |t| [t.id, translated_attribute(t.name)] } %>">
34
+ <div class="card-section">
35
+ <div class="table-scroll">
36
+ <script type="text/template" class="decidim-template">
37
+ <tr>
38
+ <td>{{tag_id}}</td>
39
+ <td>{{tag_name}}</td>
40
+ <td>
41
+ <input type="hidden" name="tags[]" value="{{tag_id}}">
42
+ <%= icon_link_to "circle-x", "#", t("actions.destroy", scope: "decidim.plans"), class: "remove-tagging action-icon--remove" %>
43
+ </td>
44
+ </tr>
45
+ </script>
46
+
47
+ <table class="table-list">
48
+ <thead>
49
+ <tr>
50
+ <th><%= t("models.plan_tags.fields.id", scope: "decidim.plans") %></th>
51
+ <th><%= t("models.plan_tags.fields.name", scope: "decidim.plans") %></th>
52
+ <th></th>
53
+ </tr>
54
+ </thead>
55
+ <tbody>
56
+ </tbody>
57
+ </table>
58
+ </div>
59
+ </div>
60
+ </div>
61
+
62
+ <div class="button--double form-general-submit">
63
+ <%= f.submit t(".update") %>
64
+ </div>
65
+ <% end %>
66
+
67
+ <%= javascript_include_tag "decidim/plans/admin/plans" %>
@@ -0,0 +1,21 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title">
4
+ <%= link_to "#{translated_attribute(plan.title)}", plans_path %>
5
+ &gt;
6
+ <%= link_to t(".tags"), taggings_plan_path(plan) %>
7
+ &gt;
8
+ <%= title %>
9
+
10
+ <div class="button--title">
11
+ <%= link_to t("actions.back", scope: "decidim.plans"), taggings_plan_path(plan), class: "button hollow tiny button--simple" %>
12
+ </div>
13
+ </h2>
14
+ </div>
15
+
16
+ <%= form.hidden_field :back_to_plan %>
17
+
18
+ <div class="card-section">
19
+ <%= form.translated :text_field, :name %>
20
+ </div>
21
+ </div>
@@ -0,0 +1,7 @@
1
+ <%= decidim_form_for(@form, url: plan_tag_path(plan, @form), html: { class: "form plans-form new_plan plan_form_admin" }) do |f| %>
2
+ <%= render partial: "form", object: f, locals: { title: t(".title") } %>
3
+
4
+ <div class="button--double form-general-submit">
5
+ <%= f.submit t(".update") %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,52 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title flex--sbc">
4
+ <div>
5
+ <%= link_to "#{translated_attribute(plan.title)}", plans_path %>
6
+ &gt;
7
+ <%= link_to t(".tags"), taggings_plan_path(plan) %>
8
+ &gt;
9
+ <%= t(".title") %>
10
+ </div>
11
+
12
+ <div class="flex--cc flex-gap--1">
13
+ <%= link_to t("actions.back", scope: "decidim.plans"), taggings_plan_path(plan), class: "button hollow tiny button--simple" %>
14
+ <%= link_to t("actions.new_tag", scope: "decidim.plans"), new_plan_tag_path(plan), class: "button tiny button--simple" if allowed_to? :create, :plan_tags %>
15
+ </div>
16
+ </h2>
17
+ </div>
18
+
19
+ <div class="card-section">
20
+ <div class="table-scroll">
21
+ <table class="table-list">
22
+ <thead>
23
+ <tr>
24
+ <th><%= t("models.plan_tags.fields.id", scope: "decidim.plans") %></th>
25
+ <th><%= t("models.plan_tags.fields.name", scope: "decidim.plans") %></th>
26
+ <th><%= t("models.plan_tags.fields.taggings_count", scope: "decidim.plans") %></th>
27
+ <th></th>
28
+ </tr>
29
+ </thead>
30
+ <tbody>
31
+ <% tags.each do |tag| %>
32
+ <tr>
33
+ <td><%= tag.id %></td>
34
+ <td><%= translated_attribute(tag.name) %></td>
35
+ <td><%= tag.plan_taggings_count %></td>
36
+ <td class="table-list__actions">
37
+ <% if allowed_to? :edit, :plan_tag, tag: tag %>
38
+ <%= icon_link_to "pencil", edit_plan_tag_path(plan, tag), t("actions.edit", scope: "decidim.plans"), class: "action-icon--edit" %>
39
+ <% end %>
40
+
41
+ <% if allowed_to? :destroy, :plan_tag, tag: tag %>
42
+ <%= icon_link_to "circle-x", plan_tag_path(plan, tag), t("actions.destroy", scope: "decidim.plans"), method: :delete, class: "action-icon--remove", data: { confirm: t("actions.confirm_destroy", scope: "decidim.plans") } %>
43
+ <% end %>
44
+ </td>
45
+ </tr>
46
+ <% end %>
47
+ </tbody>
48
+ </table>
49
+ <%= paginate tags, theme: "decidim" %>
50
+ </div>
51
+ </div>
52
+ </div>
@@ -0,0 +1,7 @@
1
+ <%= decidim_form_for(@form, url: plan_tags_path(plan, @form), html: { class: "form plans-form new_plan plan_form_admin" }) do |f| %>
2
+ <%= render partial: "form", object: f, locals: { title: t(".title") } %>
3
+
4
+ <div class="button--double form-general-submit">
5
+ <%= f.submit t(".create") %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <div class="reveal" id="evaluationModal" data-reveal>
2
+ <div class="reveal__header">
3
+ <h3 class="reveal__title"><%= t(".title") %></h3>
4
+ <button class="close-button" data-close aria-label="<%= t(".close") %>"
5
+ type="button">
6
+ <span aria-hidden="true">&times;</span>
7
+ </button>
8
+ </div>
9
+ <div class="row">
10
+ <div class="columns medium-8 medium-centered">
11
+ <p class="text-center">
12
+ <%= t(".description") %>
13
+ </p>
14
+
15
+ <div class="actions">
16
+ <button class="button expanded" data-close type="button">
17
+ <%= t(".button_text") %>
18
+ </button>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </div>
@@ -28,5 +28,9 @@
28
28
  <%= form.categories_select :category_id, current_component.categories, legend_title: t(".category"), disable_parents: false, label: false, prompt: t(".category_prompt") %>
29
29
  <% end %>
30
30
 
31
+ <% if available_tags.any? %>
32
+ <%= form.collection_check_boxes :tag_id, available_tags, ->(p) { "#{p.id}" }, ->(p) { translated_attribute(p.name) }, legend_title: t(".tag"), disable_parents: false, label: false, prompt: t(".tag_prompt") %>
33
+ <% end %>
34
+
31
35
  <%= hidden_field_tag :order, order, id: nil, class: "order_filter" %>
32
36
  <% end %>
@@ -46,6 +46,11 @@
46
46
 
47
47
  <% if allowed_to?(:edit, :plan, plan: @plan) %>
48
48
  <%= link_to t("edit", scope:"decidim.plans.plans.show"), edit_plan_path(@plan), class: "button secondary hollow expanded button--sc mt-s", id: "plan_edit" %>
49
+ <% elsif @plan.editable_by?(current_user) && @plan.waiting_for_evaluation? %>
50
+ <span class="button secondary hollow expanded button--sc mt-s disabled" data-open="evaluationModal">
51
+ <%= t("edit", scope:"decidim.plans.plans.show") %>
52
+ </span>
53
+ <p><%= t("plan_waiting_for_evaluation", scope:"decidim.plans.plans.show") %></p>
49
54
  <% end %>
50
55
  <% if allowed_to?(:close, :plan, plan: @plan) && !@plan.closed? %>
51
56
  <%= link_to t("close", scope:"decidim.plans.plans.show"), close_plan_path(@plan), method: :post, class: "button secondary hollow expanded button--sc mt-s", id: "plan_close", data: { confirm: t("close_confirm", scope:"decidim.plans.plans.show") } %>
@@ -93,7 +98,7 @@
93
98
  <div class="section">
94
99
  <%== cell("decidim/plans/plan_m", @plan, full_badge: true).badge %>
95
100
  <%= render partial: "contents" %>
96
- <%= cell "decidim/tags", @plan, context: { extra_classes: ["tags--plan"] } %>
101
+ <%= cell "decidim/plans/tags", @plan, context: { extra_classes: ["tags--plan"] } %>
97
102
  </div>
98
103
  <% if @plan.answered? && translated_attribute(@plan.answer).present? %>
99
104
  <% if @plan.accepted? %>
@@ -136,3 +141,6 @@
136
141
  url: decidim.report_path(sgid: @plan.to_sgid.to_s)
137
142
  }
138
143
  %>
144
+ <% if @plan.editable_by?(current_user) && @plan.waiting_for_evaluation? %>
145
+ <%= render partial: "evaluation_modal" %>
146
+ <% end %>
@@ -1,10 +1,10 @@
1
1
  <% if component_settings.attachments_allowed? %>
2
2
  <div class="multifield-fields attachments-container" data-placeholder-id="<%= blank_attachment.to_param %>">
3
- <template>
3
+ <script type="text/template" class="decidim-template">
4
4
  <%= fields_for "#{form.object_name}[attachments][#{blank_attachment.to_param}]", blank_attachment do |attachment_form| %>
5
5
  <%= render partial: "decidim/plans/shared/attachment_fields", object: attachment_form, locals: { form: attachment_form, id: tabs_id_for_attachment(blank_attachment) } %>
6
6
  <% end %>
7
- </template>
7
+ </script>
8
8
 
9
9
  <fieldset>
10
10
  <legend><%= t(".legend") %></legend>
@@ -0,0 +1 @@
1
+ <%= cell "decidim/plans/tags", resource, context: { extra_classes: [tags_class_extra] } %>