decidim-consultations 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/consultations/utils_multiple.js +1 -1
- data/app/assets/stylesheets/decidim/consultations/_question_multiple_votes.scss +22 -0
- data/app/assets/stylesheets/decidim/consultations/consultations.scss +1 -0
- data/app/commands/decidim/consultations/admin/create_response.rb +2 -1
- data/app/commands/decidim/consultations/admin/create_response_group.rb +40 -0
- data/app/commands/decidim/consultations/admin/destroy_response_group.rb +39 -0
- data/app/commands/decidim/consultations/admin/update_response.rb +3 -2
- data/app/commands/decidim/consultations/admin/update_response_group.rb +46 -0
- data/app/controllers/decidim/consultations/admin/response_groups_controller.rb +88 -0
- data/app/controllers/decidim/consultations/admin/responses_controller.rb +1 -0
- data/app/forms/decidim/consultations/admin/response_form.rb +5 -0
- data/app/forms/decidim/consultations/admin/response_group_form.rb +18 -0
- data/app/helpers/decidim/consultations/admin/questions_helper.rb +11 -0
- data/app/models/decidim/consultation.rb +11 -0
- data/app/models/decidim/consultations/question.rb +22 -0
- data/app/models/decidim/consultations/response.rb +7 -0
- data/app/models/decidim/consultations/response_group.rb +19 -0
- data/app/permissions/decidim/consultations/admin/permissions.rb +16 -0
- data/app/views/decidim/consultations/admin/response_groups/_form.html.erb +11 -0
- data/app/views/decidim/consultations/admin/response_groups/edit.html.erb +18 -0
- data/app/views/decidim/consultations/admin/response_groups/index.html.erb +56 -0
- data/app/views/decidim/consultations/admin/response_groups/new.html.erb +13 -0
- data/app/views/decidim/consultations/admin/responses/_form.html.erb +3 -0
- data/app/views/decidim/consultations/admin/responses/index.html.erb +12 -1
- data/app/views/decidim/consultations/question_multiple_votes/_form.html.erb +14 -10
- data/app/views/decidim/consultations/question_multiple_votes/show.html.erb +8 -2
- data/app/views/layouts/decidim/admin/question.html.erb +1 -1
- data/config/locales/ca.yml +13 -0
- data/config/locales/cs.yml +25 -0
- data/config/locales/en.yml +25 -0
- data/config/locales/fi-plain.yml +25 -0
- data/config/locales/fi.yml +25 -0
- data/config/locales/fr.yml +25 -0
- data/config/locales/hu.yml +25 -0
- data/config/locales/it.yml +25 -0
- data/config/locales/nl.yml +25 -0
- data/config/locales/no.yml +2 -0
- data/config/locales/sv.yml +15 -0
- data/db/migrate/20190708114204_create_decidim_consultations_response_groups.rb +16 -0
- data/db/migrate/20190708120345_add_response_groups_count_to_decidim_consultations_questions.rb +7 -0
- data/db/migrate/20190708121643_add_response_groups_to_decidim_consultations_responses.rb +10 -0
- data/lib/decidim/consultations/admin_engine.rb +1 -0
- data/lib/decidim/consultations/participatory_space.rb +4 -0
- data/lib/decidim/consultations/test/factories.rb +5 -0
- data/lib/decidim/consultations/version.rb +1 -1
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 770756382de23cf53682dd57ab217078711bf73a1e8c2df0a8f56afdc7ebe745
|
4
|
+
data.tar.gz: 764efb1bf1e01147a7b5a82203ff7f8ba64e2910181d9dfc0f850c1a5011d76e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c13bfb201a61ef24723c27f2ee4b0e2573ee01178b2b29b1b86e7998e4824932f11698f846a541f45dcda0716ec89ee85df67f928d6b481665128ff42a975e9c
|
7
|
+
data.tar.gz: 7e1f3862681a23cfcbbb1f744d2a686e9576e6ff4c07efe55a8504226b473c60ea0726143852126f1fa6d3e45cc748f3e5cc484de35cf9c052638b12b8eb8ede
|
@@ -0,0 +1,22 @@
|
|
1
|
+
.question-masonry-group{
|
2
|
+
$masonry-css-column-gap: $global-margin;
|
3
|
+
|
4
|
+
column-count: 1;
|
5
|
+
column-gap: $masonry-css-column-gap;
|
6
|
+
|
7
|
+
@include breakpoint(map-get($breakpoints, medium)){
|
8
|
+
column-count: 2;
|
9
|
+
}
|
10
|
+
|
11
|
+
@include breakpoint(map-get($breakpoints, large)){
|
12
|
+
column-count: 3;
|
13
|
+
}
|
14
|
+
|
15
|
+
.column{
|
16
|
+
// override float styles from foundation
|
17
|
+
float: none !important;
|
18
|
+
width: auto !important;
|
19
|
+
break-inside: avoid;
|
20
|
+
margin-bottom: $masonry-css-column-gap;
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Consultations
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic when creating a new response group
|
7
|
+
class CreateResponseGroup < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params.
|
11
|
+
def initialize(form)
|
12
|
+
@form = form
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
broadcast(:ok, create_response_group)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :form
|
30
|
+
|
31
|
+
def create_response_group
|
32
|
+
ResponseGroup.create(
|
33
|
+
question: form.context.current_question,
|
34
|
+
title: form.title
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Consultations
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic to destroy a response group in the
|
7
|
+
# system.
|
8
|
+
class DestroyResponseGroup < Rectify::Command
|
9
|
+
# Public: Initializes the command.
|
10
|
+
#
|
11
|
+
# response_group - A ResponseGroup that will be destroyed
|
12
|
+
def initialize(response_group)
|
13
|
+
@response_group = response_group
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if the data wasn't valid and we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
return broadcast(:invalid) if response_group.nil? || response_group.responses.any?
|
24
|
+
|
25
|
+
destroy_response_group
|
26
|
+
broadcast(:ok)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :response_group
|
32
|
+
|
33
|
+
def destroy_response_group
|
34
|
+
response_group.destroy!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -33,12 +33,13 @@ module Decidim
|
|
33
33
|
|
34
34
|
def update_response
|
35
35
|
response.assign_attributes(attributes)
|
36
|
-
response.save
|
36
|
+
response.save!
|
37
37
|
end
|
38
38
|
|
39
39
|
def attributes
|
40
40
|
{
|
41
|
-
title: form.title
|
41
|
+
title: form.title,
|
42
|
+
response_group: form.response_group
|
42
43
|
}
|
43
44
|
end
|
44
45
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Consultations
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic when updating a new response group
|
7
|
+
class UpdateResponseGroup < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# response_group - the response group to update
|
11
|
+
# form - A form object with the params.
|
12
|
+
def initialize(response_group, form)
|
13
|
+
@response_group = response_group
|
14
|
+
@form = form
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Broadcasts these events:
|
18
|
+
#
|
19
|
+
# - :ok when everything is valid.
|
20
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
return broadcast(:invalid) if form.invalid?
|
25
|
+
|
26
|
+
broadcast(:ok, update_response_group)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :form, :response_group
|
32
|
+
|
33
|
+
def update_response_group
|
34
|
+
response_group.assign_attributes(attributes)
|
35
|
+
response_group.save!
|
36
|
+
end
|
37
|
+
|
38
|
+
def attributes
|
39
|
+
{
|
40
|
+
title: form.title
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Consultations
|
5
|
+
module Admin
|
6
|
+
# Controller that manages responses for a question
|
7
|
+
class ResponseGroupsController < Decidim::Consultations::Admin::ApplicationController
|
8
|
+
include QuestionAdmin
|
9
|
+
|
10
|
+
helper_method :current_response_group
|
11
|
+
|
12
|
+
def index
|
13
|
+
enforce_permission_to :read, :response_group, question: current_question
|
14
|
+
end
|
15
|
+
|
16
|
+
def new
|
17
|
+
enforce_permission_to :create, :response_group, question: current_question
|
18
|
+
@form = response_group_form.instance
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
enforce_permission_to :create, :response_group, question: current_question
|
23
|
+
@form = response_group_form.from_params(params, current_question: current_question)
|
24
|
+
|
25
|
+
CreateResponseGroup.call(@form) do
|
26
|
+
on(:ok) do
|
27
|
+
flash[:notice] = I18n.t("response_groups.create.success", scope: "decidim.admin")
|
28
|
+
redirect_to response_groups_path(current_question)
|
29
|
+
end
|
30
|
+
|
31
|
+
on(:invalid) do
|
32
|
+
flash.now[:alert] = I18n.t("response_groups.create.error", scope: "decidim.admin")
|
33
|
+
render :new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def edit
|
39
|
+
enforce_permission_to :update, :response_group, response_group: current_response_group
|
40
|
+
@form = response_group_form.from_model(current_response_group)
|
41
|
+
end
|
42
|
+
|
43
|
+
def update
|
44
|
+
enforce_permission_to :update, :response_group, response_group: current_response_group
|
45
|
+
|
46
|
+
@form = response_group_form.from_params(params)
|
47
|
+
UpdateResponseGroup.call(current_response_group, @form) do
|
48
|
+
on(:ok) do
|
49
|
+
flash[:notice] = I18n.t("response_groups.update.success", scope: "decidim.admin")
|
50
|
+
redirect_to response_groups_path(current_question)
|
51
|
+
end
|
52
|
+
|
53
|
+
on(:invalid) do
|
54
|
+
flash.now[:alert] = I18n.t("response_groups.update.error", scope: "decidim.admin")
|
55
|
+
render :edit
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def destroy
|
61
|
+
enforce_permission_to :destroy, :response_group, response_group: current_response_group
|
62
|
+
|
63
|
+
DestroyResponseGroup.call(current_response_group) do
|
64
|
+
on(:ok) do
|
65
|
+
flash[:notice] = I18n.t("response_groups.destroy.success", scope: "decidim.admin")
|
66
|
+
end
|
67
|
+
|
68
|
+
on(:invalid) do
|
69
|
+
flash[:alert] = I18n.t("response_groups.destroy.error", scope: "decidim.admin")
|
70
|
+
end
|
71
|
+
|
72
|
+
redirect_to response_groups_path(current_question)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def current_response_group
|
79
|
+
@current_response_group ||= ResponseGroup.find_by(id: params[:id])
|
80
|
+
end
|
81
|
+
|
82
|
+
def response_group_form
|
83
|
+
form(ResponseGroupForm)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -10,8 +10,13 @@ module Decidim
|
|
10
10
|
mimic :response
|
11
11
|
|
12
12
|
translatable_attribute :title, String
|
13
|
+
attribute :decidim_consultations_response_group_id, Integer
|
13
14
|
|
14
15
|
validates :title, translatable_presence: true
|
16
|
+
|
17
|
+
def response_group
|
18
|
+
ResponseGroup.find_by(id: decidim_consultations_response_group_id) if decidim_consultations_response_group_id
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Consultations
|
5
|
+
module Admin
|
6
|
+
# A form object used to create responses for a question from the admin dashboard.
|
7
|
+
class ResponseGroupForm < Form
|
8
|
+
include TranslatableAttributes
|
9
|
+
|
10
|
+
mimic :response_group
|
11
|
+
|
12
|
+
translatable_attribute :title, String
|
13
|
+
|
14
|
+
validates :title, translatable_presence: true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -5,9 +5,20 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# Helper for questions controller
|
7
7
|
module QuestionsHelper
|
8
|
+
include Decidim::TranslationsHelper
|
9
|
+
|
10
|
+
Option = Struct.new(:id, :title)
|
11
|
+
|
8
12
|
def question_example_slug
|
9
13
|
"question-#{Time.now.utc.year}-#{Time.now.utc.month}-1"
|
10
14
|
end
|
15
|
+
|
16
|
+
def question_response_groups(question = current_question)
|
17
|
+
[Option.new("", "-")] +
|
18
|
+
question.response_groups.map do |group|
|
19
|
+
Option.new(group.id, translated_attribute(group.title))
|
20
|
+
end
|
21
|
+
end
|
11
22
|
end
|
12
23
|
end
|
13
24
|
end
|
@@ -11,6 +11,7 @@ module Decidim
|
|
11
11
|
include Decidim::Loggable
|
12
12
|
include Decidim::ParticipatorySpaceResourceable
|
13
13
|
include Decidim::Randomable
|
14
|
+
include Decidim::Searchable
|
14
15
|
|
15
16
|
belongs_to :organization,
|
16
17
|
foreign_key: "decidim_organization_id",
|
@@ -41,6 +42,16 @@ module Decidim
|
|
41
42
|
scope :finished, -> { published.where("end_voting_date < ?", Time.now.utc) }
|
42
43
|
scope :order_by_most_recent, -> { order(created_at: :desc) }
|
43
44
|
|
45
|
+
searchable_fields({
|
46
|
+
participatory_space: :itself,
|
47
|
+
A: :title,
|
48
|
+
B: :subtitle,
|
49
|
+
D: :description,
|
50
|
+
datetime: :published_at
|
51
|
+
},
|
52
|
+
index_on_create: ->(_process) { false },
|
53
|
+
index_on_update: ->(process) { process.visible? })
|
54
|
+
|
44
55
|
def to_param
|
45
56
|
slug
|
46
57
|
end
|
@@ -39,6 +39,12 @@ module Decidim
|
|
39
39
|
inverse_of: :question,
|
40
40
|
dependent: :destroy
|
41
41
|
|
42
|
+
has_many :response_groups,
|
43
|
+
foreign_key: "decidim_consultations_questions_id",
|
44
|
+
class_name: "Decidim::Consultations::ResponseGroup",
|
45
|
+
inverse_of: :question,
|
46
|
+
dependent: :destroy
|
47
|
+
|
42
48
|
has_many :categories,
|
43
49
|
foreign_key: "decidim_participatory_space_id",
|
44
50
|
foreign_type: "decidim_participatory_space_type",
|
@@ -88,6 +94,22 @@ module Decidim
|
|
88
94
|
max_votes > 1
|
89
95
|
end
|
90
96
|
|
97
|
+
# Sorted responses by date so admins have a way to predict it
|
98
|
+
def sorted_responses
|
99
|
+
@sorted_responses ||= responses.sort_by(&:created_at)
|
100
|
+
end
|
101
|
+
|
102
|
+
# matrix of responses by group (sorted by configuration)
|
103
|
+
def grouped_responses
|
104
|
+
@grouped_responses ||= sorted_responses.group_by(&:response_group)
|
105
|
+
end
|
106
|
+
|
107
|
+
def grouped?
|
108
|
+
return false unless multiple?
|
109
|
+
|
110
|
+
response_groups_count.positive?
|
111
|
+
end
|
112
|
+
|
91
113
|
# Public: Overrides the `comments_have_alignment?` Commentable concern method.
|
92
114
|
def comments_have_alignment?
|
93
115
|
true
|
@@ -14,6 +14,13 @@ module Decidim
|
|
14
14
|
class_name: "Decidim::Consultations::Vote",
|
15
15
|
inverse_of: :response,
|
16
16
|
dependent: :restrict_with_error
|
17
|
+
|
18
|
+
belongs_to :response_group,
|
19
|
+
foreign_key: "decidim_consultations_response_group_id",
|
20
|
+
class_name: "Decidim::Consultations::ResponseGroup",
|
21
|
+
inverse_of: :responses,
|
22
|
+
counter_cache: :responses_count,
|
23
|
+
optional: true
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Consultations
|
5
|
+
class ResponseGroup < ApplicationRecord
|
6
|
+
belongs_to :question,
|
7
|
+
foreign_key: "decidim_consultations_questions_id",
|
8
|
+
class_name: "Decidim::Consultations::Question",
|
9
|
+
counter_cache: :response_groups_count,
|
10
|
+
inverse_of: :response_groups
|
11
|
+
|
12
|
+
has_many :responses,
|
13
|
+
foreign_key: "decidim_consultations_response_group_id",
|
14
|
+
class_name: "Decidim::Consultations::Response",
|
15
|
+
inverse_of: :response_group,
|
16
|
+
dependent: :restrict_with_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -27,6 +27,7 @@ module Decidim
|
|
27
27
|
allowed_consultation_action?
|
28
28
|
allowed_question_action?
|
29
29
|
allowed_response_action?
|
30
|
+
allowed_response_group_action?
|
30
31
|
|
31
32
|
permission_action
|
32
33
|
end
|
@@ -45,6 +46,10 @@ module Decidim
|
|
45
46
|
@response ||= context.fetch(:response, nil)
|
46
47
|
end
|
47
48
|
|
49
|
+
def response_group
|
50
|
+
@response_group ||= context.fetch(:response_group, nil)
|
51
|
+
end
|
52
|
+
|
48
53
|
def allowed_action_on_component?
|
49
54
|
return unless permission_action.subject == :component
|
50
55
|
|
@@ -90,6 +95,17 @@ module Decidim
|
|
90
95
|
end
|
91
96
|
end
|
92
97
|
|
98
|
+
def allowed_response_group_action?
|
99
|
+
return unless permission_action.subject == :response_group
|
100
|
+
|
101
|
+
case permission_action.action
|
102
|
+
when :create, :read
|
103
|
+
toggle_allow(question&.multiple?)
|
104
|
+
when :update, :destroy
|
105
|
+
toggle_allow(response_group.present?)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
93
109
|
# Only admin users can enter the consultations area.
|
94
110
|
def user_can_enter_space_area?
|
95
111
|
return unless permission_action.action == :enter &&
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-divider">
|
3
|
+
<h2 class="card-title"><%= t "response_groups.form.title", scope: "decidim.admin" %></h2>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div class="card-section">
|
7
|
+
<div class="row column">
|
8
|
+
<%= form.translated :text_field, :title, autofocus: true %>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%= decidim_form_for @form,
|
2
|
+
url: response_group_path(current_question, current_response_group),
|
3
|
+
html: { class: "form edit_response_group" } do |f| %>
|
4
|
+
<%= render partial: "form", object: f %>
|
5
|
+
<div class="button--double form-general-submit">
|
6
|
+
<%= f.submit t("response_groups.edit.update", scope: "decidim.admin"),
|
7
|
+
class: "button",
|
8
|
+
data: { disable_with: true } %>
|
9
|
+
|
10
|
+
<% if allowed_to? :destroy, :response_group, response_group: current_response_group %>
|
11
|
+
<%= link_to t("decidim.admin.actions.destroy"),
|
12
|
+
response_group_path(current_question, current_response_group),
|
13
|
+
method: :delete,
|
14
|
+
class: "alert button",
|
15
|
+
data: { confirm: t("decidim.admin.actions.confirm_destroy") } %>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<div class="card" id="questions">
|
2
|
+
<div class="card-divider">
|
3
|
+
<h2 class="card-title">
|
4
|
+
<%= t "decidim.admin.titles.response_groups" %>
|
5
|
+
<%= link_to t("actions.new_response_group", scope: "decidim.admin"),
|
6
|
+
new_response_group_path(current_question),
|
7
|
+
class: "button tiny button--title" if allowed_to? :create, :response_group, question: current_question %>
|
8
|
+
<%= link_to t("actions.back_to_responses", scope: "decidim.admin"),
|
9
|
+
responses_path(current_question),
|
10
|
+
class: "button tiny button--title" if allowed_to? :read, :response %>
|
11
|
+
</h2>
|
12
|
+
</div>
|
13
|
+
<div class="card-section">
|
14
|
+
<p>
|
15
|
+
<%= t "decidim.admin.response_groups.help" %>
|
16
|
+
</p>
|
17
|
+
</div>
|
18
|
+
<div class="card-section">
|
19
|
+
<div class="table-scroll">
|
20
|
+
<table class="table-list">
|
21
|
+
<thead>
|
22
|
+
<tr>
|
23
|
+
<th><%= t("models.response.fields.title", scope: "decidim.admin") %></th>
|
24
|
+
<th><%= t("models.response.fields.created_at", scope: "decidim.admin") %></th>
|
25
|
+
<th></th>
|
26
|
+
</tr>
|
27
|
+
</thead>
|
28
|
+
<tbody>
|
29
|
+
<% current_question.response_groups.each do |group| %>
|
30
|
+
<tr>
|
31
|
+
<td>
|
32
|
+
<% if allowed_to? :update, :response_group, response_group: group %>
|
33
|
+
<%= link_to translated_attribute(group.title),
|
34
|
+
edit_response_group_path(current_question, group) %>
|
35
|
+
<% else %>
|
36
|
+
<%= translated_attribute(group.title) %>
|
37
|
+
<% end %>
|
38
|
+
</td>
|
39
|
+
<td>
|
40
|
+
<%= l group.created_at, format: :short %>
|
41
|
+
</td>
|
42
|
+
<td class="table-list__actions">
|
43
|
+
<% if allowed_to? :update, :response_group, response_group: group %>
|
44
|
+
<%= icon_link_to "pencil",
|
45
|
+
edit_response_group_path(current_question, group),
|
46
|
+
t("actions.configure", scope: "decidim.admin"),
|
47
|
+
class: "action-icon--edit" %>
|
48
|
+
<% end %>
|
49
|
+
</td>
|
50
|
+
</tr>
|
51
|
+
<% end %>
|
52
|
+
</tbody>
|
53
|
+
</table>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<h2 class="questions-title-summary">
|
2
|
+
<%= t "response_groups.new.title", scope: "decidim.admin" %>
|
3
|
+
</h2>
|
4
|
+
|
5
|
+
<%= decidim_form_for @form,
|
6
|
+
url: response_groups_path(current_question),
|
7
|
+
html: { class: "form new_response_group" } do |f| %>
|
8
|
+
<%= render partial: "form", object: f %>
|
9
|
+
|
10
|
+
<div class="button--double form-general-submit">
|
11
|
+
<%= f.submit t("response_groups.new.create", scope: "decidim.admin"), data: { disable_with: true } %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
@@ -6,6 +6,9 @@
|
|
6
6
|
<div class="card-section">
|
7
7
|
<div class="row column">
|
8
8
|
<%= form.translated :text_field, :title, autofocus: true %>
|
9
|
+
<% if allowed_to? :create, :response_group, question: current_question %>
|
10
|
+
<%= form.collection_select :decidim_consultations_response_group_id, question_response_groups, :id, :title %>
|
11
|
+
<% end %>
|
9
12
|
</div>
|
10
13
|
</div>
|
11
14
|
</div>
|
@@ -5,6 +5,9 @@
|
|
5
5
|
<%= link_to t("actions.new_response", scope: "decidim.admin"),
|
6
6
|
new_response_path(current_question),
|
7
7
|
class: "button tiny button--title" if allowed_to? :create, :response %>
|
8
|
+
<%= link_to t("actions.response_groups", scope: "decidim.admin"),
|
9
|
+
response_groups_path(current_question),
|
10
|
+
class: "button tiny button--title" if allowed_to? :create, :response_group, question: current_question %>
|
8
11
|
</h2>
|
9
12
|
</div>
|
10
13
|
<div class="card-section">
|
@@ -13,12 +16,15 @@
|
|
13
16
|
<thead>
|
14
17
|
<tr>
|
15
18
|
<th><%= t("models.response.fields.title", scope: "decidim.admin") %></th>
|
19
|
+
<% if allowed_to? :create, :response_group, question: current_question %>
|
20
|
+
<th><%= t("models.response.fields.response_group", scope: "decidim.admin") %></th>
|
21
|
+
<% end %>
|
16
22
|
<th><%= t("models.response.fields.created_at", scope: "decidim.admin") %></th>
|
17
23
|
<th></th>
|
18
24
|
</tr>
|
19
25
|
</thead>
|
20
26
|
<tbody>
|
21
|
-
<% current_question.
|
27
|
+
<% current_question.sorted_responses.each do |response| %>
|
22
28
|
<tr>
|
23
29
|
<td>
|
24
30
|
<% if allowed_to? :update, :response, response: response %>
|
@@ -28,6 +34,11 @@
|
|
28
34
|
<%= translated_attribute(response.title) %>
|
29
35
|
<% end %>
|
30
36
|
</td>
|
37
|
+
<% if allowed_to? :create, :response_group, question: current_question %>
|
38
|
+
<td>
|
39
|
+
<%= translated_attribute(response&.response_group&.title) %>
|
40
|
+
</td>
|
41
|
+
<% end %>
|
31
42
|
<td>
|
32
43
|
<%= l response.created_at, format: :short %>
|
33
44
|
</td>
|