decidim-templates 0.24.1 → 0.25.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-templates might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/commands/decidim/templates/admin/apply_questionnaire_template.rb +3 -27
- data/app/commands/decidim/templates/admin/copy_questionnaire_template.rb +2 -26
- data/app/commands/decidim/templates/admin/questionnaire_copier.rb +65 -0
- data/app/controllers/decidim/templates/admin/questionnaire_templates_controller.rb +3 -2
- data/app/packs/entrypoints/decidim_templates.js +4 -0
- data/app/packs/entrypoints/decidim_templates.scss +1 -0
- data/app/{assets/images/decidim/templates/icon.svg → packs/images/decidim/templates/decidim_templates.svg} +0 -0
- data/app/{assets → packs}/stylesheets/decidim/templates/templates.scss +0 -0
- data/app/views/decidim/templates/admin/questionnaire_templates/_choose.html.erb +1 -1
- data/app/views/decidim/templates/admin/questionnaire_templates/_preview.html.erb +1 -1
- data/app/views/decidim/templates/admin/questionnaire_templates/index.html.erb +1 -1
- data/app/views/layouts/decidim/admin/templates.html.erb +1 -1
- data/config/assets.rb +8 -0
- data/config/locales/ca.yml +7 -0
- data/config/locales/cs.yml +7 -0
- data/config/locales/en.yml +7 -0
- data/config/locales/fi-plain.yml +7 -0
- data/config/locales/fi.yml +7 -0
- data/config/locales/fr-CA.yml +7 -0
- data/config/locales/fr-LU.yml +67 -0
- data/config/locales/fr.yml +7 -0
- data/config/locales/gl.yml +7 -0
- data/config/locales/it.yml +8 -0
- data/config/locales/ja.yml +7 -0
- data/config/locales/lb-LU.yml +1 -0
- data/config/locales/nl.yml +7 -0
- data/config/locales/pl.yml +1 -1
- data/config/locales/pt-BR.yml +66 -0
- data/config/locales/ro-RO.yml +7 -0
- data/db/seeds.rb +2 -2
- data/lib/decidim/templates/admin_engine.rb +9 -14
- data/lib/decidim/templates/engine.rb +0 -4
- data/lib/decidim/templates/test/factories.rb +7 -0
- data/lib/decidim/templates/test/shared_examples/copies_all_questionnaire_contents_examples.rb +67 -0
- data/lib/decidim/templates/version.rb +1 -1
- metadata +21 -17
- data/app/assets/config/decidim_templates_manifest.css +0 -3
- data/app/assets/config/decidim_templates_manifest.js +0 -0
- data/app/helpers/decidim/templates/admin/templates_menu_helper.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9065f2481cfb457b92633e575ea0c921a31026eb34de44c7d183b4178979386a
|
4
|
+
data.tar.gz: 2618e4040581aff62c42d4c3cc5d0fa76b8f028a84e658fe45ec085bf9c3384c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1341c5b8cadc07523308f88eae9e1aaca7eb10059e91998e970188dadd697a93446d4b061e4a6cc07ca3201c9320971fc0037e3e0fe1e472ecf67fef4c327454
|
7
|
+
data.tar.gz: 8ce7b1e44ac81a2ba2bb6df740f1e0c13da5ff8581b6112f485955a64ec21e9997222fa3e16452bc2f922aedeb690ee00a9b794f345341701033dd199da917df
|
@@ -5,6 +5,8 @@ module Decidim
|
|
5
5
|
# A command with all the business logic when duplicating a questionnaire template
|
6
6
|
module Admin
|
7
7
|
class ApplyQuestionnaireTemplate < Rectify::Command
|
8
|
+
include Decidim::Templates::Admin::QuestionnaireCopier
|
9
|
+
|
8
10
|
# Public: Initializes the command.
|
9
11
|
#
|
10
12
|
# template - The template we want to apply
|
@@ -21,7 +23,7 @@ module Decidim
|
|
21
23
|
#
|
22
24
|
# Returns nothing.
|
23
25
|
def call
|
24
|
-
return broadcast(:invalid) unless @template.valid?
|
26
|
+
return broadcast(:invalid) unless @template && @template.valid?
|
25
27
|
|
26
28
|
Template.transaction do
|
27
29
|
apply_template
|
@@ -42,32 +44,6 @@ module Decidim
|
|
42
44
|
tos: @template.templatable.tos
|
43
45
|
)
|
44
46
|
end
|
45
|
-
|
46
|
-
def copy_questionnaire_questions(original_questionnaire, new_questionnaire)
|
47
|
-
original_questionnaire.questions.each do |original_question|
|
48
|
-
new_question = original_question.dup
|
49
|
-
new_question.questionnaire = new_questionnaire
|
50
|
-
new_question.save!
|
51
|
-
copy_questionnaire_answer_options(original_question, new_question)
|
52
|
-
copy_questionnaire_matrix_rows(original_question, new_question)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def copy_questionnaire_answer_options(original_question, new_question)
|
57
|
-
original_question.answer_options.each do |original_answer_option|
|
58
|
-
new_answer_option = original_answer_option.dup
|
59
|
-
new_answer_option.question = new_question
|
60
|
-
new_answer_option.save!
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def copy_questionnaire_matrix_rows(original_question, new_question)
|
65
|
-
original_question.matrix_rows.each do |original_matrix_row|
|
66
|
-
new_matrix_row = original_matrix_row.dup
|
67
|
-
new_matrix_row.question = new_question
|
68
|
-
new_matrix_row.save!
|
69
|
-
end
|
70
|
-
end
|
71
47
|
end
|
72
48
|
end
|
73
49
|
end
|
@@ -5,6 +5,8 @@ module Decidim
|
|
5
5
|
# A command with all the business logic when duplicating a questionnaire template
|
6
6
|
module Admin
|
7
7
|
class CopyQuestionnaireTemplate < Rectify::Command
|
8
|
+
include Decidim::Templates::Admin::QuestionnaireCopier
|
9
|
+
|
8
10
|
# Public: Initializes the command.
|
9
11
|
#
|
10
12
|
# template - A template we want to duplicate
|
@@ -47,32 +49,6 @@ module Decidim
|
|
47
49
|
|
48
50
|
@copied_template.update!(templatable: @resource)
|
49
51
|
end
|
50
|
-
|
51
|
-
def copy_questionnaire_questions(original_questionnaire, new_questionnaire)
|
52
|
-
original_questionnaire.questions.each do |original_question|
|
53
|
-
new_question = original_question.dup
|
54
|
-
new_question.questionnaire = new_questionnaire
|
55
|
-
new_question.save!
|
56
|
-
copy_questionnaire_answer_options(original_question, new_question)
|
57
|
-
copy_questionnaire_matrix_rows(original_question, new_question)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def copy_questionnaire_answer_options(original_question, new_question)
|
62
|
-
original_question.answer_options.each do |original_answer_option|
|
63
|
-
new_answer_option = original_answer_option.dup
|
64
|
-
new_answer_option.question = new_question
|
65
|
-
new_answer_option.save!
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def copy_questionnaire_matrix_rows(original_question, new_question)
|
70
|
-
original_question.matrix_rows.each do |original_matrix_row|
|
71
|
-
new_matrix_row = original_matrix_row.dup
|
72
|
-
new_matrix_row.question = new_question
|
73
|
-
new_matrix_row.save!
|
74
|
-
end
|
75
|
-
end
|
76
52
|
end
|
77
53
|
end
|
78
54
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Templates
|
5
|
+
# All the business logic to duplicate a questionnaire
|
6
|
+
module Admin
|
7
|
+
module QuestionnaireCopier
|
8
|
+
def copy_questionnaire_questions(original_questionnaire, new_questionnaire)
|
9
|
+
# start by copying the questions so that they already exist when cross referencing them in the conditions
|
10
|
+
original_questionnaire.questions.includes(:answer_options, :matrix_rows, :display_conditions).load
|
11
|
+
original_questionnaire.questions.each do |original_question|
|
12
|
+
new_question = original_question.dup
|
13
|
+
new_question.questionnaire = new_questionnaire
|
14
|
+
new_question.save!
|
15
|
+
copy_questionnaire_answer_options(original_question, new_question)
|
16
|
+
copy_questionnaire_matrix_rows(original_question, new_question)
|
17
|
+
end
|
18
|
+
# once all questions are copied, copy display conditions
|
19
|
+
original_questionnaire.questions.zip(new_questionnaire.questions.load).each do |original_question, new_question|
|
20
|
+
copy_question_display_conditions(original_question, new_question)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_questionnaire_answer_options(original_question, new_question)
|
25
|
+
original_question.answer_options.each do |original_answer_option|
|
26
|
+
new_answer_option = original_answer_option.dup
|
27
|
+
new_answer_option.question = new_question
|
28
|
+
new_answer_option.save!
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def copy_questionnaire_matrix_rows(original_question, new_question)
|
33
|
+
original_question.matrix_rows.each do |original_matrix_row|
|
34
|
+
new_matrix_row = original_matrix_row.dup
|
35
|
+
new_matrix_row.question = new_question
|
36
|
+
new_matrix_row.save!
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def copy_question_display_conditions(original_question, destination_question)
|
41
|
+
original_question.display_conditions.each do |original_display_condition|
|
42
|
+
new_display_condition = original_display_condition.dup
|
43
|
+
new_display_condition.question = destination_question
|
44
|
+
|
45
|
+
destination_question_to_be_checked = find_question_by_position(destination_question.questionnaire.questions, original_display_condition.condition_question.position)
|
46
|
+
new_display_condition.condition_question = destination_question_to_be_checked
|
47
|
+
|
48
|
+
if original_display_condition.answer_option
|
49
|
+
new_display_condition.answer_option = find_answer_option_by_body(destination_question_to_be_checked.answer_options, original_display_condition.answer_option.body)
|
50
|
+
end
|
51
|
+
new_display_condition.save!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def find_question_by_position(questions, position)
|
56
|
+
questions.to_a.find { |q| q.position == position }
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_answer_option_by_body(answer_options, body)
|
60
|
+
answer_options.to_a.find { |ao| ao.body == body }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -103,7 +103,7 @@ module Decidim
|
|
103
103
|
|
104
104
|
def apply
|
105
105
|
questionnaire = Decidim::Forms::Questionnaire.find_by(id: params[:questionnaire_id])
|
106
|
-
template = Decidim::Templates::Template.find_by(id: params
|
106
|
+
template = Decidim::Templates::Template.find_by(id: params.dig(:questionnaire, :questionnaire_template_id))
|
107
107
|
|
108
108
|
ApplyQuestionnaireTemplate.call(questionnaire, template) do
|
109
109
|
on(:ok) do
|
@@ -111,7 +111,8 @@ module Decidim
|
|
111
111
|
redirect_to params[:url]
|
112
112
|
end
|
113
113
|
on(:invalid) do
|
114
|
-
flash
|
114
|
+
flash[:error] = I18n.t("templates.apply.error", scope: "decidim.admin")
|
115
|
+
redirect_to EngineRouter.admin_proxy(questionnaire.questionnaire_for.component).survey_path
|
115
116
|
end
|
116
117
|
end
|
117
118
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "stylesheets/decidim/templates/templates";
|
File without changes
|
File without changes
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<h2 class="card-title">
|
4
4
|
<%= t ".title" %>
|
5
5
|
<% if allowed_to?(:create, :template) %>
|
6
|
-
<%= link_to t("actions.new", scope: "decidim.admin", name: t("template.name", scope: "decidim.models").downcase), [
|
6
|
+
<%= link_to t("actions.new", scope: "decidim.admin", name: t("template.name", scope: "decidim.models").downcase), [:new, :questionnaire_template], class: "button tiny button--title new" %>
|
7
7
|
<% end %>
|
8
8
|
</h2>
|
9
9
|
</div>
|
data/config/assets.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
base_path = File.expand_path("..", __dir__)
|
4
|
+
|
5
|
+
Decidim::Webpacker.register_path("#{base_path}/app/packs")
|
6
|
+
Decidim::Webpacker.register_entrypoints(
|
7
|
+
decidim_templates: "#{base_path}/app/packs/entrypoints/decidim_templates.js"
|
8
|
+
)
|
data/config/locales/ca.yml
CHANGED
data/config/locales/cs.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/fi-plain.yml
CHANGED
data/config/locales/fi.yml
CHANGED
data/config/locales/fr-CA.yml
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
fr-LU:
|
2
|
+
activemodel:
|
3
|
+
attributes:
|
4
|
+
questionnaire:
|
5
|
+
title: Titre
|
6
|
+
template:
|
7
|
+
description: Description
|
8
|
+
name: Nom
|
9
|
+
decidim:
|
10
|
+
admin:
|
11
|
+
menu:
|
12
|
+
templates: Modèles de questionnaire
|
13
|
+
templates:
|
14
|
+
apply:
|
15
|
+
error: Une erreur est survenue lors de l'application de ce modèle.
|
16
|
+
success: Modèle appliqué avec succès
|
17
|
+
copy:
|
18
|
+
error: Une erreur est survenue lors de la copie de ce modèle.
|
19
|
+
success: Modèle copié avec succès
|
20
|
+
create:
|
21
|
+
error: Une erreur est survenue pendant la création du modèle.
|
22
|
+
success: Modèle créé avec succès
|
23
|
+
destroy:
|
24
|
+
success: Modèle supprimé avec succès
|
25
|
+
empty: Il n'y a pas de modèle pour l'instant.
|
26
|
+
update:
|
27
|
+
error: Une erreur est survenue pendant la mise à jour du modèle.
|
28
|
+
success: Modèle mis à jour avec succès
|
29
|
+
titles:
|
30
|
+
template_types:
|
31
|
+
questionnaires: Modèles de questionnaire
|
32
|
+
templates: Modèles
|
33
|
+
models:
|
34
|
+
questionnaire_template:
|
35
|
+
fields:
|
36
|
+
questions: Nombre de questions
|
37
|
+
title: Nom du questionnaire
|
38
|
+
template:
|
39
|
+
fields:
|
40
|
+
created_at: Créé le
|
41
|
+
name: Modèle
|
42
|
+
templates:
|
43
|
+
admin:
|
44
|
+
questionnaire_templates:
|
45
|
+
choose:
|
46
|
+
create_from_template: Créer depuis un modèle
|
47
|
+
description: Vous êtes sur le point de créer un nouveau questionnaire. Vous pouvez choisir un modèle prédéfini et le modifier par la suite.
|
48
|
+
label: Choisir un modèle
|
49
|
+
placeholder: Choisir un modèle
|
50
|
+
skip_template: Passer
|
51
|
+
edit:
|
52
|
+
edit: Modifier
|
53
|
+
empty: Il n'y a pas encore de question
|
54
|
+
questionnaire: Questionnaire
|
55
|
+
form:
|
56
|
+
save: Sauvegarder
|
57
|
+
template_title: Informations sur le modèle
|
58
|
+
title: Modèle de questionnaire %{questionnaire_for}
|
59
|
+
index:
|
60
|
+
confirm_delete: Êtes-vous sûr de vouloir supprimer ce modèle?
|
61
|
+
title: Modèles de questionnaire
|
62
|
+
preview:
|
63
|
+
current_step: Étape %{step}
|
64
|
+
of_total_steps: sur %{total_steps}
|
65
|
+
tos_agreement: En participant, vous acceptez ces conditions d'utilisation
|
66
|
+
template_types:
|
67
|
+
questionnaires: Questionnaires
|
data/config/locales/fr.yml
CHANGED
data/config/locales/gl.yml
CHANGED
data/config/locales/it.yml
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
it:
|
2
|
+
activemodel:
|
3
|
+
attributes:
|
4
|
+
questionnaire:
|
5
|
+
title: Titolo
|
6
|
+
template:
|
7
|
+
description: Descrizione
|
8
|
+
name: Nome
|
2
9
|
decidim:
|
3
10
|
admin:
|
4
11
|
menu:
|
@@ -48,6 +55,7 @@ it:
|
|
48
55
|
form:
|
49
56
|
save: Salva
|
50
57
|
template_title: Informazioni del modello
|
58
|
+
title: Template del questionario %{questionnaire_for}
|
51
59
|
index:
|
52
60
|
confirm_delete: Sei sicuro di voler eliminare questo modello?
|
53
61
|
title: Modelli di questionari
|
data/config/locales/ja.yml
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
lb:
|
data/config/locales/nl.yml
CHANGED
data/config/locales/pl.yml
CHANGED
@@ -55,6 +55,6 @@ pl:
|
|
55
55
|
preview:
|
56
56
|
current_step: Krok %{step}
|
57
57
|
of_total_steps: z %{total_steps}
|
58
|
-
tos_agreement: Biorąc udział akceptujesz
|
58
|
+
tos_agreement: Biorąc udział akceptujesz Warunki korzystania z Platformy
|
59
59
|
template_types:
|
60
60
|
questionnaires: Kwestionariusze
|
data/config/locales/pt-BR.yml
CHANGED
@@ -1 +1,67 @@
|
|
1
1
|
pt:
|
2
|
+
activemodel:
|
3
|
+
attributes:
|
4
|
+
questionnaire:
|
5
|
+
title: Título
|
6
|
+
template:
|
7
|
+
description: Descrição
|
8
|
+
name: Nome
|
9
|
+
decidim:
|
10
|
+
admin:
|
11
|
+
menu:
|
12
|
+
templates: Modelos
|
13
|
+
templates:
|
14
|
+
apply:
|
15
|
+
error: Ocorreu um erro ao aplicar este modelo.
|
16
|
+
success: Modelo aplicado com sucesso
|
17
|
+
copy:
|
18
|
+
error: Ocorreu um erro ao copiar este modelo.
|
19
|
+
success: Modelo copiado com sucesso
|
20
|
+
create:
|
21
|
+
error: Ocorreu um erro ao criar este modelo.
|
22
|
+
success: Modelo criado com sucesso
|
23
|
+
destroy:
|
24
|
+
success: Modelo excluído com sucesso
|
25
|
+
empty: Ainda não existem modelos.
|
26
|
+
update:
|
27
|
+
error: Ocorreu um erro ao atualizar este modelo.
|
28
|
+
success: Modelo atualizado com sucesso
|
29
|
+
titles:
|
30
|
+
template_types:
|
31
|
+
questionnaires: Modelos de questionário
|
32
|
+
templates: Modelos
|
33
|
+
models:
|
34
|
+
questionnaire_template:
|
35
|
+
fields:
|
36
|
+
questions: Número de Questões
|
37
|
+
title: Nome do questionário
|
38
|
+
template:
|
39
|
+
fields:
|
40
|
+
created_at: Criado em
|
41
|
+
name: Modelo
|
42
|
+
templates:
|
43
|
+
admin:
|
44
|
+
questionnaire_templates:
|
45
|
+
choose:
|
46
|
+
create_from_template: Criar a partir de modelo
|
47
|
+
description: Você está prestes a criar um novo questionário. Você pode escolher um modelo predefinido e modificá-lo depois.
|
48
|
+
label: Selecionar modelo
|
49
|
+
placeholder: Selecionar modelo
|
50
|
+
skip_template: Ignorar
|
51
|
+
edit:
|
52
|
+
edit: Editar
|
53
|
+
empty: Ainda não há questões
|
54
|
+
questionnaire: Questionário
|
55
|
+
form:
|
56
|
+
save: Salvar
|
57
|
+
template_title: Informações do Template
|
58
|
+
title: Modelo de questionário %{questionnaire_for}
|
59
|
+
index:
|
60
|
+
confirm_delete: Tem certeza de que deseja excluir este modelo?
|
61
|
+
title: Modelos de questionário
|
62
|
+
preview:
|
63
|
+
current_step: Passo %{step}
|
64
|
+
of_total_steps: de %{total_steps}
|
65
|
+
tos_agreement: Ao participar você aceita os Termos de Serviço
|
66
|
+
template_types:
|
67
|
+
questionnaires: Questionários
|
data/config/locales/ro-RO.yml
CHANGED
data/db/seeds.rb
CHANGED
@@ -69,9 +69,9 @@ if !Rails.env.production? || ENV["SEED"]
|
|
69
69
|
question_type: matrix_question_type
|
70
70
|
)
|
71
71
|
|
72
|
-
3.times do
|
72
|
+
3.times do |idx|
|
73
73
|
question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
|
74
|
-
question.matrix_rows.create!(body: Decidim::Faker::Localized.sentence)
|
74
|
+
question.matrix_rows.create!(body: Decidim::Faker::Localized.sentence, position: idx)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -30,18 +30,12 @@ module Decidim
|
|
30
30
|
root to: "questionnaire_templates#index"
|
31
31
|
end
|
32
32
|
|
33
|
-
initializer "decidim_templates.action_controller" do |_app|
|
34
|
-
ActiveSupport.on_load :action_controller do
|
35
|
-
helper Decidim::Templates::Admin::TemplatesMenuHelper if respond_to?(:helper)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
33
|
initializer "decidim_participatory_processes.admin_participatory_processes_menu" do
|
40
34
|
Decidim.menu :admin_template_types_menu do |menu|
|
41
35
|
template_types.each_pair do |name, url|
|
42
|
-
menu.
|
43
|
-
|
44
|
-
|
36
|
+
menu.add_item name, name, url,
|
37
|
+
if: allowed_to?(:index, :templates),
|
38
|
+
active: is_active_link?(url)
|
45
39
|
end
|
46
40
|
end
|
47
41
|
end
|
@@ -54,11 +48,12 @@ module Decidim
|
|
54
48
|
|
55
49
|
initializer "decidim_templates.admin_menu" do
|
56
50
|
Decidim.menu :admin_menu do |menu|
|
57
|
-
menu.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
51
|
+
menu.add_item :questionnaire_templates,
|
52
|
+
I18n.t("menu.templates", scope: "decidim.admin", default: "Templates"),
|
53
|
+
decidim_admin_templates.questionnaire_templates_path,
|
54
|
+
icon_name: "document",
|
55
|
+
position: 12,
|
56
|
+
active: :inclusive
|
62
57
|
end
|
63
58
|
end
|
64
59
|
|
@@ -14,10 +14,6 @@ module Decidim
|
|
14
14
|
resources :templates
|
15
15
|
# root to: "templates#index"
|
16
16
|
end
|
17
|
-
|
18
|
-
initializer "decidim_templates.assets" do |app|
|
19
|
-
app.config.assets.precompile += %w(decidim_templates_manifest.js decidim_templates_manifest.css)
|
20
|
-
end
|
21
17
|
end
|
22
18
|
end
|
23
19
|
end
|
@@ -18,6 +18,13 @@ FactoryBot.define do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
trait :with_all_questions do
|
22
|
+
after(:create) do |template|
|
23
|
+
template.templatable = create(:questionnaire, :with_all_questions, questionnaire_for: template)
|
24
|
+
template.save!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
21
28
|
after(:create) do |template|
|
22
29
|
template.templatable = create(:questionnaire, questionnaire_for: template)
|
23
30
|
template.save!
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
shared_examples_for "copies all questionnaire contents" do
|
6
|
+
describe "when the questionnaire has all contents" do
|
7
|
+
it "copies all template contents to the questionnaire" do
|
8
|
+
destination_questionnaire.reload
|
9
|
+
|
10
|
+
check_copy_questionnaire_questions(template.templatable, destination_questionnaire)
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_copy_questionnaire_questions(source_questionnaire, new_questionnaire)
|
14
|
+
expect(source_questionnaire.questions.size).to eq(new_questionnaire.questions.size)
|
15
|
+
|
16
|
+
source_questionnaire.questions.each_with_index do |source_question, idx|
|
17
|
+
new_question = new_questionnaire.questions[idx]
|
18
|
+
|
19
|
+
expect(source_question.position).to eq(new_question.position)
|
20
|
+
expect(source_question.question_type).to eq(new_question.question_type)
|
21
|
+
expect(source_question.mandatory).to eq(new_question.mandatory)
|
22
|
+
expect(source_question.body).to eq(new_question.body)
|
23
|
+
expect(source_question.description).to eq(new_question.description)
|
24
|
+
expect(source_question.max_choices).to eq(new_question.max_choices)
|
25
|
+
|
26
|
+
check_answer_options(source_question, new_question)
|
27
|
+
check_matrix_rows(source_question, new_question)
|
28
|
+
check_display_conditions(source_question.display_conditions, new_question.display_conditions)
|
29
|
+
check_display_conditions(source_question.display_conditions_for_other_questions, new_question.display_conditions_for_other_questions)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def check_answer_options(source_question, new_question)
|
34
|
+
expect(source_question.answer_options.size).to eq(new_question.answer_options.size)
|
35
|
+
|
36
|
+
source_question.answer_options.each_with_index do |source_answer_option, idx|
|
37
|
+
new_answer_option = new_question.answer_options[idx]
|
38
|
+
|
39
|
+
expect(source_answer_option.body).to eq(new_answer_option.body)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_matrix_rows(source_question, new_question)
|
44
|
+
expect(source_question.matrix_rows.size).to eq(new_question.matrix_rows.size)
|
45
|
+
|
46
|
+
source_question.matrix_rows.each_with_index do |source_matrix_row, idx|
|
47
|
+
new_matrix_row = new_question.matrix_rows[idx]
|
48
|
+
|
49
|
+
expect(source_matrix_row.body).to eq(new_matrix_row.body)
|
50
|
+
expect(source_matrix_row.position).to eq(new_matrix_row.position)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def check_display_conditions(source_display_conditions, new_display_conditions)
|
55
|
+
expect(source_display_conditions.size).to eq(new_display_conditions.size)
|
56
|
+
|
57
|
+
source_display_conditions.each_with_index do |source_matrix_row, idx|
|
58
|
+
new_matrix_row = new_display_conditions[idx]
|
59
|
+
|
60
|
+
expect(source_matrix_row.condition_type).to eq(new_matrix_row.condition_type)
|
61
|
+
expect(source_matrix_row.condition_value).to eq(new_matrix_row.condition_value)
|
62
|
+
expect(source_matrix_row.mandatory).to eq(new_matrix_row.mandatory)
|
63
|
+
expect(new_matrix_row).to be_persisted
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-templates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vera Rojman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim-core
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.25.0.rc2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.25.0.rc2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: decidim-forms
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.25.0.rc2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.25.0.rc2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: decidim-admin
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.25.0.rc2
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.25.0.rc2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: decidim-dev
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.25.0.rc2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.25.0.rc2
|
69
69
|
description: This module provides a solution to create templates for different Decidim
|
70
70
|
models, such as Proposals and Questionnaires..
|
71
71
|
email:
|
@@ -77,14 +77,11 @@ files:
|
|
77
77
|
- LICENSE-AGPLv3.txt
|
78
78
|
- README.md
|
79
79
|
- Rakefile
|
80
|
-
- app/assets/config/decidim_templates_manifest.css
|
81
|
-
- app/assets/config/decidim_templates_manifest.js
|
82
|
-
- app/assets/images/decidim/templates/icon.svg
|
83
|
-
- app/assets/stylesheets/decidim/templates/templates.scss
|
84
80
|
- app/commands/decidim/templates/admin/apply_questionnaire_template.rb
|
85
81
|
- app/commands/decidim/templates/admin/copy_questionnaire_template.rb
|
86
82
|
- app/commands/decidim/templates/admin/create_questionnaire_template.rb
|
87
83
|
- app/commands/decidim/templates/admin/destroy_template.rb
|
84
|
+
- app/commands/decidim/templates/admin/questionnaire_copier.rb
|
88
85
|
- app/commands/decidim/templates/admin/update_template.rb
|
89
86
|
- app/controllers/decidim/templates/admin/application_controller.rb
|
90
87
|
- app/controllers/decidim/templates/admin/concerns/templatable.rb
|
@@ -93,11 +90,14 @@ files:
|
|
93
90
|
- app/controllers/decidim/templates/application_controller.rb
|
94
91
|
- app/forms/decidim/templates/admin/template_form.rb
|
95
92
|
- app/helpers/decidim/templates/admin/templates_helper.rb
|
96
|
-
- app/helpers/decidim/templates/admin/templates_menu_helper.rb
|
97
93
|
- app/helpers/decidim/templates/application_helper.rb
|
98
94
|
- app/models/concerns/decidim/templates/templatable.rb
|
99
95
|
- app/models/decidim/templates/application_record.rb
|
100
96
|
- app/models/decidim/templates/template.rb
|
97
|
+
- app/packs/entrypoints/decidim_templates.js
|
98
|
+
- app/packs/entrypoints/decidim_templates.scss
|
99
|
+
- app/packs/images/decidim/templates/decidim_templates.svg
|
100
|
+
- app/packs/stylesheets/decidim/templates/templates.scss
|
101
101
|
- app/permissions/decidim/templates/admin/permissions.rb
|
102
102
|
- app/views/decidim/templates/admin/questionnaire_templates/_choose.html.erb
|
103
103
|
- app/views/decidim/templates/admin/questionnaire_templates/_form.html.erb
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- app/views/decidim/templates/admin/questionnaire_templates/new.html.erb
|
108
108
|
- app/views/decidim/templates/admin/questionnaire_templates/preview.js.erb
|
109
109
|
- app/views/layouts/decidim/admin/templates.html.erb
|
110
|
+
- config/assets.rb
|
110
111
|
- config/locales/am-ET.yml
|
111
112
|
- config/locales/ar.yml
|
112
113
|
- config/locales/bg.yml
|
@@ -125,6 +126,7 @@ files:
|
|
125
126
|
- config/locales/fi-plain.yml
|
126
127
|
- config/locales/fi.yml
|
127
128
|
- config/locales/fr-CA.yml
|
129
|
+
- config/locales/fr-LU.yml
|
128
130
|
- config/locales/fr.yml
|
129
131
|
- config/locales/ga-IE.yml
|
130
132
|
- config/locales/gl.yml
|
@@ -136,6 +138,7 @@ files:
|
|
136
138
|
- config/locales/ja.yml
|
137
139
|
- config/locales/ko-KR.yml
|
138
140
|
- config/locales/ko.yml
|
141
|
+
- config/locales/lb-LU.yml
|
139
142
|
- config/locales/lt.yml
|
140
143
|
- config/locales/lv.yml
|
141
144
|
- config/locales/mt.yml
|
@@ -168,6 +171,7 @@ files:
|
|
168
171
|
- lib/decidim/templates/admin_engine.rb
|
169
172
|
- lib/decidim/templates/engine.rb
|
170
173
|
- lib/decidim/templates/test/factories.rb
|
174
|
+
- lib/decidim/templates/test/shared_examples/copies_all_questionnaire_contents_examples.rb
|
171
175
|
- lib/decidim/templates/test/shared_examples/uses_questionnaire_templates.rb
|
172
176
|
- lib/decidim/templates/version.rb
|
173
177
|
homepage: https://github.com/decidim/decidim-module-templates
|
@@ -185,9 +189,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
189
|
version: '2.7'
|
186
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
191
|
requirements:
|
188
|
-
- - "
|
192
|
+
- - ">"
|
189
193
|
- !ruby/object:Gem::Version
|
190
|
-
version:
|
194
|
+
version: 1.3.1
|
191
195
|
requirements: []
|
192
196
|
rubygems_version: 3.1.2
|
193
197
|
signing_key:
|
File without changes
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Templates
|
5
|
-
module Admin
|
6
|
-
module TemplatesMenuHelper
|
7
|
-
include Decidim::Admin::SidebarMenuHelper
|
8
|
-
|
9
|
-
def template_types_menu
|
10
|
-
@template_types_menu ||= sidebar_menu(:admin_template_types_menu)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|