survey_on_rails 0.4.3 → 1.0.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.
- data/gen/models/model.rb +6 -2
- data/gen/models/styles.rb +1 -1
- data/gen/models/view.rb +4 -0
- data/lib/generators/survey/USAGE +4 -4
- data/lib/generators/survey/metamodels/app.rb +38 -27
- data/lib/generators/survey/metamodels/base.rb +31 -29
- data/lib/generators/survey/metamodels/main.rb +1 -0
- data/lib/generators/survey/metamodels/model.rb +22 -54
- data/lib/generators/survey/metamodels/static.rb +44 -0
- data/lib/generators/survey/metamodels/style.rb +64 -83
- data/lib/generators/survey/metamodels/types.rb +2 -0
- data/lib/generators/survey/metamodels/validation.rb +15 -2
- data/lib/generators/survey/metamodels/view.rb +124 -172
- data/lib/generators/survey/showcase/assets/static_pages/about.html.erb +10 -0
- data/lib/generators/survey/showcase/assets/static_pages/contact.html.erb +7 -0
- data/lib/generators/survey/showcase/assets/static_pages/help.html.erb +8 -0
- data/lib/generators/survey/showcase/assets/static_pages/home.html.erb +11 -0
- data/lib/generators/survey/showcase/models/app.rb +10 -0
- data/lib/generators/survey/showcase/models/model.rb +13 -0
- data/lib/generators/survey/showcase/models/static.rb +22 -0
- data/lib/generators/survey/showcase/models/styles.rb +3 -0
- data/lib/generators/survey/showcase/models/view.rb +13 -0
- data/lib/generators/survey/survey_generator.rb +11 -0
- data/lib/generators/survey/templates/app/assets/stylesheets/stylesheet.tpl +7 -7
- data/lib/generators/survey/templates/app/controllers/survey_controller.tpl +1 -1
- data/lib/generators/survey/templates/app/models/validator.tpl +2 -2
- data/lib/generators/survey/templates/app/views/{form → forms}/checkbox_group.tpl +12 -12
- data/lib/generators/survey/templates/app/views/{form → forms}/choice_question.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/dropdown.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/element.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/form.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/group.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/horizontal_radio_button_group.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/image.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/pagination.tpl +4 -5
- data/lib/generators/survey/templates/app/views/{form → forms}/radio_button_group.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/table.tpl +0 -0
- data/lib/generators/survey/templates/app/views/{form → forms}/textfield.tpl +0 -0
- data/lib/generators/survey/templates/app/views/layouts/header.tpl +31 -31
- data/lib/generators/survey/templates/app/views/views.tpl +1 -1
- metadata +29 -17
- checksums.yaml +0 -15
data/gen/models/model.rb
CHANGED
@@ -5,8 +5,8 @@ SURVEYS = SurveyOnRails::Builder::build do
|
|
5
5
|
text(:title => "A textfield with suffix and color", :name => "textfield_3")
|
6
6
|
text "textfield_4", :title => "A small textfield"
|
7
7
|
text "textfield_5", :title => "A multiline textfield"
|
8
|
-
text "textfield_6", :title => "A textfield with color"
|
9
|
-
text "textfield_6_1", :title => "A textfield with number rule." do
|
8
|
+
text "textfield_6", :title => "A textfield with color" do dependency :requires => "textfield_6_1", :value => "25" end
|
9
|
+
text "textfield_6_1", :title => "A textfield with number rule." do integerRule end
|
10
10
|
text "textfield_7", :title => "A textfield with info text" do presenceRule end
|
11
11
|
|
12
12
|
multipleChoice "multiple_choice_1", :title => "A multiple choice." do
|
@@ -102,6 +102,10 @@ SURVEYS = SurveyOnRails::Builder::build do
|
|
102
102
|
text "textfield_14", :title => "A normal textfield"
|
103
103
|
end
|
104
104
|
|
105
|
+
survey("survey_3", :author => "Max Mustermann", :title => "Also a survey") do
|
106
|
+
text "textfield_15", :title => "A normal textfield"
|
107
|
+
end
|
108
|
+
|
105
109
|
survey("product_survey", :author => "Max Mustermann", :title => "Product survey") do
|
106
110
|
text :name => "comment_1", :title => "How would you comment the new product?"
|
107
111
|
end
|
data/gen/models/styles.rb
CHANGED
@@ -6,7 +6,7 @@ STYLES = SurveyOnRails::Builder::build do
|
|
6
6
|
staticStyle :element_names => "choice_23", :foreground => :blue, :background => :red
|
7
7
|
staticStyle :element_names => "group_1, group_2, table_5", :foreground => :black, :background => :white
|
8
8
|
|
9
|
-
staticStyle :element_types => "radio_button_group, horizontal_radio_button_group", :background => :lightGray, :font_style => :italic
|
9
|
+
staticStyle :element_types => "radio_button_group, horizontal_radio_button_group", :element_names => "textfield_1", :background => :lightGray, :font_style => :italic
|
10
10
|
|
11
11
|
staticStyle(:element_names => "textfield_21", :margin => 10, :padding => 5, :background => :lightGray, :foreground => :white, :font_size => 20, :font_style => :oblique, :font_weight => :bold,
|
12
12
|
:horizontal_alignment => :center, :vertical_alignment => :middle) do
|
data/gen/models/view.rb
CHANGED
data/lib/generators/survey/USAGE
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
Description:
|
2
|
-
This generator will generate classes for a rails application to display a survey.
|
3
|
-
|
4
|
-
Example:
|
1
|
+
Description:
|
2
|
+
This generator will generate classes for a rails application to display a survey.
|
3
|
+
|
4
|
+
Example:
|
5
5
|
rails generate survey
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module SurveyMetamodel extend RGen::MetamodelBuilder::ModuleExtension
|
2
2
|
class View < Base
|
3
3
|
contains_many 'forms', Form, 'view'
|
4
|
-
|
5
4
|
contains_one 'header', Header, 'view'
|
6
5
|
contains_one 'footer', Footer, 'view'
|
7
6
|
contains_many 'static_pages', StaticPage, 'view'
|
@@ -20,49 +19,61 @@ end
|
|
20
19
|
|
21
20
|
module SurveyMetamodel
|
22
21
|
module Application::ClassModule
|
22
|
+
def model_surveys
|
23
|
+
model.surveys if !model.nil? and !model.surveys.nil?
|
24
|
+
end
|
25
|
+
|
23
26
|
def view_forms
|
24
27
|
view.forms if !view.nil? and !view.forms.nil?
|
25
28
|
end
|
26
29
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def all_survey_questions
|
31
|
+
return model.survey_questions.flatten.uniq
|
32
|
+
end
|
33
|
+
|
34
|
+
def all_view_elements
|
35
|
+
elements = view.form_elements
|
36
|
+
all_elements = (view_forms + elements)
|
37
|
+
elements.each { |element| all_elements << element.elements if ((element.is_a?(Group) or element.is_a?(Page)) and !element.is_a?(Image)) }
|
38
|
+
return all_elements.flatten.uniq
|
34
39
|
end
|
35
40
|
|
36
41
|
def preprocessing
|
37
42
|
model.survey_questions.each { |question| question.init } if !model.nil?
|
38
43
|
if !view.nil?
|
39
|
-
view.static_pages.each { |static_page| static_page.create_page_file }
|
40
|
-
view.header.elements.each { |element| element.init }
|
41
|
-
view.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
view.static_pages.each { |static_page| static_page.create_page_file } if !view.static_pages.nil?
|
45
|
+
view.header.elements.each { |element| element.init } if !view.header.nil? and !view.header.elements.nil?
|
46
|
+
view.footer.elements.each { |element| element.init } if !view.header.nil? and !view.footer.elements.nil?
|
47
|
+
if !view.forms.nil? and !view.forms.elements.nil?
|
48
|
+
view.form_elements.each do |element|
|
49
|
+
element.init
|
50
|
+
element.set_model_element
|
51
|
+
end
|
46
52
|
end
|
47
|
-
view.
|
48
|
-
|
49
|
-
|
53
|
+
if !view.nil? and !view.forms.nil?
|
54
|
+
view_forms.each do |form|
|
55
|
+
form.init
|
56
|
+
form.set_model_element
|
57
|
+
form.set_page_elements
|
58
|
+
end
|
50
59
|
end
|
51
60
|
check_for_inconsistencies
|
52
61
|
end
|
53
62
|
end
|
54
63
|
|
55
64
|
def check_for_inconsistencies
|
56
|
-
|
57
|
-
|
58
|
-
if
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
65
|
+
all_survey_questions.each do |question_1|
|
66
|
+
all_survey_questions.each do |question_2|
|
67
|
+
raise "Model elements cannot have the same name (name='#{element_1.name}')!" if question_1.name? and question_2.name? and question_1.name == question_2.name and (question_1 != question_2)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
all_view_elements.each do |element_1|
|
72
|
+
all_view_elements.each do |element_2|
|
73
|
+
raise "View elements can only be associated to a exactly one model element (name='#{element_1.name}')!" if (!element_1.model_element.nil? and !element_2.model_element.nil?) and ((element_1.model_element == element_2.model_element) and (element_1 != element_2))
|
74
|
+
raise "Pages cannot contain other pages (name='#{element_1.name}')!" if element_1.is_a?(Page) and !element_1.elements.nil? and element_1.elements.any? { |e| e.is_a?(Page) }
|
63
75
|
end
|
64
76
|
end
|
65
|
-
return true
|
66
77
|
end
|
67
78
|
end
|
68
79
|
|
@@ -82,7 +93,7 @@ module SurveyMetamodel
|
|
82
93
|
end
|
83
94
|
|
84
95
|
def form_inputs
|
85
|
-
form_elements.select { |q| q.is_a?(Input) }
|
96
|
+
form_elements.select { |q| q.is_a?(Input) } if !form_elements.nil?
|
86
97
|
end
|
87
98
|
end
|
88
99
|
end
|
@@ -32,32 +32,32 @@ module SurveyMetamodel
|
|
32
32
|
end
|
33
33
|
|
34
34
|
module Element::ClassModule
|
35
|
-
def
|
36
|
-
|
35
|
+
def name?
|
36
|
+
!name.blank?
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
|
39
|
+
def title?
|
40
|
+
!title.blank?
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
43
|
+
def has_name?
|
44
|
+
return !(self.is_a?(Group) or self.is_a?(Image) or self.is_a?(Page) or self.is_a?(SurveyManagement) or self.is_a?(UserManagement))
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
48
|
-
|
47
|
+
def snake_name
|
48
|
+
plural_name.underscore if plural_name?
|
49
49
|
end
|
50
|
-
|
51
|
-
def
|
52
|
-
|
50
|
+
|
51
|
+
def snake_name_singular
|
52
|
+
name.underscore if name?
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
|
55
|
+
def camel_name
|
56
|
+
plural_name.camelize if plural_name?
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
60
|
-
|
59
|
+
def file_name
|
60
|
+
((plural_name.split('').any? { |c| c =~ /^[0-9]$/ })? plural_name.gsub!('_', ''): plural_name) if plural_name?
|
61
61
|
end
|
62
62
|
|
63
63
|
def init
|
@@ -76,20 +76,20 @@ module SurveyMetamodel
|
|
76
76
|
|
77
77
|
private
|
78
78
|
|
79
|
-
def
|
80
|
-
|
79
|
+
def plural_name?
|
80
|
+
!plural_name.blank?
|
81
81
|
end
|
82
82
|
|
83
|
-
def
|
84
|
-
|
83
|
+
def plural_name
|
84
|
+
name.pluralize if name?
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
88
|
-
|
87
|
+
def set_name
|
88
|
+
self.name = unique_name if !name?
|
89
89
|
end
|
90
90
|
|
91
|
-
def
|
92
|
-
|
91
|
+
def set_title
|
92
|
+
self.title = unique_title if !title?
|
93
93
|
end
|
94
94
|
|
95
95
|
def unique_name
|
@@ -101,8 +101,12 @@ module SurveyMetamodel
|
|
101
101
|
name.camelize if !name?
|
102
102
|
end
|
103
103
|
|
104
|
+
def init_all(collection)
|
105
|
+
collection.each { |e| e.init } if !collection.nil?
|
106
|
+
end
|
107
|
+
|
104
108
|
def init_with(new_name)
|
105
|
-
{ :name => "#{new_name.to_underscore}", :title => "#{new_name}" }
|
109
|
+
return { :name => "#{new_name.to_underscore}", :title => "#{new_name}" }
|
106
110
|
end
|
107
111
|
|
108
112
|
def choices_by_s(string)
|
@@ -110,11 +114,9 @@ module SurveyMetamodel
|
|
110
114
|
end
|
111
115
|
|
112
116
|
def choices_by_a(array)
|
113
|
-
|
114
|
-
array.each
|
115
|
-
|
116
|
-
end
|
117
|
-
return tmp_choices
|
117
|
+
choices_a = Array.new
|
118
|
+
array.each { |choice| choices_a << Choice.new(init_with(choice.strip)) }
|
119
|
+
return choices_a
|
118
120
|
end
|
119
121
|
end
|
120
122
|
end
|
@@ -3,22 +3,17 @@ module SurveyMetamodel extend RGen::MetamodelBuilder::ModuleExtension
|
|
3
3
|
abstract
|
4
4
|
end
|
5
5
|
|
6
|
-
class Survey < ModelElement
|
7
|
-
has_attr 'author', String
|
8
|
-
contains_many 'questions', ModelElement, 'survey'
|
9
|
-
end
|
10
|
-
|
11
|
-
class Dependency < Base
|
12
|
-
has_attr 'requires', String
|
13
|
-
has_attr 'value', String
|
14
|
-
end
|
15
|
-
|
16
6
|
class Question < ModelElement
|
17
7
|
abstract
|
18
8
|
contains_many 'rules', ValidationRule, 'question'
|
19
9
|
contains_many 'dependencies', Dependency, 'question'
|
20
10
|
end
|
21
11
|
|
12
|
+
class Survey < ModelElement
|
13
|
+
has_attr 'author', String
|
14
|
+
contains_many 'questions', Question, 'survey'
|
15
|
+
end
|
16
|
+
|
22
17
|
class Text < Question
|
23
18
|
end
|
24
19
|
|
@@ -55,6 +50,7 @@ module SurveyMetamodel extend RGen::MetamodelBuilder::ModuleExtension
|
|
55
50
|
|
56
51
|
has_attr 'rows_s', String
|
57
52
|
contains_many 'rows', Row, 'matrix'
|
53
|
+
|
58
54
|
has_attr 'columns_s', String
|
59
55
|
contains_many 'columns', Column, 'matrix'
|
60
56
|
|
@@ -64,77 +60,49 @@ module SurveyMetamodel extend RGen::MetamodelBuilder::ModuleExtension
|
|
64
60
|
end
|
65
61
|
|
66
62
|
module SurveyMetamodel
|
67
|
-
LIKERT_SCALE = ["Strongly disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"]
|
68
|
-
|
69
|
-
module Dependency::ClassModule
|
70
|
-
def condition
|
71
|
-
return "(!params[:#{requires}].blank? and params[:#{requires}][:content] == '#{value}')"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
63
|
module Question::ClassModule
|
76
64
|
def conditions
|
77
65
|
conditions_a = Array.new
|
78
|
-
dependencies.each
|
79
|
-
conditions_a << dependency.condition
|
80
|
-
end
|
66
|
+
dependencies.each { |dependency| conditions_a << dependency.condition }
|
81
67
|
return "(#{conditions_a.join(" and ")})"
|
82
68
|
end
|
83
69
|
end
|
84
70
|
|
85
|
-
module
|
71
|
+
module ChoiceQuestion::ClassModule
|
86
72
|
def real_choices
|
87
|
-
|
88
|
-
choices2 = Array.new
|
89
|
-
(min..max).each { |i| choices2 << Choice.new(:name => "#{self.name}_choice_#{i}", :title => "#{i}") }
|
90
|
-
choices2
|
91
|
-
elsif type == :likert
|
92
|
-
choices_by_a(LIKERT_SCALE)
|
93
|
-
elsif self.is_a?(RatingScale)
|
94
|
-
choices
|
95
|
-
end
|
73
|
+
return (!choices_s.blank? and choices.empty?)? choices_by_s(choices_s): choices
|
96
74
|
end
|
97
75
|
end
|
98
76
|
|
99
|
-
module
|
77
|
+
module RatingScale::ClassModule
|
100
78
|
def real_choices
|
101
|
-
if
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
79
|
+
if type == :numerical
|
80
|
+
choices_a = Array.new
|
81
|
+
(min..max).each { |i| choices_a << Choice.new(:name => "#{self.name}_choice_#{i}", :title => "#{i}") }
|
82
|
+
return choices_a
|
83
|
+
elsif type == :likert
|
84
|
+
return choices_by_a(LIKERT_SCALE)
|
85
|
+
else
|
86
|
+
return choices
|
107
87
|
end
|
108
88
|
end
|
109
89
|
end
|
110
90
|
|
111
91
|
module Matrix::ClassModule
|
112
92
|
def real_rows
|
113
|
-
|
114
|
-
choices_by_s(rows_s)
|
115
|
-
else
|
116
|
-
rows
|
117
|
-
end
|
93
|
+
return (!rows_s.blank? and rows.empty?)? choices_by_s(rows_s): rows
|
118
94
|
end
|
119
95
|
|
120
96
|
def real_columns
|
121
97
|
if type == :likert
|
122
98
|
choices_by_s(LIKERT_SCALE.join(','))
|
123
|
-
|
124
|
-
|
125
|
-
choices_by_s(columns_s)
|
126
|
-
else
|
127
|
-
columns
|
128
|
-
end
|
99
|
+
else
|
100
|
+
return (!columns_s.blank? and columns.empty?)? choices_by_s(columns_s): columns
|
129
101
|
end
|
130
102
|
end
|
131
103
|
|
132
104
|
def real_choices
|
133
|
-
|
134
|
-
choices_by_s(choices_s)
|
135
|
-
else
|
136
|
-
choices
|
137
|
-
end
|
105
|
+
return (!choices_s.blank? and choices.empty?)? choices_by_s(choices_s): choices
|
138
106
|
end
|
139
107
|
end
|
140
108
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module SurveyMetamodel extend RGen::MetamodelBuilder::ModuleExtension
|
2
|
+
class StaticElement < ViewElement
|
3
|
+
abstract
|
4
|
+
end
|
5
|
+
|
6
|
+
class StaticView < ViewElement
|
7
|
+
abstract
|
8
|
+
contains_many 'elements', StaticElement, 'page'
|
9
|
+
end
|
10
|
+
|
11
|
+
class Header < StaticView
|
12
|
+
end
|
13
|
+
|
14
|
+
class Footer < StaticView
|
15
|
+
end
|
16
|
+
|
17
|
+
class StaticPage < StaticView
|
18
|
+
has_attr 'file', String
|
19
|
+
has_attr 'root', Boolean
|
20
|
+
end
|
21
|
+
|
22
|
+
class Label < StaticElement
|
23
|
+
end
|
24
|
+
|
25
|
+
class Link < StaticElement
|
26
|
+
has_attr 'url', String
|
27
|
+
has_attr 'path', Boolean
|
28
|
+
end
|
29
|
+
|
30
|
+
class SurveyManagement < StaticElement
|
31
|
+
end
|
32
|
+
|
33
|
+
class UserManagement < StaticElement
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module SurveyMetamodel
|
38
|
+
module StaticPage::ClassModule
|
39
|
+
def create_page_file
|
40
|
+
file_path = (!file.nil?)? file: "gen/assets/static_pages/#{name}.html.erb"
|
41
|
+
File.new(file_path, 'w') unless File.exists?(file_path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -6,7 +6,6 @@ module SurveyMetamodel extend RGen::MetamodelBuilder::ModuleExtension
|
|
6
6
|
|
7
7
|
class Style < Base
|
8
8
|
abstract
|
9
|
-
|
10
9
|
has_attr 'margin', Integer
|
11
10
|
has_attr 'padding', Integer
|
12
11
|
has_attr 'foreground', Color
|
@@ -30,8 +29,8 @@ module SurveyMetamodel extend RGen::MetamodelBuilder::ModuleExtension
|
|
30
29
|
|
31
30
|
class StyleElement < Element
|
32
31
|
abstract
|
33
|
-
contains_one 'style', ElementStyle, 'element'
|
34
32
|
has_attr 'custom_html', String
|
33
|
+
contains_one 'style', ElementStyle, 'element'
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
@@ -48,11 +47,11 @@ module SurveyMetamodel
|
|
48
47
|
|
49
48
|
module Style::ClassModule
|
50
49
|
def margin?
|
51
|
-
!margin.nil? and margin != 0
|
50
|
+
!margin.nil? and (margin != 0)
|
52
51
|
end
|
53
52
|
|
54
53
|
def padding?
|
55
|
-
!padding.nil? and margin != 0
|
54
|
+
!padding.nil? and (margin != 0)
|
56
55
|
end
|
57
56
|
|
58
57
|
def foreground?
|
@@ -64,102 +63,83 @@ module SurveyMetamodel
|
|
64
63
|
end
|
65
64
|
|
66
65
|
def font_size?
|
67
|
-
!font_size.nil? and
|
66
|
+
!font_size.nil? and (font_size != 0)
|
68
67
|
end
|
69
68
|
|
70
69
|
def font_style?
|
71
|
-
!
|
70
|
+
!style.nil?
|
72
71
|
end
|
73
72
|
|
74
73
|
def font_weight?
|
75
|
-
!
|
74
|
+
!weight.nil?
|
76
75
|
end
|
77
76
|
|
78
|
-
def
|
77
|
+
def horizontal_alignment?
|
79
78
|
!horizontal_align.nil?
|
80
79
|
end
|
81
80
|
|
82
|
-
def
|
81
|
+
def vertical_alignment?
|
83
82
|
!vertical_align.nil?
|
84
83
|
end
|
85
84
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
elsif color == :yellow
|
93
|
-
"#FFFF00"
|
94
|
-
elsif color == :gray
|
95
|
-
"#808080"
|
96
|
-
elsif color == :green
|
97
|
-
"#008000"
|
98
|
-
elsif color == :white
|
99
|
-
"#FFFFFF"
|
100
|
-
elsif color == :black
|
101
|
-
"#000000"
|
102
|
-
elsif color == :lightGray
|
103
|
-
"#D3D3D3"
|
104
|
-
elsif color == :darkGray
|
105
|
-
"#A9A9A9"
|
106
|
-
else
|
107
|
-
"#FFFFFF"
|
108
|
-
end
|
85
|
+
def foreground_color
|
86
|
+
color(foreground)
|
87
|
+
end
|
88
|
+
|
89
|
+
def background_color
|
90
|
+
color(background)
|
109
91
|
end
|
110
92
|
|
111
93
|
def style
|
112
|
-
|
113
|
-
"normal"
|
114
|
-
|
115
|
-
"
|
116
|
-
elsif font_style == :oblique
|
117
|
-
"oblique"
|
94
|
+
case font_style
|
95
|
+
when :normal then "normal"
|
96
|
+
when :italic then "italic"
|
97
|
+
when :oblique then "oblique"
|
118
98
|
end
|
119
99
|
end
|
120
100
|
|
121
101
|
def weight
|
122
|
-
|
123
|
-
"normal"
|
124
|
-
|
125
|
-
"italic"
|
102
|
+
case font_weight
|
103
|
+
when :normal then "normal"
|
104
|
+
when :bold then "bold"
|
126
105
|
end
|
127
106
|
end
|
128
107
|
|
129
108
|
def horizontal_align
|
130
|
-
|
131
|
-
"left"
|
132
|
-
|
133
|
-
"
|
134
|
-
elsif horizontal_alignment == :right
|
135
|
-
"right"
|
109
|
+
case horizontal_alignment
|
110
|
+
when :left then "left"
|
111
|
+
when :center then "center"
|
112
|
+
when :right then "right"
|
136
113
|
end
|
137
114
|
end
|
138
115
|
|
139
116
|
def vertical_align
|
140
|
-
|
141
|
-
"top"
|
142
|
-
|
143
|
-
"
|
144
|
-
elsif vertical_alignment == :bottom
|
145
|
-
"bottom"
|
117
|
+
case vertical_alignment
|
118
|
+
when :top then "top"
|
119
|
+
when :middle then "middle"
|
120
|
+
when :bottom then "bottom"
|
146
121
|
end
|
147
122
|
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def color(color)
|
127
|
+
case color
|
128
|
+
when :blue then "#0000FF"
|
129
|
+
when :red then "#FF0000"
|
130
|
+
when :yellow then "#FFFF00"
|
131
|
+
when :gray then "#808080"
|
132
|
+
when :green then "#008000"
|
133
|
+
when :white then "#FFFFFF"
|
134
|
+
when :black then "#000000"
|
135
|
+
when :lightGray then "#D3D3D3"
|
136
|
+
when :darkGray then "#A9A9A9"
|
137
|
+
else "#FFFFFF"
|
138
|
+
end
|
139
|
+
end
|
148
140
|
end
|
149
141
|
|
150
142
|
module StaticStyle::ClassModule
|
151
|
-
def names
|
152
|
-
names = Array.new
|
153
|
-
if element_names? and !element_types?
|
154
|
-
names = self.element_names.split(',')
|
155
|
-
elsif !element_names? and element_types?
|
156
|
-
names = self.element_types.split(',')
|
157
|
-
elsif element_names? and element_types?
|
158
|
-
names = self.element_names.split(',') + self.element_types.split(',')
|
159
|
-
end
|
160
|
-
return names.each {|s| s.strip! }
|
161
|
-
end
|
162
|
-
|
163
143
|
def element_names?
|
164
144
|
!element_names.blank?
|
165
145
|
end
|
@@ -167,36 +147,37 @@ module SurveyMetamodel
|
|
167
147
|
def element_types?
|
168
148
|
!element_types.blank?
|
169
149
|
end
|
150
|
+
|
151
|
+
def names_and_types
|
152
|
+
names_a = Array.new
|
153
|
+
names_a += self.element_names.split(',') if element_names?
|
154
|
+
names_a += self.element_types.split(',') if element_types?
|
155
|
+
return (names_a.each {|s| s.strip! })
|
156
|
+
end
|
170
157
|
end
|
171
158
|
|
172
159
|
module StyleElement::ClassModule
|
173
|
-
def has_style?(element)
|
174
|
-
return true if style?
|
175
|
-
|
176
|
-
container = nil
|
177
|
-
if !self.group.nil?
|
178
|
-
container = self.group
|
179
|
-
elsif self.is_a?(Input)
|
180
|
-
container = self
|
181
|
-
end
|
182
|
-
|
183
|
-
(!container.form.view.styles.select { |s| s.element_name == element.name }.empty?)
|
184
|
-
end
|
185
|
-
|
186
160
|
def style?
|
187
161
|
!style.nil?
|
188
162
|
end
|
189
163
|
|
164
|
+
def content?
|
165
|
+
!content.blank?
|
166
|
+
end
|
167
|
+
|
190
168
|
def content
|
191
169
|
if custom_html?
|
192
|
-
custom_html
|
170
|
+
return custom_html
|
193
171
|
elsif title?
|
194
|
-
title
|
172
|
+
return title
|
195
173
|
end
|
196
174
|
end
|
197
175
|
|
198
|
-
def
|
199
|
-
|
176
|
+
def has_style?(element)
|
177
|
+
return true if style?
|
178
|
+
container = self
|
179
|
+
container = self.group if !self.group.nil?
|
180
|
+
return (!container.form.view.styles.select { |s| s.element_name == element.name }.empty?)
|
200
181
|
end
|
201
182
|
end
|
202
183
|
end
|