decidim-templates 0.23.0
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 +7 -0
- data/LICENSE-AGPLv3.txt +661 -0
- data/README.md +31 -0
- data/Rakefile +9 -0
- data/app/assets/config/decidim_templates_manifest.css +3 -0
- data/app/assets/config/decidim_templates_manifest.js +0 -0
- data/app/assets/images/decidim/templates/icon.svg +1 -0
- data/app/assets/stylesheets/decidim/templates/templates.scss +14 -0
- data/app/commands/decidim/templates/admin/apply_questionnaire_template.rb +74 -0
- data/app/commands/decidim/templates/admin/copy_questionnaire_template.rb +79 -0
- data/app/commands/decidim/templates/admin/create_questionnaire_template.rb +34 -0
- data/app/commands/decidim/templates/admin/destroy_template.rb +41 -0
- data/app/commands/decidim/templates/admin/update_template.rb +35 -0
- data/app/controllers/decidim/templates/admin/application_controller.rb +34 -0
- data/app/controllers/decidim/templates/admin/concerns/templatable.rb +46 -0
- data/app/controllers/decidim/templates/admin/questionnaire_templates/questionnaires_controller.rb +38 -0
- data/app/controllers/decidim/templates/admin/questionnaire_templates_controller.rb +156 -0
- data/app/controllers/decidim/templates/application_controller.rb +13 -0
- data/app/forms/decidim/templates/admin/template_form.rb +17 -0
- data/app/helpers/decidim/templates/admin/templates_helper.rb +32 -0
- data/app/helpers/decidim/templates/application_helper.rb +10 -0
- data/app/models/concerns/decidim/templates/templatable.rb +24 -0
- data/app/models/decidim/templates/application_record.rb +10 -0
- data/app/models/decidim/templates/template.rb +33 -0
- data/app/permissions/decidim/templates/admin/permissions.rb +26 -0
- data/app/views/decidim/templates/admin/questionnaire_templates/_choose.html.erb +35 -0
- data/app/views/decidim/templates/admin/questionnaire_templates/_form.html.erb +16 -0
- data/app/views/decidim/templates/admin/questionnaire_templates/_preview.html.erb +73 -0
- data/app/views/decidim/templates/admin/questionnaire_templates/edit.html.erb +20 -0
- data/app/views/decidim/templates/admin/questionnaire_templates/index.html.erb +52 -0
- data/app/views/decidim/templates/admin/questionnaire_templates/new.html.erb +7 -0
- data/app/views/decidim/templates/admin/questionnaire_templates/preview.js.erb +11 -0
- data/app/views/layouts/decidim/admin/templates.html.erb +21 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +1 -0
- data/config/locales/bg.yml +1 -0
- data/config/locales/ca.yml +60 -0
- data/config/locales/cs.yml +60 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +54 -0
- data/config/locales/el.yml +1 -0
- data/config/locales/en.yml +61 -0
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +60 -0
- data/config/locales/es-PY.yml +60 -0
- data/config/locales/es.yml +60 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +1 -0
- data/config/locales/fi-plain.yml +60 -0
- data/config/locales/fi.yml +60 -0
- data/config/locales/fr-CA.yml +60 -0
- data/config/locales/fr.yml +60 -0
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +1 -0
- data/config/locales/id-ID.yml +1 -0
- data/config/locales/is-IS.yml +1 -0
- data/config/locales/it.yml +60 -0
- data/config/locales/ja.yml +60 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +60 -0
- data/config/locales/no.yml +5 -0
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +1 -0
- data/config/locales/pt-BR.yml +1 -0
- data/config/locales/pt.yml +1 -0
- data/config/locales/ro-RO.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/config/locales/sk.yml +1 -0
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -0
- data/config/locales/sv.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +1 -0
- data/config/locales/uk.yml +1 -0
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +60 -0
- data/config/locales/zh-TW.yml +1 -0
- data/lib/decidim/templates.rb +12 -0
- data/lib/decidim/templates/admin.rb +10 -0
- data/lib/decidim/templates/admin_engine.rb +54 -0
- data/lib/decidim/templates/engine.rb +23 -0
- data/lib/decidim/templates/test/factories.rb +27 -0
- data/lib/decidim/templates/test/shared_examples/uses_questionnaire_templates.rb +108 -0
- data/lib/decidim/templates/version.rb +10 -0
- metadata +191 -0
@@ -0,0 +1 @@
|
|
1
|
+
ko:
|
@@ -0,0 +1 @@
|
|
1
|
+
ko:
|
@@ -0,0 +1 @@
|
|
1
|
+
lt:
|
@@ -0,0 +1 @@
|
|
1
|
+
lv:
|
@@ -0,0 +1 @@
|
|
1
|
+
mt:
|
@@ -0,0 +1,60 @@
|
|
1
|
+
nl:
|
2
|
+
decidim:
|
3
|
+
admin:
|
4
|
+
menu:
|
5
|
+
templates: Templates
|
6
|
+
templates:
|
7
|
+
apply:
|
8
|
+
error: Er is een fout opgetreden bij het bijwerken van dit template.
|
9
|
+
success: Template met succes toegepast
|
10
|
+
copy:
|
11
|
+
error: Er is een fout opgetreden bij het kopiëren van dit template.
|
12
|
+
success: Template met succes gekopieerd
|
13
|
+
create:
|
14
|
+
error: Er is een fout opgetreden bij het maken van dit template.
|
15
|
+
success: Template met succes aangemaakt
|
16
|
+
destroy:
|
17
|
+
success: Template met succes verwijderd
|
18
|
+
empty: Er zijn nog geen templates.
|
19
|
+
update:
|
20
|
+
error: Er is een fout opgetreden bij het bijwerken van dit template.
|
21
|
+
success: Template met succes bijgewerkt
|
22
|
+
titles:
|
23
|
+
template_types:
|
24
|
+
questionnaires: Vragenlijst templates
|
25
|
+
templates: Templates
|
26
|
+
models:
|
27
|
+
questionnaire_template:
|
28
|
+
fields:
|
29
|
+
questions: Aantal vragen
|
30
|
+
title: Vragenlijst titel
|
31
|
+
template:
|
32
|
+
fields:
|
33
|
+
created_at: Aangemaakt op
|
34
|
+
name: Template
|
35
|
+
templates:
|
36
|
+
admin:
|
37
|
+
questionnaire_templates:
|
38
|
+
choose:
|
39
|
+
create_from_template: Met template aanmaken
|
40
|
+
description: Je staat op het punt een nieuwe vragenlijst te maken. Je kunt een vooraf gedefinieerd template kiezen en daarna wijzigen.
|
41
|
+
label: Template kiezen
|
42
|
+
placeholder: Template kiezen
|
43
|
+
skip_template: Overslaan
|
44
|
+
edit:
|
45
|
+
edit: Bewerk
|
46
|
+
empty: Er zijn nog geen vragen
|
47
|
+
questionnaire: Vragenlijst
|
48
|
+
form:
|
49
|
+
save: Opslaan
|
50
|
+
template_title: Template informatie
|
51
|
+
title: Vragenlijst
|
52
|
+
index:
|
53
|
+
confirm_delete: Weet je zeker dat je dit template wilt verwijderen?
|
54
|
+
title: Vragenlijst templates
|
55
|
+
preview:
|
56
|
+
current_step: Stap %{step}
|
57
|
+
of_total_steps: van %{total_steps}
|
58
|
+
tos_agreement: Door deel te nemen accepteer je de gebruiksvoorwaarden
|
59
|
+
template_types:
|
60
|
+
questionnaires: Vragenlijsten
|
@@ -0,0 +1 @@
|
|
1
|
+
om:
|
@@ -0,0 +1 @@
|
|
1
|
+
pl:
|
@@ -0,0 +1 @@
|
|
1
|
+
pt:
|
@@ -0,0 +1 @@
|
|
1
|
+
pt:
|
@@ -0,0 +1 @@
|
|
1
|
+
ro:
|
@@ -0,0 +1 @@
|
|
1
|
+
ru:
|
@@ -0,0 +1 @@
|
|
1
|
+
sk:
|
@@ -0,0 +1 @@
|
|
1
|
+
sl:
|
@@ -0,0 +1 @@
|
|
1
|
+
so:
|
@@ -0,0 +1 @@
|
|
1
|
+
sr:
|
@@ -0,0 +1 @@
|
|
1
|
+
sv:
|
@@ -0,0 +1 @@
|
|
1
|
+
ti:
|
@@ -0,0 +1 @@
|
|
1
|
+
tr:
|
@@ -0,0 +1 @@
|
|
1
|
+
uk:
|
@@ -0,0 +1 @@
|
|
1
|
+
vi:
|
@@ -0,0 +1 @@
|
|
1
|
+
vi:
|
@@ -0,0 +1,60 @@
|
|
1
|
+
zh-CN:
|
2
|
+
decidim:
|
3
|
+
admin:
|
4
|
+
menu:
|
5
|
+
templates: 模板
|
6
|
+
templates:
|
7
|
+
apply:
|
8
|
+
error: 应用此模板时出现问题。
|
9
|
+
success: 模板应用成功
|
10
|
+
copy:
|
11
|
+
error: 复制此模板时出现问题。
|
12
|
+
success: 模板复制成功
|
13
|
+
create:
|
14
|
+
error: 创建此模板时出现问题。
|
15
|
+
success: 模板创建成功
|
16
|
+
destroy:
|
17
|
+
success: 模板删除成功
|
18
|
+
empty: 尚无模板。
|
19
|
+
update:
|
20
|
+
error: 在更新此模板时出现问题。
|
21
|
+
success: 模板更新成功
|
22
|
+
titles:
|
23
|
+
template_types:
|
24
|
+
questionnaires: 问卷模板
|
25
|
+
templates: 模板
|
26
|
+
models:
|
27
|
+
questionnaire_template:
|
28
|
+
fields:
|
29
|
+
questions: 问题数量
|
30
|
+
title: Questionnaire Title
|
31
|
+
template:
|
32
|
+
fields:
|
33
|
+
created_at: 创建于
|
34
|
+
name: 模板
|
35
|
+
templates:
|
36
|
+
admin:
|
37
|
+
questionnaire_templates:
|
38
|
+
choose:
|
39
|
+
create_from_template: 从模板创建
|
40
|
+
description: 您即将创建一个新的问题单。您可以选择一个预定义的模板并在其后进行修改。
|
41
|
+
label: 选择模板
|
42
|
+
placeholder: 选择模板
|
43
|
+
skip_template: 跳过
|
44
|
+
edit:
|
45
|
+
edit: 编辑
|
46
|
+
empty: 还没有问题
|
47
|
+
questionnaire: Questionnaire
|
48
|
+
form:
|
49
|
+
save: 保存
|
50
|
+
template_title: 模板信息
|
51
|
+
title: Questionnaire
|
52
|
+
index:
|
53
|
+
confirm_delete: 您确定要删除此模板吗?
|
54
|
+
title: 问卷模板
|
55
|
+
preview:
|
56
|
+
current_step: 步骤 %{step}
|
57
|
+
of_total_steps: '%{total_steps}'
|
58
|
+
tos_agreement: 通过参与您接受其服务条款
|
59
|
+
template_types:
|
60
|
+
questionnaires: Questionnaires
|
@@ -0,0 +1 @@
|
|
1
|
+
zh-TW:
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/templates/admin"
|
4
|
+
require "decidim/templates/engine"
|
5
|
+
require "decidim/templates/admin_engine"
|
6
|
+
|
7
|
+
module Decidim
|
8
|
+
# This namespace holds the logic of the `Templates` component. This component
|
9
|
+
# allows users to create templates in a participatory space.
|
10
|
+
module Templates
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Templates
|
5
|
+
# This is the engine that runs on the public interface of `Templates`.
|
6
|
+
class AdminEngine < ::Rails::Engine
|
7
|
+
isolate_namespace Decidim::Templates::Admin
|
8
|
+
|
9
|
+
paths["db/migrate"] = nil
|
10
|
+
paths["lib/tasks"] = nil
|
11
|
+
|
12
|
+
routes do
|
13
|
+
## Routes for Questionnaire Templates
|
14
|
+
resources :questionnaire_templates do
|
15
|
+
member do
|
16
|
+
post :copy
|
17
|
+
|
18
|
+
resource :questionnaire, module: :questionnaire_templates # To manage the templatable resource
|
19
|
+
end
|
20
|
+
|
21
|
+
collection do
|
22
|
+
post :apply # To use when creating an object from a template
|
23
|
+
post :skip # To use when creating an object without a template
|
24
|
+
get :preview # To provide a preview for the template in the object creation view
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
get "/questionnaire_template/questionnaire/answer_options", to: "questionnaires#answer_options", as: "answer_options_template"
|
29
|
+
|
30
|
+
root to: "questionnaire_templates#index"
|
31
|
+
end
|
32
|
+
|
33
|
+
initializer "decidim_templates.admin_mount_routes" do
|
34
|
+
Decidim::Core::Engine.routes do
|
35
|
+
mount Decidim::Templates::AdminEngine, at: "/admin/templates", as: "decidim_admin_templates"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
initializer "decidim_templates.admin_menu" do
|
40
|
+
Decidim.menu :admin_menu do |menu|
|
41
|
+
menu.item I18n.t("menu.templates", scope: "decidim.admin", default: "Templates"),
|
42
|
+
decidim_admin_templates.questionnaire_templates_path,
|
43
|
+
icon_name: "document",
|
44
|
+
position: 12,
|
45
|
+
active: :inclusive
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def load_seed
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
require "decidim/core"
|
5
|
+
|
6
|
+
module Decidim
|
7
|
+
module Templates
|
8
|
+
# This is the engine that runs on the public interface of templates.
|
9
|
+
class Engine < ::Rails::Engine
|
10
|
+
isolate_namespace Decidim::Templates
|
11
|
+
|
12
|
+
routes do
|
13
|
+
# Add engine routes here
|
14
|
+
resources :templates
|
15
|
+
# root to: "templates#index"
|
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
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/faker/localized"
|
4
|
+
require "decidim/dev"
|
5
|
+
|
6
|
+
FactoryBot.define do
|
7
|
+
factory :template, class: "Decidim::Templates::Template" do
|
8
|
+
organization
|
9
|
+
templatable { build(:dummy_resource) }
|
10
|
+
name { Decidim::Faker::Localized.sentence }
|
11
|
+
|
12
|
+
## Questionnaire templates
|
13
|
+
factory :questionnaire_template do
|
14
|
+
trait :with_questions do
|
15
|
+
after(:create) do |template|
|
16
|
+
template.templatable = create(:questionnaire, :with_questions, questionnaire_for: template)
|
17
|
+
template.save!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
after(:create) do |template|
|
22
|
+
template.templatable = create(:questionnaire, questionnaire_for: template)
|
23
|
+
template.save!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
# rubocop:disable Rails/SkipsModelValidations
|
6
|
+
|
7
|
+
shared_examples_for "uses questionnaire templates" do |_questionnaire_for|
|
8
|
+
describe "choose a template" do
|
9
|
+
context "when there are no templates" do
|
10
|
+
before do
|
11
|
+
questionnaire.update_columns(
|
12
|
+
created_at: Time.zone.now - 1.day,
|
13
|
+
updated_at: Time.zone.now
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "doesn't show the template selection screen" do
|
18
|
+
expect(page).to have_no_content("Choose template")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when there are templates" do
|
23
|
+
let!(:templates) { create_list(:questionnaire_template, 6, :with_questions, organization: questionnaire.questionnaire_for.organization) }
|
24
|
+
let(:template) { templates.first }
|
25
|
+
let(:question) { template.templatable.questions.first }
|
26
|
+
|
27
|
+
context "when it is an existing questionnaire" do
|
28
|
+
before do
|
29
|
+
questionnaire.update_columns(
|
30
|
+
created_at: Time.zone.now - 1.day,
|
31
|
+
updated_at: Time.zone.now
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "doesn't show the template selection screen" do
|
36
|
+
expect(page).to have_no_content("Choose template")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when it is a newly created questionnaire" do
|
41
|
+
before do
|
42
|
+
questionnaire.update_columns(
|
43
|
+
created_at: Time.zone.now,
|
44
|
+
updated_at: Time.zone.now,
|
45
|
+
title: {},
|
46
|
+
description: {},
|
47
|
+
tos: {}
|
48
|
+
)
|
49
|
+
visit questionnaire_edit_path
|
50
|
+
end
|
51
|
+
|
52
|
+
it "shows the template choosing screen" do
|
53
|
+
expect(page).to have_content("Choose template")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "loads the last 5 templates in the select" do
|
57
|
+
page.find(".Select-control").click
|
58
|
+
|
59
|
+
within ".Select-menu" do
|
60
|
+
expect(page).to have_selector(".Select-option:not(.is-focused)", count: 5)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "displays the preview when a template is selected" do
|
65
|
+
autocomplete_select template.name["en"], from: :questionnaire_template_id
|
66
|
+
within ".questionnaire-template-preview" do
|
67
|
+
expect(page).to have_i18n_content(template.name)
|
68
|
+
expect(page).to have_i18n_content(question.body)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "apply a template" do
|
76
|
+
let!(:templates) { create_list(:questionnaire_template, 6, :with_questions, organization: questionnaire.questionnaire_for.organization) }
|
77
|
+
let(:template) { templates.first }
|
78
|
+
let(:question) { template.templatable.questions.first }
|
79
|
+
let(:questionnaire_question) { questionnaire.questions.first }
|
80
|
+
|
81
|
+
before do
|
82
|
+
questionnaire.update_columns(
|
83
|
+
created_at: Time.zone.now,
|
84
|
+
updated_at: Time.zone.now,
|
85
|
+
title: {},
|
86
|
+
description: {},
|
87
|
+
tos: {}
|
88
|
+
)
|
89
|
+
visit questionnaire_edit_path
|
90
|
+
|
91
|
+
autocomplete_select template.name["en"], from: :questionnaire_template_id
|
92
|
+
|
93
|
+
within ".create-from-template" do
|
94
|
+
find("*[type=submit]").click
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
it "copies the template data to the questionnaire on submit" do
|
99
|
+
within "form.edit_questionnaire" do
|
100
|
+
click_button "Expand all"
|
101
|
+
expect(page.find("#questionnaire_title_en").value).to eq(template.templatable.title["en"])
|
102
|
+
expect(page.find("#questionnaire_questions_#{questionnaire_question.id}_body_en").value).to eq(question.body["en"])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# rubocop:enable Rails/SkipsModelValidations
|