fe 2.1.0 → 2.1.2
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/README.md +9 -5
- data/app/assets/javascripts/fe/fe.admin.js +1 -1
- data/app/assets/javascripts/fe/fe.public.nojquery.js.erb +410 -408
- data/app/controllers/concerns/fe/admin/question_sheets_controller_concern.rb +3 -3
- data/app/controllers/concerns/fe/answer_sheets_controller_concern.rb +16 -2
- data/app/controllers/fe/admin/elements_controller.rb +0 -1
- data/app/controllers/fe/admin/email_templates_controller.rb +15 -15
- data/app/controllers/fe/admin/question_pages_controller.rb +0 -1
- data/app/models/concerns/fe/answer_pages_presenter_concern.rb +13 -0
- data/app/models/concerns/fe/choice_field_concern.rb +10 -4
- data/app/models/fe/element.rb +14 -7
- data/app/models/fe/page.rb +6 -2
- data/app/models/fe/question.rb +2 -2
- data/app/models/fe/question_set.rb +1 -1
- data/app/models/fe/question_sheet.rb +7 -3
- data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -0
- data/db/migrate/20181108201746_create_versions.rb +2 -6
- data/lib/fe/version.rb +1 -1
- data/spec/dummy/app/views/layouts/fe/fe.admin.html.erb +1 -0
- data/spec/dummy/log/test.log +67388 -0
- data/spec/models/fe/application_spec.rb +1 -1
- metadata +27 -10
- data/config/initializers/paper_trail.rb +0 -3
@@ -24,17 +24,17 @@ module Fe::Admin::QuestionSheetsControllerConcern
|
|
24
24
|
|
25
25
|
def archive
|
26
26
|
@question_sheet.update_attribute(:archived, true)
|
27
|
-
redirect_back
|
27
|
+
redirect_back fallback_location: fe_admin_question_sheets_path
|
28
28
|
end
|
29
29
|
|
30
30
|
def unarchive
|
31
31
|
@question_sheet.update_attribute(:archived, false)
|
32
|
-
redirect_back
|
32
|
+
redirect_back fallback_location: fe_admin_question_sheets_path
|
33
33
|
end
|
34
34
|
|
35
35
|
def duplicate
|
36
36
|
@question_sheet.duplicate
|
37
|
-
redirect_back
|
37
|
+
redirect_back fallback_location: fe_admin_question_sheets_path
|
38
38
|
end
|
39
39
|
|
40
40
|
# entry point: display form designer with page 1 and panels loaded
|
@@ -36,8 +36,22 @@ module Fe::AnswerSheetsControllerConcern
|
|
36
36
|
render html: "", layout: true
|
37
37
|
end
|
38
38
|
else
|
39
|
-
|
40
|
-
|
39
|
+
if get_filter.present?
|
40
|
+
# filter presenter entire page list
|
41
|
+
all_question_set = @presenter.questions_for_all_pages
|
42
|
+
all_question_set.set_filter(get_filter)
|
43
|
+
@presenter.filter_pages_from_elements(all_question_set.elements)
|
44
|
+
|
45
|
+
# get first page elements
|
46
|
+
question_set = @presenter.questions_for_page(:first)
|
47
|
+
question_set.set_filter(get_filter)
|
48
|
+
@elements = question_set.elements
|
49
|
+
@page = @presenter.pages.first
|
50
|
+
else
|
51
|
+
# save some processing by not doing any filtering code
|
52
|
+
@elements = @presenter.questions_for_page(:first).elements
|
53
|
+
@page = @presenter.pages.first
|
54
|
+
end
|
41
55
|
end
|
42
56
|
end
|
43
57
|
|
@@ -1,34 +1,34 @@
|
|
1
1
|
class Fe::Admin::EmailTemplatesController < ApplicationController
|
2
2
|
before_action :check_valid_user
|
3
|
-
layout 'fe/
|
4
|
-
|
3
|
+
layout 'fe/fe.admin'
|
4
|
+
|
5
5
|
def index
|
6
6
|
@email_templates = Fe::EmailTemplate.order('name')
|
7
|
-
|
7
|
+
|
8
8
|
respond_to do |format|
|
9
9
|
format.html
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
13
|
-
def new
|
12
|
+
|
13
|
+
def new
|
14
14
|
@email_template = Fe::EmailTemplate.new
|
15
|
-
|
15
|
+
|
16
16
|
respond_to do |format|
|
17
17
|
format.html
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def edit
|
22
22
|
@email_template = Fe::EmailTemplate.find(params[:id])
|
23
|
-
|
23
|
+
|
24
24
|
respond_to do |format|
|
25
25
|
format.html
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def create
|
30
30
|
@email_template = Fe::EmailTemplate.new(email_template_params)
|
31
|
-
|
31
|
+
|
32
32
|
respond_to do |format|
|
33
33
|
if @email_template.save
|
34
34
|
format.html { redirect_to fe_admin_email_templates_path }
|
@@ -37,10 +37,10 @@ class Fe::Admin::EmailTemplatesController < ApplicationController
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
41
|
-
def update
|
40
|
+
|
41
|
+
def update
|
42
42
|
@email_template = Fe::EmailTemplate.find(params[:id])
|
43
|
-
|
43
|
+
|
44
44
|
respond_to do |format|
|
45
45
|
if @email_template.update(email_template_params)
|
46
46
|
format.html { redirect_to fe_admin_email_templates_path }
|
@@ -49,7 +49,7 @@ class Fe::Admin::EmailTemplatesController < ApplicationController
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def destroy
|
54
54
|
@email_template = Fe::EmailTemplate.find(params[:id])
|
55
55
|
@email_template.destroy
|
@@ -60,7 +60,7 @@ class Fe::Admin::EmailTemplatesController < ApplicationController
|
|
60
60
|
end
|
61
61
|
|
62
62
|
protected
|
63
|
-
|
63
|
+
|
64
64
|
def email_template_params
|
65
65
|
params.require(:email_template).permit(:name, :subject, :content)
|
66
66
|
end
|
@@ -36,6 +36,10 @@ module Fe
|
|
36
36
|
Fe::QuestionSet.new(@active_page ? @active_page.all_elements : [], @active_answer_sheet)
|
37
37
|
end
|
38
38
|
|
39
|
+
def questions_for_all_pages
|
40
|
+
Fe::QuestionSet.new(@active_answer_sheet.question_sheet.all_elements, @active_answer_sheet)
|
41
|
+
end
|
42
|
+
|
39
43
|
# title
|
40
44
|
def sheet_title
|
41
45
|
@active_answer_sheet.question_sheet.label
|
@@ -94,6 +98,15 @@ module Fe
|
|
94
98
|
Fe::PageLink.new(edit_fe_answer_sheet_page_path(answer_sheet, page, a: a), dom_page(answer_sheet, page), page) if page
|
95
99
|
end
|
96
100
|
|
101
|
+
# filters the pages and pages_list such that only pages for which there
|
102
|
+
# are elements in the elements array passed in are kept
|
103
|
+
def filter_pages_from_elements(elements)
|
104
|
+
pages_from_elements = elements.collect{ |e| e.pages }.flatten.uniq
|
105
|
+
pages.reject! { |p| !pages_from_elements.include?(p) }
|
106
|
+
@page_links.reject! { |pl| !pages_from_elements.include?(pl.page) }
|
107
|
+
true
|
108
|
+
end
|
109
|
+
|
97
110
|
protected
|
98
111
|
|
99
112
|
# for pages_list sidebar
|
@@ -14,9 +14,13 @@ module Fe
|
|
14
14
|
begin
|
15
15
|
included do
|
16
16
|
has_many :elements, class_name: "Element", foreign_key: "choice_field_id", dependent: :nullify#, order: :position
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
[:rating_before_label_translations, :rating_after_label_translations, :rating_na_label_translations].each do |column|
|
18
|
+
if Rails::VERSION::MAJOR < 7
|
19
|
+
serialize column, Hash
|
20
|
+
else
|
21
|
+
serialize column, type: Hash
|
22
|
+
end
|
23
|
+
end
|
20
24
|
end
|
21
25
|
rescue ActiveSupport::Concern::MultipleIncludedBlocks
|
22
26
|
end
|
@@ -51,7 +55,9 @@ module Fe
|
|
51
55
|
values = doc.find(value_xpath).collect { |n| n.content }
|
52
56
|
retVal = [options, values].transpose
|
53
57
|
rescue NameError, LibXML::XML::Error
|
54
|
-
|
58
|
+
url = URI.parse(source)
|
59
|
+
url.query = [url.query, "locale=#{locale}"].compact.join('&') if locale.present?
|
60
|
+
doc = REXML::Document.new Net::HTTP.get_response(url).body
|
55
61
|
retVal = [ doc.elements.collect(text_xpath){|c|c.text}, doc.elements.collect(value_xpath){|c|c.text} ].transpose
|
56
62
|
end
|
57
63
|
elsif content.present?
|
data/app/models/fe/element.rb
CHANGED
@@ -6,14 +6,17 @@ module Fe
|
|
6
6
|
attr_accessor :old_id
|
7
7
|
|
8
8
|
belongs_to :question_grid,
|
9
|
-
|
9
|
+
class_name: "Fe::QuestionGrid",
|
10
|
+
optional: true
|
10
11
|
|
11
12
|
belongs_to :question_grid_with_total,
|
12
|
-
|
13
|
-
foreign_key: "question_grid_id"
|
13
|
+
class_name: "Fe::QuestionGridWithTotal",
|
14
|
+
foreign_key: "question_grid_id",
|
15
|
+
optional: true
|
14
16
|
|
15
17
|
belongs_to :choice_field,
|
16
|
-
|
18
|
+
class_name: "Fe::ChoiceField",
|
19
|
+
optional: true
|
17
20
|
|
18
21
|
has_many :choice_field_children, foreign_key: 'choice_field_id',
|
19
22
|
class_name: 'Fe::Element'
|
@@ -46,9 +49,13 @@ module Fe
|
|
46
49
|
after_save :update_page_all_element_ids
|
47
50
|
after_save :update_any_previous_conditional_elements
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
+
[:label_translations, :tip_translations, :content_translations].each do |column|
|
53
|
+
if Rails::VERSION::MAJOR < 7
|
54
|
+
serialize column, Hash
|
55
|
+
else
|
56
|
+
serialize column, type: Hash
|
57
|
+
end
|
58
|
+
end
|
52
59
|
|
53
60
|
# HUMANIZED_ATTRIBUTES = {
|
54
61
|
# slug: "Variable"
|
data/app/models/fe/page.rb
CHANGED
@@ -45,7 +45,11 @@ module Fe
|
|
45
45
|
|
46
46
|
# NOTE: You may need config.active_record.yaml_column_permitted_classes = [Hash, ActiveSupport::HashWithIndifferentAccess]
|
47
47
|
# in config/application.rb or you may get Psych::DisallowedClass trying to use label_translations
|
48
|
-
|
48
|
+
if Rails::VERSION::MAJOR < 7
|
49
|
+
serialize :label_translations, Hash
|
50
|
+
else
|
51
|
+
serialize :label_translations, type: Hash
|
52
|
+
end
|
49
53
|
|
50
54
|
# a page is disabled if there is a condition, and that condition evaluates to false
|
51
55
|
# could set multiple conditions to influence this question, in which case all must be met
|
@@ -89,7 +93,7 @@ module Fe
|
|
89
93
|
def all_elements
|
90
94
|
ids = all_element_ids_arr
|
91
95
|
order = ids.collect{ |id| "id=#{id} DESC" }.join(', ')
|
92
|
-
ids.present? ? Element.where(id: ids).order(Arel.sql(order)) : Element.where(
|
96
|
+
ids.present? ? Element.where(id: ids).order(Arel.sql(order)) : Element.where(id: [])
|
93
97
|
end
|
94
98
|
|
95
99
|
def all_element_ids
|
data/app/models/fe/question.rb
CHANGED
@@ -27,9 +27,9 @@ module Fe
|
|
27
27
|
dependent: :destroy
|
28
28
|
|
29
29
|
belongs_to :related_question_sheet,
|
30
|
-
optional: true,
|
31
30
|
class_name: "QuestionSheet",
|
32
|
-
foreign_key: "related_question_sheet_id"
|
31
|
+
foreign_key: "related_question_sheet_id",
|
32
|
+
optional: true
|
33
33
|
|
34
34
|
# validates_inclusion_of :required, in: [false, true]
|
35
35
|
|
@@ -97,7 +97,7 @@ module Fe
|
|
97
97
|
|
98
98
|
# convert posted response to a question into Array of values
|
99
99
|
def posted_values(param)
|
100
|
-
|
100
|
+
param = param.to_h if param.is_a?(ActionController::Parameters)
|
101
101
|
if param.kind_of?(Hash) and param.has_key?('year') and param.has_key?('month')
|
102
102
|
year = param['year']
|
103
103
|
month = param['month']
|
@@ -21,7 +21,11 @@ module Fe
|
|
21
21
|
|
22
22
|
validates_presence_of :label
|
23
23
|
|
24
|
-
|
24
|
+
if Rails::VERSION::MAJOR < 7
|
25
|
+
serialize :languages, Array
|
26
|
+
else
|
27
|
+
serialize :languages, type: Array
|
28
|
+
end
|
25
29
|
|
26
30
|
before_destroy :check_for_answers
|
27
31
|
|
@@ -42,7 +46,7 @@ module Fe
|
|
42
46
|
|
43
47
|
def all_elements
|
44
48
|
element_ids = pages.pluck(:all_element_ids).compact.join(',').split(',').find_all(&:present?)
|
45
|
-
element_ids.present? ? Element.where(id: element_ids).order(Arel.sql(element_ids.collect{ |id| "id=#{id} DESC" }.join(', '))) : Element.where(
|
49
|
+
element_ids.present? ? Element.where(id: element_ids).order(Arel.sql(element_ids.collect{ |id| "id=#{id} DESC" }.join(', '))) : Element.where(id: [])
|
46
50
|
end
|
47
51
|
|
48
52
|
# Pages get duplicated
|
@@ -68,7 +72,7 @@ module Fe
|
|
68
72
|
# NOTE: yaml will break if some classes aren't loaded before YAML::load, strange
|
69
73
|
Fe::Element.distinct.where.not(kind: 'Fe::Style').pluck(:kind).each(&:constantize)
|
70
74
|
|
71
|
-
sheet_data =
|
75
|
+
sheet_data = Psych.unsafe_load_file(filename)
|
72
76
|
sheet_data[:old_id] = sheet_data.delete("id")
|
73
77
|
pages = sheet_data.delete(:pages)
|
74
78
|
puts("Create import by data #{sheet_data}")
|
@@ -16,7 +16,7 @@ class CreateVersions < ActiveRecord::Migration[4.2]
|
|
16
16
|
TEXT_BYTES = 1_073_741_823
|
17
17
|
|
18
18
|
def change
|
19
|
-
create_table :versions, versions_table_options do |t|
|
19
|
+
create_table :versions, options: versions_table_options do |t|
|
20
20
|
t.string :item_type, item_type_options
|
21
21
|
t.integer :item_id, null: false
|
22
22
|
t.string :event, null: false
|
@@ -71,10 +71,6 @@ class CreateVersions < ActiveRecord::Migration[4.2]
|
|
71
71
|
# - https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html
|
72
72
|
#
|
73
73
|
def versions_table_options
|
74
|
-
|
75
|
-
{ options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }
|
76
|
-
else
|
77
|
-
{}
|
78
|
-
end
|
74
|
+
mysql? ? "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" : ""
|
79
75
|
end
|
80
76
|
end
|
data/lib/fe/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|