active_scaffold 3.0.12 → 3.0.21

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 (142) hide show
  1. data/README +21 -11
  2. data/frontends/default/images/close_touch.png +0 -0
  3. data/frontends/default/javascripts/jquery/active_scaffold.js +187 -99
  4. data/frontends/default/javascripts/prototype/active_scaffold.js +105 -33
  5. data/frontends/default/javascripts/prototype/dhtml_history.js +80 -77
  6. data/frontends/default/stylesheets/stylesheet.css +121 -2
  7. data/frontends/default/views/_action_group.html.erb +6 -2
  8. data/frontends/default/views/_base_form.html.erb +11 -5
  9. data/frontends/default/views/_base_form.html.erb~ +42 -0
  10. data/frontends/default/views/_field_search.html.erb +1 -1
  11. data/frontends/default/views/_form.html.erb +9 -7
  12. data/frontends/default/views/_form_association.html.erb +8 -3
  13. data/frontends/default/views/_form_association_footer.html.erb +10 -3
  14. data/frontends/default/views/_form_attribute.html.erb +8 -3
  15. data/frontends/default/views/_horizontal_subform.html.erb +12 -2
  16. data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
  17. data/frontends/default/views/_horizontal_subform_record.html.erb +5 -4
  18. data/frontends/default/views/_list_messages.html.erb +1 -1
  19. data/frontends/default/views/_list_with_header.html.erb +1 -1
  20. data/frontends/default/views/_render_field.js.rjs +4 -6
  21. data/frontends/default/views/_vertical_subform.html.erb +1 -1
  22. data/frontends/default/views/_vertical_subform_record.html.erb +2 -2
  23. data/frontends/default/views/on_action_update.js.rjs +3 -1
  24. data/frontends/default/views/on_mark_all.js.rjs +12 -0
  25. data/frontends/default/views/on_update.js.rjs +1 -1
  26. data/frontends/default/views/render_field.js.rjs +1 -0
  27. data/frontends/default/views/update_column.js.rjs +1 -1
  28. data/lib/active_scaffold.rb +60 -21
  29. data/lib/active_scaffold/actions/common_search.rb +2 -2
  30. data/lib/active_scaffold/actions/core.rb +30 -9
  31. data/lib/active_scaffold/actions/create.rb +14 -10
  32. data/lib/active_scaffold/actions/field_search.rb +6 -6
  33. data/lib/active_scaffold/actions/list.rb +22 -12
  34. data/lib/active_scaffold/actions/mark.rb +34 -9
  35. data/lib/active_scaffold/actions/nested.rb +12 -16
  36. data/lib/active_scaffold/actions/show.rb +2 -2
  37. data/lib/active_scaffold/actions/subform.rb +15 -8
  38. data/lib/active_scaffold/actions/update.rb +14 -4
  39. data/lib/active_scaffold/attribute_params.rb +15 -10
  40. data/lib/active_scaffold/bridges/bridge.rb +21 -12
  41. data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +3 -3
  42. data/lib/active_scaffold/bridges/cancan/bridge.rb +12 -0
  43. data/lib/active_scaffold/bridges/cancan/lib/cancan_bridge.rb +107 -0
  44. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +1 -1
  45. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +3 -8
  46. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +1 -15
  47. data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +23 -13
  48. data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +1 -1
  49. data/lib/active_scaffold/bridges/country_helper/bridge.rb +9 -0
  50. data/lib/active_scaffold/bridges/country_helper/lib/country_helper_bridge.rb +358 -0
  51. data/lib/active_scaffold/bridges/date_picker/bridge.rb +5 -3
  52. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +9 -0
  53. data/lib/active_scaffold/bridges/dragonfly/bridge.rb +9 -0
  54. data/lib/active_scaffold/bridges/dragonfly/bridge.rb~ +12 -0
  55. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +36 -0
  56. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb~ +36 -0
  57. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +12 -0
  58. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb~ +12 -0
  59. data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb +27 -0
  60. data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb~ +27 -0
  61. data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb +16 -0
  62. data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb~ +16 -0
  63. data/lib/active_scaffold/bridges/paperclip/bridge.rb +1 -1
  64. data/lib/active_scaffold/bridges/record_select/bridge.rb +5 -0
  65. data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb +87 -0
  66. data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb~ +84 -0
  67. data/lib/active_scaffold/bridges/shared/date_bridge.rb +56 -34
  68. data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +19 -3
  69. data/lib/active_scaffold/config/base.rb +4 -4
  70. data/lib/active_scaffold/config/core.rb +4 -0
  71. data/lib/active_scaffold/config/create.rb +1 -1
  72. data/lib/active_scaffold/config/field_search.rb +7 -7
  73. data/lib/active_scaffold/config/form.rb +8 -2
  74. data/lib/active_scaffold/config/list.rb +22 -8
  75. data/lib/active_scaffold/config/mark.rb +18 -5
  76. data/lib/active_scaffold/config/nested.rb +3 -3
  77. data/lib/active_scaffold/config/search.rb +1 -1
  78. data/lib/active_scaffold/config/show.rb +1 -1
  79. data/lib/active_scaffold/data_structures/action_columns.rb +10 -6
  80. data/lib/active_scaffold/data_structures/action_link.rb +14 -10
  81. data/lib/active_scaffold/data_structures/action_links.rb +2 -2
  82. data/lib/active_scaffold/data_structures/column.rb +25 -11
  83. data/lib/active_scaffold/data_structures/nested_info.rb +21 -21
  84. data/lib/active_scaffold/data_structures/set.rb +2 -3
  85. data/lib/active_scaffold/data_structures/sorting.rb +8 -8
  86. data/lib/{extensions → active_scaffold/extensions}/action_controller_rendering.rb +3 -1
  87. data/lib/{extensions → active_scaffold/extensions}/action_view_rendering.rb +31 -33
  88. data/lib/{extensions → active_scaffold/extensions}/action_view_resolver.rb +0 -0
  89. data/lib/{extensions → active_scaffold/extensions}/active_association_reflection.rb +0 -0
  90. data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
  91. data/lib/{extensions → active_scaffold/extensions}/array.rb +0 -0
  92. data/lib/{extensions → active_scaffold/extensions}/localize.rb +1 -1
  93. data/lib/{extensions → active_scaffold/extensions}/name_option_for_datetime.rb +1 -1
  94. data/lib/{extensions → active_scaffold/extensions}/nil_id_in_url_params.rb +0 -0
  95. data/lib/{extensions → active_scaffold/extensions}/paginator_extensions.rb +2 -2
  96. data/lib/{extensions → active_scaffold/extensions}/reverse_associations.rb +1 -1
  97. data/lib/{extensions → active_scaffold/extensions}/routing_mapper.rb +2 -2
  98. data/lib/{extensions → active_scaffold/extensions}/to_label.rb +0 -0
  99. data/lib/{extensions → active_scaffold/extensions}/unsaved_associated.rb +0 -0
  100. data/lib/{extensions → active_scaffold/extensions}/unsaved_record.rb +0 -0
  101. data/lib/active_scaffold/extensions/usa_state.rb +46 -0
  102. data/lib/active_scaffold/finder.rb +30 -19
  103. data/lib/active_scaffold/helpers/controller_helpers.rb +3 -5
  104. data/lib/active_scaffold/helpers/form_column_helpers.rb +19 -45
  105. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
  106. data/lib/active_scaffold/helpers/id_helpers.rb +2 -2
  107. data/lib/active_scaffold/helpers/list_column_helpers.rb +28 -17
  108. data/lib/active_scaffold/helpers/search_column_helpers.rb +51 -40
  109. data/lib/active_scaffold/helpers/search_column_helpers.rb~ +215 -0
  110. data/lib/active_scaffold/helpers/show_column_helpers.rb +8 -4
  111. data/lib/active_scaffold/helpers/view_helpers.rb +50 -27
  112. data/lib/active_scaffold/locale/de.yml +111 -0
  113. data/lib/active_scaffold/locale/en.yml +115 -0
  114. data/lib/active_scaffold/locale/es.yml +32 -32
  115. data/lib/active_scaffold/locale/fr.yml +118 -0
  116. data/lib/active_scaffold/marked_model.rb +6 -6
  117. data/lib/active_scaffold/version.rb +1 -1
  118. data/lib/active_scaffold_assets.rb +1 -3
  119. data/lib/active_scaffold_env.rb +1 -2
  120. data/lib/generators/active_scaffold/active_scaffold_generator.rb +5 -5
  121. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +3 -2
  122. data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
  123. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +17 -19
  124. data/shoulda_macros/macros.rb +4 -4
  125. data/test/misc/finder_test.rb +2 -2
  126. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +4 -1
  127. metadata +144 -126
  128. data/.autotest +0 -27
  129. data/.document +0 -5
  130. data/Gemfile +0 -13
  131. data/Gemfile.lock +0 -20
  132. data/Rakefile +0 -53
  133. data/active_scaffold.gemspec +0 -385
  134. data/init.rb +0 -2
  135. data/lib/active_scaffold/helpers/country_helpers.rb +0 -358
  136. data/lib/active_scaffold/locale/de.rb +0 -120
  137. data/lib/active_scaffold/locale/en.rb +0 -119
  138. data/lib/active_scaffold/locale/fr.rb +0 -116
  139. data/lib/extensions/active_record_offset.rb +0 -12
  140. data/lib/extensions/usa_state.rb +0 -50
  141. data/test/mock_app/.gitignore +0 -2
  142. data/uninstall.rb +0 -13
@@ -100,7 +100,7 @@ module ActiveScaffold::DataStructures
100
100
  end
101
101
  }
102
102
  end
103
-
103
+
104
104
  def collect_by_type(type = nil)
105
105
  links = []
106
106
  subgroup(type).each(type) {|link| links << link}
@@ -182,4 +182,4 @@ module ActiveScaffold::DataStructures
182
182
  from.instance_variable_get('@set').each { |link| @set << link.clone }
183
183
  end
184
184
  end
185
- end
185
+ end
@@ -19,7 +19,7 @@ module ActiveScaffold::DataStructures
19
19
 
20
20
  # Whether to enable add_existing for this column
21
21
  attr_accessor :allow_add_existing
22
-
22
+
23
23
  # Any extra parameters this particular column uses. This is for create/update purposes.
24
24
  def params
25
25
  # lazy initialize
@@ -52,9 +52,9 @@ module ActiveScaffold::DataStructures
52
52
  def required?
53
53
  @required
54
54
  end
55
-
55
+
56
56
  attr_reader :update_columns
57
-
57
+
58
58
  # update dependent columns after value change in form
59
59
  # update_columns = :name
60
60
  # update_columns = [:name, :age]
@@ -62,6 +62,10 @@ module ActiveScaffold::DataStructures
62
62
  @update_columns = Array(column_names)
63
63
  end
64
64
 
65
+ # send all the form instead of only new value when this column change
66
+ cattr_accessor :send_form_on_update_column
67
+ attr_accessor :send_form_on_update_column
68
+
65
69
  # sorting on a column can be configured four ways:
66
70
  # sort = true default, uses intelligent sorting sql default
67
71
  # sort = false sometimes sorting doesn't make sense
@@ -153,7 +157,10 @@ module ActiveScaffold::DataStructures
153
157
  # a collection of associations to pre-load when finding the records on a page
154
158
  attr_reader :includes
155
159
  def includes=(value)
156
- @includes = value.is_a?(Array) ? value : [value] # automatically convert to an array
160
+ @includes = case value
161
+ when Array, Hash then value
162
+ else [value] # automatically convert to an array
163
+ end
157
164
  end
158
165
 
159
166
  # a collection of columns to load when eager loading is disabled, if it's nil all columns will be loaded
@@ -202,7 +209,7 @@ module ActiveScaffold::DataStructures
202
209
  cattr_accessor :actions_for_association_links
203
210
  @@actions_for_association_links = [:new, :edit, :show]
204
211
  attr_accessor :actions_for_association_links
205
-
212
+
206
213
  cattr_accessor :association_form_ui
207
214
  @@association_form_ui = nil
208
215
 
@@ -241,6 +248,11 @@ module ActiveScaffold::DataStructures
241
248
  def virtual?
242
249
  column.nil? && association.nil?
243
250
  end
251
+
252
+ attr_writer :number
253
+ def number?
254
+ @number
255
+ end
244
256
 
245
257
  # this is so that array.delete and array.include?, etc., will work by column name
246
258
  def ==(other) #:nodoc:
@@ -268,18 +280,20 @@ module ActiveScaffold::DataStructures
268
280
  @associated_number = self.class.associated_number
269
281
  @show_blank_record = self.class.show_blank_record
270
282
  @actions_for_association_links = self.class.actions_for_association_links.clone if @association
271
- @options = {:format => :i18n_number} if @column.try(:number?)
283
+
284
+ self.number = @column.try(:number?)
285
+ @options = {:format => :i18n_number} if self.number?
272
286
  @form_ui = :checkbox if @column and @column.type == :boolean
273
287
  @form_ui = :textarea if @column and @column.type == :text
274
288
  @allow_add_existing = true
275
289
  @form_ui = self.class.association_form_ui if @association && self.class.association_form_ui
276
-
290
+
277
291
  # default all the configurable variables
278
292
  self.css_class = ''
279
293
  self.required = active_record_class.validators_on(self.name).map(&:class).include? ActiveModel::Validations::PresenceValidator
280
294
  self.sort = true
281
295
  self.search_sql = true
282
-
296
+
283
297
  @weight = estimate_weight
284
298
 
285
299
  self.includes = (association and not polymorphic_association?) ? [association.name] : []
@@ -312,7 +326,7 @@ module ActiveScaffold::DataStructures
312
326
  end
313
327
  end
314
328
  end
315
-
329
+
316
330
  def initialize_search_sql
317
331
  self.search_sql = unless self.virtual?
318
332
  if association.nil?
@@ -332,13 +346,13 @@ module ActiveScaffold::DataStructures
332
346
  def field
333
347
  @field ||= [@active_record_class.connection.quote_column_name(@table), field_name].join('.')
334
348
  end
335
-
349
+
336
350
  def estimate_weight
337
351
  if singular_association?
338
352
  400
339
353
  elsif plural_association?
340
354
  500
341
- elsif [:created_at, :updated_at].include?(self.name)
355
+ elsif [:created_at, :updated_at].include?(self.name)
342
356
  600
343
357
  elsif [:name, :label, :title].include?(self.name)
344
358
  100
@@ -1,7 +1,7 @@
1
1
  module ActiveScaffold::DataStructures
2
2
  class NestedInfo
3
3
  def self.get(model, session_storage)
4
- if session_storage[:nested].nil?
4
+ if session_storage[:nested].nil?
5
5
  nil
6
6
  else
7
7
  session_info = session_storage[:nested].clone
@@ -19,29 +19,29 @@ module ActiveScaffold::DataStructures
19
19
  end
20
20
  end
21
21
  end
22
-
22
+
23
23
  attr_accessor :association, :child_association, :parent_model, :parent_scaffold, :parent_id, :constrained_fields, :scope
24
-
24
+
25
25
  def initialize(model, session_info)
26
26
  @parent_model = session_info[:parent_model]
27
27
  @parent_id = session_info[:parent_id]
28
28
  @parent_scaffold = session_info[:parent_scaffold]
29
29
  end
30
-
30
+
31
31
  def new_instance?
32
32
  result = @new_instance.nil?
33
33
  @new_instance = false
34
34
  result
35
35
  end
36
-
36
+
37
37
  def parent_scope
38
38
  parent_model.find(parent_id)
39
39
  end
40
-
40
+
41
41
  def habtm?
42
- false
42
+ false
43
43
  end
44
-
44
+
45
45
  def belongs_to?
46
46
  false
47
47
  end
@@ -49,7 +49,7 @@ module ActiveScaffold::DataStructures
49
49
  def has_one?
50
50
  false
51
51
  end
52
-
52
+
53
53
  def readonly?
54
54
  false
55
55
  end
@@ -58,18 +58,18 @@ module ActiveScaffold::DataStructures
58
58
  false
59
59
  end
60
60
  end
61
-
61
+
62
62
  class NestedInfoAssociation < NestedInfo
63
63
  def initialize(model, session_info)
64
64
  super(model, session_info)
65
65
  @association = session_info[:association]
66
66
  iterate_model_associations(model)
67
67
  end
68
-
68
+
69
69
  def habtm?
70
- association.macro == :has_and_belongs_to_many
70
+ association.macro == :has_and_belongs_to_many
71
71
  end
72
-
72
+
73
73
  def belongs_to?
74
74
  association.belongs_to?
75
75
  end
@@ -77,7 +77,7 @@ module ActiveScaffold::DataStructures
77
77
  def has_one?
78
78
  association.macro == :has_one
79
79
  end
80
-
80
+
81
81
  def readonly?
82
82
  if association.options.has_key? :readonly
83
83
  association.options[:readonly]
@@ -93,31 +93,31 @@ module ActiveScaffold::DataStructures
93
93
  def default_sorting
94
94
  association.options[:order]
95
95
  end
96
-
96
+
97
97
  protected
98
-
98
+
99
99
  def iterate_model_associations(model)
100
- @constrained_fields = []
100
+ @constrained_fields = []
101
101
  @constrained_fields << association.primary_key_name.to_sym unless association.belongs_to?
102
102
  model.reflect_on_all_associations.each do |current|
103
103
  if !current.belongs_to? && association.primary_key_name == current.association_foreign_key
104
104
  constrained_fields << current.name.to_sym
105
- @child_association = current
105
+ @child_association = current if current.klass == @parent_model
106
106
  end
107
107
  if association.primary_key_name == current.primary_key_name
108
108
  # show columns for has_many and has_one child associationes
109
- constrained_fields << current.name.to_sym if current.belongs_to?
109
+ constrained_fields << current.name.to_sym if current.belongs_to?
110
110
  @child_association = current
111
111
  end
112
112
  end
113
113
  end
114
114
  end
115
-
115
+
116
116
  class NestedInfoScope < NestedInfo
117
117
  def initialize(model, session_info)
118
118
  super(model, session_info)
119
119
  @scope = session_info[:name]
120
- @constrained_fields = []
120
+ @constrained_fields = []
121
121
  end
122
122
  end
123
123
  end
@@ -53,11 +53,10 @@ module ActiveScaffold::DataStructures
53
53
  def length
54
54
  @set.length
55
55
  end
56
-
56
+
57
57
  def empty?
58
58
  @set.empty?
59
59
  end
60
60
 
61
61
  end
62
-
63
- end
62
+ end
@@ -7,7 +7,7 @@ module ActiveScaffold::DataStructures
7
7
  @columns = columns
8
8
  @clauses = []
9
9
  end
10
-
10
+
11
11
  def set_default_sorting(model)
12
12
  model_scope = model.send(:current_scoped_methods)
13
13
  order_clause = model_scope.arel.order_clauses.join(",") if model_scope
@@ -26,7 +26,7 @@ module ActiveScaffold::DataStructures
26
26
  clear
27
27
  set_sorting_from_order_clause(order_clause, table_name)
28
28
  end
29
-
29
+
30
30
  # add a clause to the sorting, assuming the column is sortable
31
31
  def add(column_name, direction = nil)
32
32
  direction ||= 'ASC'
@@ -121,21 +121,21 @@ module ActiveScaffold::DataStructures
121
121
  def mixed_sorting?
122
122
  sorts_by_method? and sorts_by_sql?
123
123
  end
124
-
124
+
125
125
  def default_sorting?
126
126
  @default_sorting
127
127
  end
128
128
 
129
129
  def set_sorting_from_order_clause(order_clause, model_table_name = nil)
130
130
  clear
131
- order_clause.split(',').each do |criterion|
131
+ order_clause.to_s.split(',').each do |criterion|
132
132
  unless criterion.blank?
133
133
  order_parts = extract_order_parts(criterion)
134
134
  add(order_parts[:column_name], order_parts[:direction]) unless different_table?(model_table_name, order_parts[:table_name])
135
135
  end
136
136
  end
137
137
  end
138
-
138
+
139
139
  def extract_order_parts(criterion_parts)
140
140
  column_name_part, direction_part = criterion_parts.strip.split(' ')
141
141
  column_name_parts = column_name_part.split('.')
@@ -144,11 +144,11 @@ module ActiveScaffold::DataStructures
144
144
  order[:table_name] = remove_quotes(column_name_parts[-2]) if column_name_parts.length >= 2
145
145
  order
146
146
  end
147
-
147
+
148
148
  def different_table?(model_table_name, order_table_name)
149
149
  !order_table_name.nil? && model_table_name != order_table_name
150
150
  end
151
-
151
+
152
152
  def remove_quotes(sql_name)
153
153
  if sql_name.starts_with?('"') || sql_name.starts_with?('`')
154
154
  sql_name[1, (sql_name.length - 2)]
@@ -156,7 +156,7 @@ module ActiveScaffold::DataStructures
156
156
  sql_name
157
157
  end
158
158
  end
159
-
159
+
160
160
  def extract_direction(direction_part)
161
161
  if direction_part.to_s.upcase == 'DESC'
162
162
  'DESC'
@@ -5,8 +5,9 @@ module ActionController #:nodoc:
5
5
  if self.class.uses_active_scaffold? and params[:adapter] and @rendering_adapter.nil?
6
6
  @rendering_adapter = true # recursion control
7
7
  # if we need an adapter, then we render the actual stuff to a string and insert it into the adapter template
8
+ opts = args.blank? ? Hash.new : args.first
8
9
  render :partial => params[:adapter][1..-1],
9
- :locals => {:payload => render_to_string(args.first.merge(:layout => false), &block)},
10
+ :locals => {:payload => render_to_string(opts.merge(:layout => false), &block)},
10
11
  :use_full_path => true, :layout => false
11
12
  @rendering_adapter = nil # recursion control
12
13
  else
@@ -18,3 +19,4 @@ module ActionController #:nodoc:
18
19
  # Rails 2.x implementation is post-initialization on :active_scaffold method
19
20
  end
20
21
  end
22
+
@@ -38,15 +38,19 @@ module ActionView::Rendering #:nodoc:
38
38
  #
39
39
  def render_with_active_scaffold(*args, &block)
40
40
  if args.first == :super
41
+ last_view = @view_stack.last
41
42
  options = args[1] || {}
42
43
  options[:locals] ||= {}
43
- options[:locals].reverse_merge!(@last_view[:locals] || {})
44
- if @last_view[:templates].nil?
45
- @last_view[:templates] = lookup_context.find_all_templates(@last_view[:view], controller_path, !@last_view[:is_template])
46
- @last_view[:templates].shift
44
+ options[:locals].reverse_merge!(last_view[:locals] || {})
45
+ if last_view[:templates].nil?
46
+ last_view[:templates] = lookup_context.find_all_templates(last_view[:view], controller_path, !last_view[:is_template])
47
+ last_view[:templates].shift
47
48
  end
48
- options[:template] = @last_view[:templates].shift
49
- render_without_active_scaffold options
49
+ options[:template] = last_view[:templates].shift
50
+ @view_stack << last_view
51
+ result = render_without_active_scaffold options
52
+ @view_stack.pop
53
+ result
50
54
  elsif args.first.is_a?(Hash) and args.first[:active_scaffold]
51
55
  require 'digest/md5'
52
56
  options = args.first
@@ -58,36 +62,44 @@ module ActionView::Rendering #:nodoc:
58
62
  session["as:#{eid}"] = {:constraints => constraints, :conditions => conditions, :list => {:label => args.first[:label]}}
59
63
  options[:params] ||= {}
60
64
  options[:params].merge! :eid => eid, :embedded => true
61
-
65
+
62
66
  id = "as_#{eid}-content"
63
67
  url_options = {:controller => remote_controller.to_s, :action => 'index'}.merge(options[:params])
64
-
65
- if respond_to? :render_component
66
- render_component url_options
68
+
69
+ if controller.respond_to?(:render_component_into_view)
70
+ controller.send(:render_component_into_view, url_options)
67
71
  else
68
- content_tag(:div, {:id => id}) do
72
+ content_tag(:div, :id => id, :class => 'active-scaffold-component') do
69
73
  url = url_for(url_options)
70
- link_to(remote_controller.to_s, url, {:remote => true, :id => id}) <<
71
- if ActiveScaffold.js_framework == :prototype
74
+ content_tag(:div, :class => 'active-scaffold-header') do
75
+ content_tag :h2, link_to(active_scaffold_config_for(remote_controller).list.label, url, :remote => true, :id => id)
76
+ end <<
77
+ if ActiveScaffold.js_framework == :prototype
72
78
  javascript_tag("new Ajax.Updater('#{id}', '#{url}', {method: 'get', evalScripts: true});")
73
79
  elsif ActiveScaffold.js_framework == :jquery
74
80
  javascript_tag("$('##{id}').load('#{url}');")
75
81
  end
76
82
  end
77
83
  end
78
-
84
+
79
85
  else
80
86
  options = args.first
81
87
  if options.is_a?(Hash)
82
- @last_view = {:view => options[:partial], :is_template => false} if options[:partial]
83
- @last_view = {:view => options[:template], :is_template => !!options[:template]} if @last_view.nil? && options[:template]
84
- @last_view[:locals] = options[:locals] if !@last_view.nil? && options[:locals]
88
+ current_view = {:view => options[:partial], :is_template => false} if options[:partial]
89
+ current_view = {:view => options[:template], :is_template => !!options[:template]} if current_view.nil? && options[:template]
90
+ current_view[:locals] = options[:locals] if !current_view.nil? && options[:locals]
91
+ if current_view.present?
92
+ @view_stack ||= []
93
+ @view_stack << current_view
94
+ end
85
95
  end
86
- render_without_active_scaffold(*args, &block)
96
+ result = render_without_active_scaffold(*args, &block)
97
+ @view_stack.pop if current_view.present?
98
+ result
87
99
  end
88
100
  end
89
101
  alias_method_chain :render, :active_scaffold
90
-
102
+
91
103
 
92
104
  def partial_pieces(partial_path)
93
105
  if partial_path.include?('/')
@@ -96,18 +108,4 @@ module ActionView::Rendering #:nodoc:
96
108
  return controller.class.controller_path, partial_path
97
109
  end
98
110
  end
99
-
100
- # This is the template finder logic, keep it updated with however we find stuff in rails
101
- # currently this very similar to the logic in ActionBase::Base.render for options file
102
- # TODO: Work with rails core team to find a better way to check for this.
103
- def template_exists?(template_name, lookup_overrides = false)
104
- begin
105
- method = 'find_template'
106
- method << '_without_active_scaffold' unless lookup_overrides
107
- self.view_paths.send(method, template_name, @template_format)
108
- return true
109
- rescue ActionView::MissingTemplate => e
110
- return false
111
- end
112
- end
113
111
  end