interview 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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,21 +0,0 @@
1
- module Interview
2
- class HtmlControl < Control
3
-
4
- def initialize(params={}, &block)
5
- super
6
- @html = ::Builder::XmlMarkup.new
7
- if block
8
- yield @html
9
- end
10
- end
11
-
12
- def add_block(&block)
13
- yield @html
14
- end
15
-
16
- def render
17
- return @html.target!
18
- end
19
-
20
- end
21
- end
@@ -1,59 +0,0 @@
1
- module Interview
2
- class ImageAttribute < Attribute
3
-
4
- # - Modul UploadBuffer muss für write vorhanden sein
5
- # - json ansicht auf bild muss vorhanden sein
6
-
7
- attr_accessor :image_style, :hide_if_not_exists, :object
8
-
9
- def render_read
10
- image_style = @image_style || :thumb
11
-
12
- return '' if value.nil? and @hide_if_not_exists
13
-
14
- html = ::Builder::XmlMarkup.new
15
- opts = {class: "image_#{image_style}"}
16
- opts[:class] += ' ' + @html_class.join(' ') unless @html_class.empty? or @surrounding_tag
17
- html.div opts do
18
- if value
19
- html << h.image_tag(value.url(image_style), class: 'image img-responsive')
20
- else
21
- html << h.image_tag('missing_thumb.png', class: 'image img-responsive')
22
- end
23
- end
24
- return html.target!
25
- end
26
-
27
- def render_write
28
- image_style = @image_style || :thumb
29
-
30
- html = ::Builder::XmlMarkup.new
31
- html.div class: 'image_attribute_container' do
32
- unless value.nil? and @hide_if_not_exists
33
- html.div class: 'inline-block' do
34
- html << h.image_tag(value.url(image_style), class: 'image img-responsive')
35
- end
36
- end
37
-
38
- html.div class: 'inline-block' do
39
- html.div class: "clearfix" do
40
- html.span class: "btn btn-default fileinput-button" do
41
- html.span "Bild hochladen" # todo
42
- html << h.file_field_tag("upload_buffer[attachment]", class: 'upload_image',
43
- data: {url: "/upload_buffers.json", type: 'POST'})
44
- end
45
- end
46
- html << Interview::ProgressBar.new(hidden: true).render
47
- html << form_builder.hidden_field(:upload_buffer_id, class: 'upload_buffer_id')
48
-
49
- # if attachment.exists?
50
- # html << form_builder.check_box("destroy_#{@method}")
51
- # html.text! ' Datei löschen'
52
- # end
53
- end
54
- end
55
- return html.target!
56
- end
57
-
58
- end
59
- end
@@ -1,79 +0,0 @@
1
- module Interview
2
- class ImageGalleryAttribute < Attribute
3
-
4
- attr_accessor :object, :submethod, :image_style, :light_box_image_style
5
-
6
- def render_read
7
- submethod = @submethod || 'attachment'
8
- image_style = @image_style || :thumb
9
- images = value
10
-
11
- html = ::Builder::XmlMarkup.new
12
- render_gallery(html, images, submethod, image_style, @light_box_image_style)
13
- return html.target!
14
- end
15
-
16
- def render_write
17
- object = @object || find_attribute(:object)
18
- submethod = @submethod || 'attachment'
19
- image_style = @image_style || :thumb
20
- images = object.send @method
21
- model = images.klass.model_name.singular
22
-
23
- html = ::Builder::XmlMarkup.new
24
- html.div class: 'image-upload-group' do
25
-
26
- html << form_builder.hidden_field("#{@method.singularize}_ids", class: 'image-ids')
27
-
28
- # render_gallery(html, images, submethod, image_style, @light_box_image_style)
29
- #
30
- # light_box_image_url = @light_box_image_style ? "#{@light_box_image_style}_url" : 'url'
31
- # html.script id: 'image-thumb-script', type: 'text/x-tmpl' do
32
- # html.a href: "{%=o.#{light_box_image_url}%}", class: 'img-link' do
33
- # html.img class: 'img-thumb', src: "{%=o.thumb_url%}"
34
- # end
35
- # end
36
-
37
- html.div class: "clearfix" do
38
- html.span class: "btn btn-default fileinput-button" do
39
- html.span "Bilder hinzufügen" # todo
40
- html << h.file_field_tag("#{model}[#{submethod}]", class: 'multiple-image-upload', multiple: true,
41
- data: {url: "/#{model.pluralize}.json", type: 'POST'})
42
- end
43
- end
44
-
45
- html.div class: 'upload-progress' do
46
- end
47
-
48
- html.script id: 'upload-progress-script', type: 'text/x-tmpl' do
49
- html.div do
50
- html.div class: 'inline-block' do
51
- html.img class: 'img-thumb', src: '/assets/missing_180x180.png'
52
- end
53
- html.div class: 'inline-block' do
54
- html.text! "{%=o.name%}"
55
- html.div class: 'progress' do
56
- html.div '', class: 'progress-bar bar', style: 'width: 0%'
57
- end
58
- end
59
- end
60
- end
61
- end
62
-
63
- return html.target!
64
- end
65
-
66
- protected
67
-
68
- def render_gallery(html, images, submethod, image_style, light_box_image_style)
69
- html.div class: 'image-gallery' do
70
- images.each do |image|
71
- html.a href: image.send(submethod).url(light_box_image_style), class: 'img-link', title: image.subtitle do
72
- html << h.image_tag(image.send(submethod).url(image_style), class: 'img-thumb')
73
- end
74
- end
75
- end
76
- end
77
-
78
- end
79
- end
@@ -1,19 +0,0 @@
1
- module Interview
2
- class ImageLightBox < Control
3
-
4
- def render
5
- html = ::Builder::XmlMarkup.new
6
- html.div id: "blueimp-gallery", class: "blueimp-gallery" do
7
- html.div '', class: "slides"
8
- html.h3 '', class: "title"
9
- html.a '‹', class: "prev"
10
- html.a '›', class: "next"
11
- html.a '×', class: "close"
12
- html.a '', class: "play-pause"
13
- html.ol '', class: "indicator"
14
- end
15
- return html.target!
16
- end
17
-
18
- end
19
- end
@@ -1,134 +0,0 @@
1
- module Interview
2
- class Link < Control
3
- include HasControls
4
-
5
- attr_accessor :image, :caption, :hint, :style, :active,
6
- :url, :controller, :object, :action, :http_method, :redirect_to,
7
- :nested_resource, :trail
8
- attr_reader :url_params, :html_class, :html_data
9
-
10
- def initialize(params={})
11
- @html_class = []
12
- @html_data = {}
13
- @url_params = {}
14
- super
15
- end
16
-
17
- def scope=(scope)
18
- @url_params[:scope] = scope
19
- end
20
-
21
- def filter=(filter)
22
- @url_params[:filter] = filter
23
- end
24
-
25
- def render
26
- if @redirect_to
27
- if @redirect_to == :current
28
- @url_params[:redirect_to] = h.request.original_url
29
- elsif @redirect_to == :parent and Object.const_defined? 'Gretel'
30
- @url_params[:redirect_to] = h.parent_breadcrumb.url
31
- else
32
- @url_params[:redirect_to] = @redirect_to
33
- end
34
- end
35
-
36
- if @trail and Object.const_defined? 'Gretel'
37
- @url_params[:trail] = h.breadcrumb_trail
38
- end
39
-
40
- if @url
41
- url = @url
42
- url = "#{h.root_url}#{url}" if url[0..3] != 'http'
43
- elsif @controller
44
- url_options = @url_option.dup
45
- opts = {controller: @controller, action: @action}.merge @url_params
46
- url = h.url_for opts
47
- else
48
- url_params = @url_params.dup
49
- url_params[:action] = @action if @action and not %w(index show create update destroy).include? @action
50
- object = @object || find_attribute!(:object)
51
- url_params.each do |key, value|
52
- url_params[key] = value.call(self) if value.is_a? Proc
53
- end
54
- if @nested_resource and assoc_object
55
- url = h.polymorphic_path [assoc_object, object], url_params
56
- else
57
- url = h.polymorphic_path object, url_params
58
- end
59
- end
60
-
61
- html_options = {}
62
- html_class = @html_class.dup
63
- if @action == 'destroy'
64
- html_options[:method] = :delete
65
- html_options[:data] = { confirm: 'Are you sure?' }
66
- end
67
- if @http_method
68
- html_options[:method] = @http_method.to_sym
69
- end
70
-
71
- if @hint
72
- html_class << 'action_hint'
73
- html_options[:'data-toggle'] = 'tooltip'
74
- html_options[:title] = @hint
75
- end
76
-
77
- if @style and respond_to? "render_#{@style}_style", true
78
- return send "render_#{@style}_style", url, html_class, html_options
79
- else
80
- return render_link url, html_class, html_options
81
- end
82
- end
83
-
84
- def object # todo: Überdenken
85
- find_attribute(:object)
86
- end
87
-
88
- def assoc_object # todo: Überdenken
89
- find_attribute(:assoc_object)
90
- end
91
-
92
- protected
93
-
94
- def render_button_style(url, html_class=[], html_options={})
95
- html_class << 'btn btn-default'
96
- return render_link(url, html_class, html_options)
97
- end
98
-
99
- def render_primary_button_style(url, html_class=[], html_options={})
100
- html_class << 'btn btn-primary'
101
- return render_link(url, html_class, html_options)
102
- end
103
-
104
- def render_list_style(url, html_class=[], html_options={})
105
- html = ::Builder::XmlMarkup.new
106
- li_class = @active ? 'active' : ''
107
- html.li class: li_class do
108
- html << render_link(url, html_class, html_options)
109
- end
110
- return html.target!
111
- end
112
-
113
- def render_link(url, html_class=[], html_options={})
114
- controls = add_parent(build_children)
115
- class_string = html_class.join(' ')
116
- html_options[:class] = class_string unless html_class.empty?
117
- html_options[:data] = @html_data unless @html_data.empty?
118
- return h.link_to(url, html_options) do
119
- html = ::Builder::XmlMarkup.new
120
- if controls.empty?
121
- html.span '', class: "glyphicon glyphicon-#{@image}" if @image
122
- html.text! ' ' if @image and @caption
123
- html << @caption if @caption
124
- else
125
- controls.each do |control|
126
- html << control.render
127
- end
128
- end
129
- html.target!.html_safe
130
- end
131
- end
132
-
133
- end
134
- end
@@ -1,26 +0,0 @@
1
- module Interview
2
- class List < Control
3
- include HasControls
4
-
5
- attr_accessor :objects, :empty_message
6
- attr_reader :object
7
-
8
- def render
9
- objects = @objects || find_attribute!(:objects)
10
- html = ::Builder::XmlMarkup.new
11
- objects.each do |object|
12
- @object = object
13
- add_parent(build_children).each do |control| # todo: controls neu initialisieren?
14
- html << control.render
15
- end
16
- end
17
- if objects.empty? and @empty_message != :hide
18
- object = find_attribute!(:object)
19
- empty_message = @empty_message || "Keine #{object.class.human_name(count: 2)} vorhanden."
20
- html.p empty_message, class: 'text-center text-muted'
21
- end
22
- return html.target!
23
- end
24
-
25
- end
26
- end
@@ -1,27 +0,0 @@
1
- module Interview
2
- class MediaObject < Control
3
- include HasControls
4
-
5
- attr_reader :object
6
-
7
- def render
8
- image_size = @image_size || :thumb
9
- object = find_attribute :object
10
- controls = add_parent(build_children)
11
- @object = object
12
- html = ::Builder::XmlMarkup.new(indent: 2)
13
- html.div class: 'media' do
14
- controls[0].html_class << 'pull-left' if controls[0].respond_to? 'html_class'
15
- html << controls.first.render
16
- html.div class: 'media-body' do
17
- controls[1].html_class << 'media-heading' if controls[1].respond_to? 'html_class'
18
- controls[1..-1].each do |control|
19
- html << control.render
20
- end
21
- end
22
- end
23
- return html.target!
24
- end
25
-
26
- end
27
- end
@@ -1,55 +0,0 @@
1
- module Interview
2
- class Navigation < Control
3
- include HasControls
4
-
5
- attr_accessor :controller_name, :action_name, :current_scope, :current_filter
6
-
7
- def render
8
- auto_set_active
9
-
10
- html = ::Builder::XmlMarkup.new
11
- html.ul class: 'nav nav-pills nav-stacked' do
12
- add_parent(build_children).each do |control|
13
- html << control.render
14
- end
15
- end
16
- return html.target!
17
- end
18
-
19
- private
20
-
21
- def auto_set_active
22
- siblings.each { |sib| sib.active = false }
23
- if (nav_item = siblings.find { |sib| controller_match(sib) && action_match(sib) && scope_match(sib) && filter_match(sib) })
24
- nav_item.active = true
25
- elsif (nav_item = siblings.find { |sib| controller_match(sib) && scope_match(sib) && filter_match(sib) })
26
- nav_item.active = true
27
- elsif (nav_item = siblings.find { |sib| controller_match(sib) && (scope_match(sib) || filter_match(sib)) })
28
- nav_item.active = true
29
- elsif (nav_item = siblings.find { |sib| controller_match(sib) })
30
- nav_item.active = true
31
- end
32
- end
33
-
34
- def controller_match(nav_item)
35
- return @controller_name == nav_item.controller
36
- end
37
-
38
- def action_match(nav_item)
39
- return @action_name == nav_item.action
40
- end
41
-
42
- def scope_match(nav_item)
43
- return true if @current_scope.nil?
44
- return false if nav_item.url_options[:scope].nil?
45
- return true if nav_item.url_options[:scope] == @current_scope
46
- end
47
-
48
- def filter_match(nav_item)
49
- return true if @current_filter.nil?
50
- return false if nav_item.url_options[:filter].nil?
51
- return @current_filter.all? { |key, value| nav_item.url_options[:filter][key] == value }
52
- end
53
-
54
- end
55
- end
@@ -1,41 +0,0 @@
1
- module Interview
2
- class NavigationItem < Control
3
-
4
- include HasControls
5
-
6
- attr_accessor :active, :image, :caption, :badge_formula,
7
- :url, :controller, :object, :action, :http_method, :trail
8
-
9
- def render
10
- css_class = "level#{ancestors.count-1}"
11
- css_class += " active" if @active
12
- show_siblings = @active || siblings.any? { |sib| sib.active }
13
-
14
- link = Link.new(parent: self, url: @url, controller: @controller, object: @object,
15
- action: @action, http_method: @http_method, trail: @trail)
16
- badge = @badge_formula.call if @badge_formula
17
- unless badge.nil? or badge == 0 or badge == ''
18
- link.add_control(HtmlControl.new do |html|
19
- html.span badge, class: 'badge pull-right'
20
- end)
21
- end
22
- link.add_control(HtmlControl.new do |html|
23
- html.span '', class: "glyphicon glyphicon-#{@image}" if @image
24
- html.text! ' ' if @image and @caption
25
- html << @caption if @caption
26
- end)
27
-
28
- html = ::Builder::XmlMarkup.new
29
- html.li class: css_class do
30
- html << link.render
31
- end
32
- if show_siblings
33
- add_parent(build_children).each do |c|
34
- html << c.render
35
- end
36
- end
37
- return html.target!
38
- end
39
-
40
- end
41
- end