interview 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/interview.gemspec +1 -0
- data/lib/{generators/interview/install/templates → assets/javascripts}/interview.js.coffee +17 -25
- data/lib/{generators/interview/install/templates/bootstrap_interview.css.scss → assets/stylesheets/interview.css.scss} +3 -2
- data/lib/generators/interview/install/install_generator.rb +0 -2
- data/lib/generators/interview/install/templates/interview.rb +1 -1
- data/lib/interview.rb +65 -51
- data/lib/interview/association_methods.rb +2 -0
- data/lib/interview/builder.rb +32 -24
- data/lib/interview/control.rb +25 -7
- data/lib/interview/controls/actionbar.rb +41 -0
- data/lib/interview/controls/alert.rb +15 -0
- data/lib/interview/{association_attribute.rb → controls/association_attribute.rb} +8 -8
- data/lib/interview/{association_list_attribute.rb → controls/association_list_attribute.rb} +10 -9
- data/lib/interview/controls/attribute.rb +80 -0
- data/lib/interview/controls/auto_attribute.rb +16 -0
- data/lib/interview/controls/boolean_attribute.rb +20 -0
- data/lib/interview/controls/breadcrumbs.rb +15 -0
- data/lib/interview/controls/button.rb +25 -0
- data/lib/interview/controls/caret.rb +9 -0
- data/lib/interview/controls/collapse_container.rb +16 -0
- data/lib/interview/controls/container.rb +5 -0
- data/lib/interview/controls/container_attribute.rb +28 -0
- data/lib/interview/controls/date_attribute.rb +23 -0
- data/lib/interview/controls/datetime_attribute.rb +22 -0
- data/lib/interview/controls/decimal_attribute.rb +12 -0
- data/lib/interview/controls/dropdown.rb +35 -0
- data/lib/interview/controls/form.rb +35 -0
- data/lib/interview/controls/form_errors.rb +20 -0
- data/lib/interview/controls/glyphicon.rb +19 -0
- data/lib/interview/controls/grid.rb +62 -0
- data/lib/interview/controls/hidden_attribute.rb +11 -0
- data/lib/interview/controls/horizontal_form_container.rb +13 -0
- data/lib/interview/controls/html_control.rb +13 -0
- data/lib/interview/controls/html_doctype.rb +9 -0
- data/lib/interview/controls/html_headers.rb +12 -0
- data/lib/interview/{html_text_attribute.rb → controls/html_text_attribute.rb} +9 -5
- data/lib/interview/controls/image_attribute.rb +61 -0
- data/lib/interview/controls/image_gallery_attribute.rb +72 -0
- data/lib/interview/controls/image_light_box.rb +17 -0
- data/lib/interview/{integer_attribute.rb → controls/integer_attribute.rb} +0 -0
- data/lib/interview/controls/link.rb +90 -0
- data/lib/interview/controls/list.rb +20 -0
- data/lib/interview/controls/media_object.rb +37 -0
- data/lib/interview/controls/navigation.rb +11 -0
- data/lib/interview/controls/navigation_item.rb +33 -0
- data/lib/interview/controls/nested_form.rb +45 -0
- data/lib/interview/controls/nested_form_add_images.rb +15 -0
- data/lib/interview/controls/nested_form_add_link.rb +29 -0
- data/lib/interview/controls/nested_form_remove_link.rb +12 -0
- data/lib/interview/{option_attribute.rb → controls/option_attribute.rb} +19 -19
- data/lib/interview/controls/pagination.rb +12 -0
- data/lib/interview/controls/panel.rb +13 -0
- data/lib/interview/{polymorphic_add_link.rb → controls/polymorphic_add_link.rb} +1 -1
- data/lib/interview/controls/polymorphic_nested_form.rb +17 -0
- data/lib/interview/{nested_form_add_link.rb → controls/polymorphic_nested_form_add_link.rb} +12 -28
- data/lib/interview/controls/progress_bar.rb +18 -0
- data/lib/interview/controls/scaffold_card.rb +27 -0
- data/lib/interview/controls/scaffold_form.rb +108 -0
- data/lib/interview/controls/search_form.rb +25 -0
- data/lib/interview/controls/section.rb +16 -0
- data/lib/interview/{space.rb → controls/space.rb} +5 -6
- data/lib/interview/{string_attribute.rb → controls/string_attribute.rb} +0 -0
- data/lib/interview/controls/submit.rb +14 -0
- data/lib/interview/controls/tab.rb +27 -0
- data/lib/interview/controls/tab_box.rb +21 -0
- data/lib/interview/controls/text.rb +33 -0
- data/lib/interview/{text_attribute.rb → controls/text_attribute.rb} +7 -5
- data/lib/interview/controls/tooltip.rb +21 -0
- data/lib/interview/{tree.rb → controls/tree.rb} +2 -3
- data/lib/interview/{view.rb → controls/view.rb} +4 -6
- data/lib/interview/engine.rb +4 -0
- data/lib/interview/handler.rb +15 -0
- data/lib/interview/has_html_options.rb +29 -0
- data/lib/interview/meta_control.rb +18 -0
- data/lib/interview/nested_buildable.rb +17 -0
- data/lib/interview/version.rb +1 -1
- metadata +84 -54
- data/lib/interview/actionbar.rb +0 -39
- data/lib/interview/attribute.rb +0 -166
- data/lib/interview/boolean_attribute.rb +0 -59
- data/lib/interview/breadcrumbs.rb +0 -21
- data/lib/interview/button.rb +0 -29
- data/lib/interview/collapse_container.rb +0 -31
- data/lib/interview/condition_container.rb +0 -19
- data/lib/interview/container.rb +0 -13
- data/lib/interview/container_attribute.rb +0 -30
- data/lib/interview/date_attribute.rb +0 -20
- data/lib/interview/datetime_attribute.rb +0 -20
- data/lib/interview/decimal_attribute.rb +0 -10
- data/lib/interview/dropdown.rb +0 -39
- data/lib/interview/form.rb +0 -64
- data/lib/interview/form_errors.rb +0 -22
- data/lib/interview/grid.rb +0 -54
- data/lib/interview/has_controls.rb +0 -40
- data/lib/interview/hidden_attribute.rb +0 -15
- data/lib/interview/html_control.rb +0 -21
- data/lib/interview/image_attribute.rb +0 -59
- data/lib/interview/image_gallery_attribute.rb +0 -79
- data/lib/interview/image_light_box.rb +0 -19
- data/lib/interview/link.rb +0 -134
- data/lib/interview/list.rb +0 -26
- data/lib/interview/media_object.rb +0 -27
- data/lib/interview/navigation.rb +0 -55
- data/lib/interview/navigation_item.rb +0 -41
- data/lib/interview/navigation_item_old.rb +0 -26
- data/lib/interview/nested_form.rb +0 -66
- data/lib/interview/nested_form_add_images.rb +0 -33
- data/lib/interview/nested_form_remove_link.rb +0 -28
- data/lib/interview/panel.rb +0 -18
- data/lib/interview/progress_bar.rb +0 -25
- data/lib/interview/search_form.rb +0 -21
- data/lib/interview/tab.rb +0 -21
- data/lib/interview/tab_box.rb +0 -30
- data/lib/interview/text.rb +0 -45
- data/lib/interview/tooltip.rb +0 -38
@@ -0,0 +1,108 @@
|
|
1
|
+
module Interview
|
2
|
+
class ScaffoldForm < Form
|
3
|
+
|
4
|
+
attr_accessor :style, :submit_caption
|
5
|
+
|
6
|
+
def build(b)
|
7
|
+
case @style
|
8
|
+
when 'horizontal'
|
9
|
+
@html_class << 'form-horizontal'
|
10
|
+
when 'inline'
|
11
|
+
@html_class << 'form-inline'
|
12
|
+
end
|
13
|
+
super(b) do
|
14
|
+
|
15
|
+
b.meta_control pointer: self do
|
16
|
+
yield if block_given?
|
17
|
+
end
|
18
|
+
|
19
|
+
if @style == 'horizontal'
|
20
|
+
b.section html_class: 'form-group' do
|
21
|
+
b.section html_class: 'col-sm-offset-3 col-sm-9' do
|
22
|
+
b.submit caption: @submit_caption
|
23
|
+
end
|
24
|
+
end
|
25
|
+
else
|
26
|
+
b.submit caption: @submit_caption
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_child(b, control, &block)
|
32
|
+
control.parent = self
|
33
|
+
control.style ||= 'write' if control.is_a? Attribute
|
34
|
+
|
35
|
+
if control.is_a? BooleanAttribute
|
36
|
+
build_boolean b, control, &block
|
37
|
+
elsif control.is_a? HiddenAttribute
|
38
|
+
build_hidden b, control, &block
|
39
|
+
elsif control.is_a? Attribute
|
40
|
+
build_default b, control, &block
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
b.space if @style == 'inline'
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def build_default(b, control, &block)
|
51
|
+
b.section html_class: 'form-group' do
|
52
|
+
b.section html_class: 'col-xs-3' if (control.caption == :hide or control.caption_as_placeholder) and @style == 'horizontal'
|
53
|
+
build_label(b, control)
|
54
|
+
if @style == 'horizontal'
|
55
|
+
b.section html_class: 'col-xs-9' do
|
56
|
+
b.add! control, &block
|
57
|
+
build_tooltip b, control
|
58
|
+
end
|
59
|
+
else
|
60
|
+
b.add! control, &block
|
61
|
+
build_tooltip b, control
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def build_boolean(b, control, &block)
|
67
|
+
b.section html_class: "form-group attribute_#{control.method.to_s} collapse in" do # todo: html_class
|
68
|
+
if @style == 'horizontal'
|
69
|
+
b.section html_class: 'col-xs-9 col-xs-offset-3' do
|
70
|
+
build_checkbox b, control
|
71
|
+
end
|
72
|
+
else
|
73
|
+
build_checkbox b, control
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def build_hidden(b, control)
|
79
|
+
b.add! control
|
80
|
+
end
|
81
|
+
|
82
|
+
def build_label(b, control)
|
83
|
+
return if control.caption == :hide
|
84
|
+
if control.caption_as_placeholder or @style == 'inline'
|
85
|
+
html_opts = { class: 'sr-only' }
|
86
|
+
elsif @style == 'horizontal'
|
87
|
+
html_opts = { class: 'col-xs-3 control-label' }
|
88
|
+
else
|
89
|
+
html_opts = {}
|
90
|
+
end
|
91
|
+
b << @form_builder.label(control.method, control.caption, html_opts)
|
92
|
+
end
|
93
|
+
|
94
|
+
def build_tooltip(b, control)
|
95
|
+
if control.tooltip != :hide
|
96
|
+
b.tooltip tooltip: control.tooltip
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def build_checkbox(b, control)
|
101
|
+
b.add! control
|
102
|
+
b.space
|
103
|
+
b << @form_builder.label(control.method, control.caption)
|
104
|
+
build_tooltip(b, control)
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Interview
|
2
|
+
class SearchForm < Control
|
3
|
+
|
4
|
+
include NestedBuildable
|
5
|
+
|
6
|
+
attr_accessor :object
|
7
|
+
|
8
|
+
def build(b)
|
9
|
+
object = @object || find_attribute!(:object)
|
10
|
+
b << h.form_tag(h.polymorphic_path(object.class.model_name.plural, action: 'search'), method: :get, class: 'form-inline', role: 'form') do
|
11
|
+
create_nested_builder(b)
|
12
|
+
b.section do
|
13
|
+
b.section html_class: 'form-group' do
|
14
|
+
b << h.text_field_tag(:search, h.params[:search], class: 'form-control')
|
15
|
+
end
|
16
|
+
b.section html_class: 'form-group' do
|
17
|
+
b << h.submit_tag('Suchen', :name => nil, class: 'form-control btn btn-primary') # todo: 'Suchen' ändern
|
18
|
+
end
|
19
|
+
end
|
20
|
+
render_nested_builder(b)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
module Interview
|
2
2
|
class Space < Control
|
3
|
+
|
3
4
|
attr_accessor :style
|
4
5
|
|
5
|
-
def
|
6
|
-
html = ::Builder::XmlMarkup.new
|
6
|
+
def build(b)
|
7
7
|
if @style and @style.to_sym == :line
|
8
|
-
|
8
|
+
b << '<hr />'
|
9
9
|
elsif @style and @style.to_sym == :break
|
10
|
-
|
10
|
+
b << '<br />'
|
11
11
|
else
|
12
|
-
|
12
|
+
b << ' '
|
13
13
|
end
|
14
|
-
return html.target!
|
15
14
|
end
|
16
15
|
|
17
16
|
end
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Interview
|
2
|
+
class Submit < Control
|
3
|
+
|
4
|
+
# todo: durch Button ersetzen?
|
5
|
+
|
6
|
+
attr_accessor :caption
|
7
|
+
|
8
|
+
def build(b)
|
9
|
+
form_builder = find_attribute! :form_builder
|
10
|
+
b << form_builder.submit(@caption, class: 'btn btn-primary')
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Interview
|
2
|
+
class Tab < Control
|
3
|
+
|
4
|
+
include HasHtmlOptions
|
5
|
+
|
6
|
+
attr_accessor :caption, :active
|
7
|
+
|
8
|
+
def build(b)
|
9
|
+
html_class = @html_class.dup
|
10
|
+
html_options = @html_options.dup
|
11
|
+
html_class << 'tab-pane'
|
12
|
+
html_class << 'active' if @active
|
13
|
+
html_options[:id] = @caption if @caption
|
14
|
+
b.section html_class: html_class, html_options: html_options do
|
15
|
+
yield if block_given?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_caption(b)
|
20
|
+
html_class = control.active ? 'active' : ''
|
21
|
+
b.section style: 'li', html_class: html_class do
|
22
|
+
b.link caption: @caption, url: "##{@caption}", html_options: { data: { toogle: 'tab' } }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Interview
|
2
|
+
class TabBox < Control
|
3
|
+
|
4
|
+
def build(b)
|
5
|
+
# todo: set auto first active
|
6
|
+
b.section style: 'ul', html_class: 'nav nav-tabs tab_box' do
|
7
|
+
b.meta_control pointer: self do
|
8
|
+
yield if block_given?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
b.section html_class: 'tab-content' do
|
12
|
+
yield if block_given?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_child(b, control, &block)
|
17
|
+
control.build_caption(b)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Interview
|
2
|
+
class Text < Control
|
3
|
+
|
4
|
+
include HasHtmlOptions
|
5
|
+
|
6
|
+
attr_accessor :text, :style, :html_safe
|
7
|
+
|
8
|
+
def build(b)
|
9
|
+
if @style
|
10
|
+
b.section style: @style, html_class: @html_class, html_options: @html_options do
|
11
|
+
build_text(b)
|
12
|
+
yield if block_given?
|
13
|
+
end
|
14
|
+
else
|
15
|
+
build_text(b)
|
16
|
+
yield if block_given?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def build_text(b)
|
23
|
+
if @text
|
24
|
+
if @html_safe
|
25
|
+
b.html << @text
|
26
|
+
else
|
27
|
+
b.html.text! @text
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -3,18 +3,20 @@ module Interview
|
|
3
3
|
|
4
4
|
attr_accessor :line_break, :cut, :rows
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
protected
|
7
|
+
|
8
|
+
def build_read(b)
|
9
|
+
return if value.nil?
|
8
10
|
line_break = @line_break || true
|
9
11
|
|
10
12
|
value = self.value.gsub(/\n/, '<br/>') if line_break
|
11
13
|
value = value[0..29] + '...' if @cut and value.size > 30
|
12
|
-
|
14
|
+
b << value.html_safe
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
17
|
+
def build_write(b)
|
16
18
|
rows = @rows || 8
|
17
|
-
form_builder.text_area
|
19
|
+
b << form_builder.text_area(@method, class: 'form-control', rows: rows)
|
18
20
|
end
|
19
21
|
|
20
22
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Interview
|
2
|
+
class Tooltip < Control
|
3
|
+
|
4
|
+
attr_accessor :tooltip, :style
|
5
|
+
|
6
|
+
def build(b)
|
7
|
+
tooltip = @tooltip || find_attribute(:tooltip)
|
8
|
+
if @style == 'box'
|
9
|
+
b.section html_class: 'alert alert-info' do
|
10
|
+
b.text text: tooltip
|
11
|
+
end
|
12
|
+
elsif @style == 'popover'
|
13
|
+
b.space
|
14
|
+
b.link image: 'question-sign', url: '#', html_class: 'tip', html_options: { data: { toogle: 'popover', content: tooltip } }
|
15
|
+
else
|
16
|
+
b.text text: tooltip, style: 'p', html_class: 'help-block'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -3,7 +3,7 @@ module Interview
|
|
3
3
|
|
4
4
|
attr_accessor :sortable, :icon
|
5
5
|
|
6
|
-
def
|
6
|
+
def build(b)
|
7
7
|
defaults = {}
|
8
8
|
defaults[:icon] = @icon if @icon and @icon != :polymorphic
|
9
9
|
objects = find_attribute! :objects
|
@@ -25,8 +25,7 @@ module Interview
|
|
25
25
|
data = { content: CGI::escapeHTML(data_content.to_json) }
|
26
26
|
data[:sortable] = true if @sortable
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
b.section html_class: 'jstree', html_options: { data: data }
|
30
29
|
end
|
31
30
|
|
32
31
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Interview
|
2
2
|
class View < Control
|
3
|
-
include HasControls
|
4
3
|
|
5
4
|
attr_accessor :object, :objects, :filter, :scope, :title, :auto_title_for
|
6
5
|
attr_reader :assoc_object, :assoc_method
|
@@ -52,7 +51,7 @@ module Interview
|
|
52
51
|
# todo: tooltip von Elternelement verwenden, falls nicht vorhanden.
|
53
52
|
end
|
54
53
|
|
55
|
-
def
|
54
|
+
def build(b)
|
56
55
|
tmp_object = @object
|
57
56
|
tmp_objects = @objects
|
58
57
|
|
@@ -60,11 +59,11 @@ module Interview
|
|
60
59
|
# if Object::const_defined?(@object.camelcase) # todo: Überdenken!
|
61
60
|
# @object = @object.camelcase.constantize.new
|
62
61
|
# else
|
63
|
-
@assoc_object = find_attribute! :object
|
62
|
+
@assoc_object = @parent.find_attribute! :object
|
64
63
|
@object = @object.split('.').inject(@assoc_object, :send)
|
65
64
|
# end
|
66
65
|
elsif @object.is_a? Proc
|
67
|
-
@assoc_object = find_attribute! :object
|
66
|
+
@assoc_object = @parent.find_attribute! :object
|
68
67
|
@object = @object.call(@assoc_object, self)
|
69
68
|
elsif @object.is_a? Class
|
70
69
|
@object = @object.new
|
@@ -98,11 +97,10 @@ module Interview
|
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
101
|
-
|
100
|
+
yield if block_given?
|
102
101
|
|
103
102
|
@object = tmp_object
|
104
103
|
@objects = tmp_objects
|
105
|
-
return html
|
106
104
|
end
|
107
105
|
|
108
106
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Interview
|
2
|
+
class Handler
|
3
|
+
|
4
|
+
class_attribute :default_format
|
5
|
+
self.default_format = Mime::HTML
|
6
|
+
|
7
|
+
def self.call(template)
|
8
|
+
"builder = ::Interview::Builder.new; "+
|
9
|
+
"b = builder; "+
|
10
|
+
template.source +
|
11
|
+
"\nbuilder.render!"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Interview
|
2
|
+
module HasHtmlOptions
|
3
|
+
|
4
|
+
attr_accessor :html_options, :html_class
|
5
|
+
|
6
|
+
def initialize(params={})
|
7
|
+
@html_options = {}
|
8
|
+
@html_class = []
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def html_class=(html_class)
|
13
|
+
if html_class.is_a? Array
|
14
|
+
@html_class = html_class
|
15
|
+
elsif html_class.is_a? String
|
16
|
+
@html_class += html_class.split
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def options_to_html(html_options = @html_options, html_class = @html_class)
|
23
|
+
opts = html_options.dup
|
24
|
+
opts[:class] = html_class.join(' ') unless html_class.empty?
|
25
|
+
return opts
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|