interview 0.1.0 → 0.3.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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/interview.gemspec +1 -0
  3. data/lib/{generators/interview/install/templates → assets/javascripts}/interview.js.coffee +17 -25
  4. data/lib/{generators/interview/install/templates/bootstrap_interview.css.scss → assets/stylesheets/interview.css.scss} +3 -2
  5. data/lib/generators/interview/install/install_generator.rb +0 -2
  6. data/lib/generators/interview/install/templates/interview.rb +1 -1
  7. data/lib/interview.rb +65 -51
  8. data/lib/interview/association_methods.rb +2 -0
  9. data/lib/interview/builder.rb +32 -24
  10. data/lib/interview/control.rb +25 -7
  11. data/lib/interview/controls/actionbar.rb +41 -0
  12. data/lib/interview/controls/alert.rb +15 -0
  13. data/lib/interview/{association_attribute.rb → controls/association_attribute.rb} +8 -8
  14. data/lib/interview/{association_list_attribute.rb → controls/association_list_attribute.rb} +10 -9
  15. data/lib/interview/controls/attribute.rb +80 -0
  16. data/lib/interview/controls/auto_attribute.rb +16 -0
  17. data/lib/interview/controls/boolean_attribute.rb +20 -0
  18. data/lib/interview/controls/breadcrumbs.rb +15 -0
  19. data/lib/interview/controls/button.rb +25 -0
  20. data/lib/interview/controls/caret.rb +9 -0
  21. data/lib/interview/controls/collapse_container.rb +16 -0
  22. data/lib/interview/controls/container.rb +5 -0
  23. data/lib/interview/controls/container_attribute.rb +28 -0
  24. data/lib/interview/controls/date_attribute.rb +23 -0
  25. data/lib/interview/controls/datetime_attribute.rb +22 -0
  26. data/lib/interview/controls/decimal_attribute.rb +12 -0
  27. data/lib/interview/controls/dropdown.rb +35 -0
  28. data/lib/interview/controls/form.rb +35 -0
  29. data/lib/interview/controls/form_errors.rb +20 -0
  30. data/lib/interview/controls/glyphicon.rb +19 -0
  31. data/lib/interview/controls/grid.rb +62 -0
  32. data/lib/interview/controls/hidden_attribute.rb +11 -0
  33. data/lib/interview/controls/horizontal_form_container.rb +13 -0
  34. data/lib/interview/controls/html_control.rb +13 -0
  35. data/lib/interview/controls/html_doctype.rb +9 -0
  36. data/lib/interview/controls/html_headers.rb +12 -0
  37. data/lib/interview/{html_text_attribute.rb → controls/html_text_attribute.rb} +9 -5
  38. data/lib/interview/controls/image_attribute.rb +61 -0
  39. data/lib/interview/controls/image_gallery_attribute.rb +72 -0
  40. data/lib/interview/controls/image_light_box.rb +17 -0
  41. data/lib/interview/{integer_attribute.rb → controls/integer_attribute.rb} +0 -0
  42. data/lib/interview/controls/link.rb +90 -0
  43. data/lib/interview/controls/list.rb +20 -0
  44. data/lib/interview/controls/media_object.rb +37 -0
  45. data/lib/interview/controls/navigation.rb +11 -0
  46. data/lib/interview/controls/navigation_item.rb +33 -0
  47. data/lib/interview/controls/nested_form.rb +45 -0
  48. data/lib/interview/controls/nested_form_add_images.rb +15 -0
  49. data/lib/interview/controls/nested_form_add_link.rb +29 -0
  50. data/lib/interview/controls/nested_form_remove_link.rb +12 -0
  51. data/lib/interview/{option_attribute.rb → controls/option_attribute.rb} +19 -19
  52. data/lib/interview/controls/pagination.rb +12 -0
  53. data/lib/interview/controls/panel.rb +13 -0
  54. data/lib/interview/{polymorphic_add_link.rb → controls/polymorphic_add_link.rb} +1 -1
  55. data/lib/interview/controls/polymorphic_nested_form.rb +17 -0
  56. data/lib/interview/{nested_form_add_link.rb → controls/polymorphic_nested_form_add_link.rb} +12 -28
  57. data/lib/interview/controls/progress_bar.rb +18 -0
  58. data/lib/interview/controls/scaffold_card.rb +27 -0
  59. data/lib/interview/controls/scaffold_form.rb +108 -0
  60. data/lib/interview/controls/search_form.rb +25 -0
  61. data/lib/interview/controls/section.rb +16 -0
  62. data/lib/interview/{space.rb → controls/space.rb} +5 -6
  63. data/lib/interview/{string_attribute.rb → controls/string_attribute.rb} +0 -0
  64. data/lib/interview/controls/submit.rb +14 -0
  65. data/lib/interview/controls/tab.rb +27 -0
  66. data/lib/interview/controls/tab_box.rb +21 -0
  67. data/lib/interview/controls/text.rb +33 -0
  68. data/lib/interview/{text_attribute.rb → controls/text_attribute.rb} +7 -5
  69. data/lib/interview/controls/tooltip.rb +21 -0
  70. data/lib/interview/{tree.rb → controls/tree.rb} +2 -3
  71. data/lib/interview/{view.rb → controls/view.rb} +4 -6
  72. data/lib/interview/engine.rb +4 -0
  73. data/lib/interview/handler.rb +15 -0
  74. data/lib/interview/has_html_options.rb +29 -0
  75. data/lib/interview/meta_control.rb +18 -0
  76. data/lib/interview/nested_buildable.rb +17 -0
  77. data/lib/interview/version.rb +1 -1
  78. metadata +84 -54
  79. data/lib/interview/actionbar.rb +0 -39
  80. data/lib/interview/attribute.rb +0 -166
  81. data/lib/interview/boolean_attribute.rb +0 -59
  82. data/lib/interview/breadcrumbs.rb +0 -21
  83. data/lib/interview/button.rb +0 -29
  84. data/lib/interview/collapse_container.rb +0 -31
  85. data/lib/interview/condition_container.rb +0 -19
  86. data/lib/interview/container.rb +0 -13
  87. data/lib/interview/container_attribute.rb +0 -30
  88. data/lib/interview/date_attribute.rb +0 -20
  89. data/lib/interview/datetime_attribute.rb +0 -20
  90. data/lib/interview/decimal_attribute.rb +0 -10
  91. data/lib/interview/dropdown.rb +0 -39
  92. data/lib/interview/form.rb +0 -64
  93. data/lib/interview/form_errors.rb +0 -22
  94. data/lib/interview/grid.rb +0 -54
  95. data/lib/interview/has_controls.rb +0 -40
  96. data/lib/interview/hidden_attribute.rb +0 -15
  97. data/lib/interview/html_control.rb +0 -21
  98. data/lib/interview/image_attribute.rb +0 -59
  99. data/lib/interview/image_gallery_attribute.rb +0 -79
  100. data/lib/interview/image_light_box.rb +0 -19
  101. data/lib/interview/link.rb +0 -134
  102. data/lib/interview/list.rb +0 -26
  103. data/lib/interview/media_object.rb +0 -27
  104. data/lib/interview/navigation.rb +0 -55
  105. data/lib/interview/navigation_item.rb +0 -41
  106. data/lib/interview/navigation_item_old.rb +0 -26
  107. data/lib/interview/nested_form.rb +0 -66
  108. data/lib/interview/nested_form_add_images.rb +0 -33
  109. data/lib/interview/nested_form_remove_link.rb +0 -28
  110. data/lib/interview/panel.rb +0 -18
  111. data/lib/interview/progress_bar.rb +0 -25
  112. data/lib/interview/search_form.rb +0 -21
  113. data/lib/interview/tab.rb +0 -21
  114. data/lib/interview/tab_box.rb +0 -30
  115. data/lib/interview/text.rb +0 -45
  116. data/lib/interview/tooltip.rb +0 -38
@@ -1,26 +0,0 @@
1
- module Interview
2
- class NavigationItem < Link
3
-
4
- include HasControls
5
-
6
- attr_accessor :active
7
-
8
- def render
9
- css_class = "level#{ancestors.count-1}"
10
- css_class += " active" if @active
11
- show_siblings = @active || siblings.any? { |sib| sib.active }
12
-
13
- html = ::Builder::XmlMarkup.new
14
- html.li class: css_class do
15
- html << super
16
- end
17
- if show_siblings
18
- add_parent(build_children).each do |c|
19
- html << c.render
20
- end
21
- end
22
- return html.target!
23
- end
24
-
25
- end
26
- end
@@ -1,66 +0,0 @@
1
- module Interview
2
- class NestedForm < Control
3
- include HasControls
4
-
5
- attr_accessor :polymorphic, :align, :image_based # todo: align einbauen
6
- attr_reader :form_builder, :object
7
-
8
- def render
9
- assoc_form_builder = find_attribute! :form_builder
10
- assoc_method = find_attribute! :assoc_method
11
-
12
- html = ::Builder::XmlMarkup.new
13
- html.div class: 'nested_form_container' do
14
- if @image_based
15
- html << Interview::NestedFormAddImages.new.render
16
- end
17
- html << assoc_form_builder.fields_for(assoc_method.to_sym) do |form_builder|
18
- if @polymorphic
19
- render_polymorphic_nested_form(form_builder)
20
- else
21
- render_nested_form(form_builder)
22
- end
23
- end
24
- html.script class: 'nested_form_script', type: 'text/x-tmpl' do
25
- new_object = assoc_form_builder.object.association(assoc_method.to_sym).build # todo: polymorphic add link
26
- html << assoc_form_builder.fields_for(assoc_method.to_sym, new_object, :child_index => "${index}") do |form_builder|
27
- if @polymorphic
28
- render_polymorphic_nested_form(form_builder)
29
- else
30
- render_nested_form(form_builder)
31
- end
32
- end
33
- end
34
- end
35
- return html.target!
36
- end
37
-
38
- def render_nested_form(form_builder)
39
- @form_builder = form_builder
40
- @object = form_builder.object
41
- html = ::Builder::XmlMarkup.new
42
- html.div class: 'nested_form collapse in' do
43
- add_parent(build_children).each do |control|
44
- html << control.render
45
- end
46
- html << form_builder.hidden_field(:id)
47
- html << form_builder.hidden_field(:_destroy, class: 'nested_form_destroy')
48
- if @image_based
49
- html << form_builder.hidden_field(:upload_buffer_id, class: 'upload_buffer_id')
50
- end
51
- end
52
- html.target!.html_safe
53
- end
54
-
55
- def render_polymorphic_nested_form(form_builder)
56
- object = form_builder.object
57
- if klass = "#{object.class.name}NestedForm".safe_constantize
58
- nested_form = klass.new(parent: self)
59
- return nested_form.render_nested_form(form_builder)
60
- else
61
- return self.render_nested_form(form_builder)
62
- end
63
- end
64
-
65
- end
66
- end
@@ -1,33 +0,0 @@
1
- module Interview
2
- class NestedFormAddImages < Control
3
-
4
- attr_accessor :style
5
-
6
- def render
7
- if @style and @style.to_sym == :horizontal_form
8
- html = ::Builder::XmlMarkup.new # todo: in eigenes Objekt auslagern?
9
- html.div class: 'row' do
10
- html.div class: 'col-xs-9 col-xs-offset-3' do
11
- html << render_link
12
- end
13
- end
14
- return html.target!
15
- else
16
- return render_link
17
- end
18
- end
19
-
20
- def render_link
21
- html = ::Builder::XmlMarkup.new
22
- html.div class: "clearfix" do
23
- html.span class: "btn btn-default fileinput-button" do
24
- html.span "Bilder hinzufügen" # todo
25
- html << h.file_field_tag("upload_buffer[attachment]", class: 'nested_form_add_images',
26
- multiple: true, data: {url: "/upload_buffers.json", type: 'POST'})
27
- end
28
- end
29
- return html.target!
30
- end
31
-
32
- end
33
- end
@@ -1,28 +0,0 @@
1
- module Interview
2
- class NestedFormRemoveLink < Control
3
-
4
- attr_accessor :style
5
-
6
- def render
7
- if @style and @style.to_sym == :horizontal_form
8
- html = ::Builder::XmlMarkup.new
9
- html.div class: 'row' do
10
- html.div class: 'col-xs-9 col-xs-offset-3' do
11
- html << render_link
12
- end
13
- end
14
- return html.target!
15
- else
16
- return render_link
17
- end
18
- end
19
-
20
- def render_link
21
- assoc_object = find_attribute! :assoc_object
22
- assoc_method = find_attribute!(:assoc_method).to_s
23
- text = h.t('views.nested_form_remove', association: assoc_object.class.human_attribute_name(assoc_method.singularize)) # todo: in view auslagern
24
- return h.content_tag :a, text, href: '#', class: 'nested_form_remove_link'
25
- end
26
-
27
- end
28
- end
@@ -1,18 +0,0 @@
1
- module Interview
2
- class Panel < Control
3
- include HasControls
4
-
5
- def render
6
- html = ::Builder::XmlMarkup.new
7
- html.div class: 'panel panel-default' do
8
- html.div class: 'panel-body' do
9
- add_parent(build_children).each do |control|
10
- html << control.render
11
- end
12
- end
13
- end
14
- return html.target!
15
- end
16
-
17
- end
18
- end
@@ -1,25 +0,0 @@
1
- module Interview
2
- class ProgressBar < Control
3
-
4
- attr_accessor :hidden, :html_class
5
-
6
- def initialize(params={})
7
- super
8
- @html_class = []
9
- @html_class << params[:html_class] if params[:html_class]
10
- end
11
-
12
- def render
13
- html_class = @html_class
14
- html = ::Builder::XmlMarkup.new
15
- opts = { class: "progress" }
16
- opts[:class] += " collapse" if @hidden
17
- opts[:class] += ' ' + @html_class.join(' ') unless @html_class.empty?
18
- html.div opts do
19
- html.div '', class: 'progress-bar bar', style: 'width: 0%'
20
- end
21
- return html.target!
22
- end
23
-
24
- end
25
- end
@@ -1,21 +0,0 @@
1
- module Interview
2
- class SearchForm < Control
3
-
4
- def render
5
- object = find_attribute! :object
6
- return h.form_tag(h.polymorphic_path(object.class.model_name.plural, action: 'search'), method: :get, class: 'form-inline', role: 'form') do
7
- html = ::Builder::XmlMarkup.new(indent: 2)
8
- html.div do
9
- html.div class: 'form-group' do
10
- html << h.text_field_tag(:search, h.params[:search], class: 'form-control')
11
- end
12
- html.div class: 'form-group' do
13
- html << h.submit_tag('Suchen', :name => nil, class: 'form-control btn btn-primary') # todo: 'Suchen' ändern
14
- end
15
- end
16
- html.target!.html_safe
17
- end
18
- end
19
-
20
- end
21
- end
data/lib/interview/tab.rb DELETED
@@ -1,21 +0,0 @@
1
- module Interview
2
- class Tab < Control
3
-
4
- include HasControls
5
-
6
- attr_accessor :caption, :active
7
-
8
- def render
9
- html = ::Builder::XmlMarkup.new
10
- html_class = 'tab-pane'
11
- html_class += ' active' if @active
12
- html.div class: html_class, id: @caption do
13
- add_parent(build_children).each do |control|
14
- html << control.render
15
- end
16
- end
17
- return html.target!
18
- end
19
-
20
- end
21
- end
@@ -1,30 +0,0 @@
1
- module Interview
2
- class TabBox < Control
3
-
4
- include HasControls
5
-
6
- def render
7
- controls = add_parent(build_children)
8
- if controls.none? { |c| c.active }
9
- controls.first.active = true
10
- end
11
-
12
- html = ::Builder::XmlMarkup.new
13
- html.ul class: 'nav nav-tabs tab_box' do
14
- controls.each do |control|
15
- html_class = control.active ? 'active' : ''
16
- html.li class: html_class do
17
- html.a control.caption, href: "##{control.caption}", :'data-toogle' => 'tab'
18
- end
19
- end
20
- end
21
- html.div class: 'tab-content' do
22
- controls.each do |control|
23
- html << control.render
24
- end
25
- end
26
- return html.target!
27
- end
28
-
29
- end
30
- end
@@ -1,45 +0,0 @@
1
- module Interview
2
- class Text < Control
3
- include HasControls
4
-
5
- attr_accessor :text, :style, :bold, :html_class
6
-
7
- def initialize(params={})
8
- @html_class = []
9
- super
10
- end
11
-
12
- def render
13
- html = ::Builder::XmlMarkup.new
14
- if @style
15
- opts = {}
16
- opts[:class] = @html_class.join(' ') unless @html_class.empty?
17
- html.tag! @style.to_sym, opts do
18
- render_text(html)
19
- end
20
- else
21
- render_text(html)
22
- end
23
- return html.target!
24
- end
25
-
26
- protected
27
-
28
- def render_text(html)
29
- if @bold
30
- html.b do
31
- html << @text # todo: besser .text! statt << ?
32
- add_parent(build_children).each do |control|
33
- html << control.render
34
- end
35
- end
36
- else
37
- html << @text if @text # todo: besser .text! statt << ?
38
- add_parent(build_children).each do |control|
39
- html << control.render
40
- end
41
- end
42
- end
43
-
44
- end
45
- end
@@ -1,38 +0,0 @@
1
- module Interview
2
- class Tooltip < Control
3
-
4
- attr_accessor :tooltip, :style
5
-
6
- def tooltip
7
- @tooltip || find_attribute(:tooltip)
8
- end
9
-
10
- def render
11
- if @style and respond_to?("render_#{@style}_style", true)
12
- return send "render_#{@style}_style"
13
- else
14
- return render_default_style
15
- end
16
- end
17
-
18
- protected
19
-
20
- def render_default_style
21
- return "<p class='text-muted'>#{tooltip}</p>".html_safe
22
- end
23
-
24
- def render_box_style
25
- return "<div class='alert alert-info'>#{tooltip}</div>".html_safe
26
- end
27
-
28
- def render_popover_style
29
- html = ::Builder::XmlMarkup.new
30
- html.text! ' '
31
- html.a href: '#', class: 'tip', :'data-toggle' => 'popover', :'data-content' => tooltip do
32
- html.span '', class: 'glyphicon glyphicon-question-sign'
33
- end
34
- return html.target!
35
- end
36
-
37
- end
38
- end