active_scaffold_vho 3.0.31 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/Gemfile +9 -1
  2. data/Gemfile.lock +8 -79
  3. data/Rakefile +17 -20
  4. data/active_scaffold_vho.gemspec +374 -15
  5. data/{frontends/default → app/assets}/images/add.gif +0 -0
  6. data/{frontends/default → app/assets}/images/arrow_down.gif +0 -0
  7. data/{frontends/default → app/assets}/images/arrow_up.gif +0 -0
  8. data/{frontends/default → app/assets}/images/close.gif +0 -0
  9. data/{frontends/default → app/assets}/images/close_touch.png +0 -0
  10. data/{frontends/default → app/assets}/images/config.png +0 -0
  11. data/{frontends/default → app/assets}/images/cross.png +0 -0
  12. data/{frontends/default → app/assets}/images/gears.png +0 -0
  13. data/{frontends/default → app/assets}/images/indicator-small.gif +0 -0
  14. data/{frontends/default → app/assets}/images/indicator.gif +0 -0
  15. data/{frontends/default → app/assets}/images/magnifier.png +0 -0
  16. data/app/assets/javascripts/active_scaffold.js.erb +12 -0
  17. data/{frontends/default → app/assets}/javascripts/jquery/active_scaffold.js +73 -245
  18. data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +24 -0
  19. data/app/assets/javascripts/jquery/jquery-ui-timepicker-addon.js +1060 -0
  20. data/{frontends/default → app/assets}/javascripts/jquery/jquery.editinplace.js +1 -1
  21. data/{lib/active_scaffold/bridges/tiny_mce/public → app/assets}/javascripts/jquery/tiny_mce_bridge.js +4 -3
  22. data/{frontends/default → app/assets}/javascripts/prototype/active_scaffold.js +36 -122
  23. data/{frontends/default → app/assets}/javascripts/prototype/dhtml_history.js +0 -0
  24. data/{frontends/default → app/assets}/javascripts/prototype/form_enhancements.js +0 -0
  25. data/{frontends/default → app/assets}/javascripts/prototype/rico_corner.js +0 -0
  26. data/{frontends/default/stylesheets/stylesheet-ie.css → app/assets/stylesheets/active_scaffold-ie.css} +0 -0
  27. data/{frontends/default/stylesheets/stylesheet.css → app/assets/stylesheets/active_scaffold.css.erb} +24 -22
  28. data/app/assets/stylesheets/jquery-ui-timepicker-addon.css +6 -0
  29. data/frontends/default/views/_action_group.html.erb +1 -1
  30. data/frontends/default/views/_base_form.html.erb +1 -1
  31. data/frontends/default/views/_form_association_footer.html.erb +11 -7
  32. data/frontends/default/views/_horizontal_subform_record.html.erb +5 -9
  33. data/frontends/default/views/_list.html.erb +1 -2
  34. data/frontends/default/views/_list_inline_adapter.html.erb +10 -0
  35. data/frontends/default/views/_list_messages.html.erb +2 -2
  36. data/frontends/default/views/_list_pagination.html.erb +6 -3
  37. data/frontends/default/views/_list_pagination_links.html.erb +9 -0
  38. data/frontends/default/views/_list_record.html.erb +2 -1
  39. data/frontends/default/views/_list_record_columns.html.erb +2 -1
  40. data/frontends/default/views/_list_with_header.html.erb +1 -1
  41. data/frontends/default/views/_messages.html.erb +0 -1
  42. data/frontends/default/views/_render_field.js.erb +13 -0
  43. data/frontends/default/views/_vertical_subform_record.html.erb +5 -9
  44. data/frontends/default/views/add_existing.js.erb +20 -0
  45. data/frontends/default/views/destroy.js.erb +24 -0
  46. data/frontends/default/views/{edit_associated.js.rjs → edit_associated.js.erb} +3 -2
  47. data/frontends/default/views/form_messages.js.erb +1 -0
  48. data/frontends/default/views/list.js.erb +1 -0
  49. data/frontends/default/views/on_action_update.js.erb +13 -0
  50. data/frontends/default/views/on_create.js.erb +45 -0
  51. data/frontends/default/views/on_mark_all.js.erb +12 -0
  52. data/frontends/default/views/on_update.js.erb +31 -0
  53. data/frontends/default/views/update_column.js.erb +16 -0
  54. data/frontends/default/views/update_row.js.erb +1 -0
  55. data/init.rb +1 -7
  56. data/lib/active_scaffold/actions/delete.rb +3 -5
  57. data/lib/active_scaffold/actions/field_search.rb +2 -6
  58. data/lib/active_scaffold/actions/list.rb +16 -14
  59. data/lib/active_scaffold/actions/search.rb +3 -3
  60. data/lib/active_scaffold/active_record_permissions.rb +2 -25
  61. data/lib/active_scaffold/attribute_params.rb +21 -44
  62. data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +1 -1
  63. data/lib/active_scaffold/bridges/date_picker/bridge.rb +2 -16
  64. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +86 -56
  65. data/lib/active_scaffold/bridges/file_column/bridge.rb +1 -1
  66. data/lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb +1 -1
  67. data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +1 -1
  68. data/lib/active_scaffold/bridges/paperclip/bridge.rb +1 -1
  69. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +2 -2
  70. data/lib/active_scaffold/bridges/shared/date_bridge.rb +3 -3
  71. data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +0 -12
  72. data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +1 -1
  73. data/lib/active_scaffold/config/base.rb +1 -1
  74. data/lib/active_scaffold/config/core.rb +1 -8
  75. data/lib/active_scaffold/config/delete.rb +1 -1
  76. data/lib/active_scaffold/config/field_search.rb +1 -22
  77. data/lib/active_scaffold/config/list.rb +10 -18
  78. data/lib/active_scaffold/data_structures/action_link.rb +9 -0
  79. data/lib/active_scaffold/data_structures/action_links.rb +1 -1
  80. data/lib/active_scaffold/data_structures/column.rb +4 -30
  81. data/lib/active_scaffold/data_structures/nested_info.rb +3 -3
  82. data/lib/active_scaffold/data_structures/sorting.rb +1 -1
  83. data/lib/active_scaffold/engine.rb +8 -0
  84. data/lib/active_scaffold/extensions/action_controller_rendering.rb +22 -0
  85. data/lib/active_scaffold/extensions/action_view_rendering.rb +79 -59
  86. data/lib/active_scaffold/extensions/action_view_resolver.rb +4 -2
  87. data/lib/active_scaffold/extensions/active_association_reflection.rb +3 -3
  88. data/lib/active_scaffold/extensions/reverse_associations.rb +3 -3
  89. data/lib/active_scaffold/finder.rb +27 -39
  90. data/lib/active_scaffold/helpers/association_helpers.rb +3 -3
  91. data/lib/active_scaffold/helpers/form_column_helpers.rb +3 -3
  92. data/lib/active_scaffold/helpers/human_condition_helpers.rb +2 -4
  93. data/lib/active_scaffold/helpers/list_column_helpers.rb +16 -22
  94. data/lib/active_scaffold/helpers/search_column_helpers.rb +1 -1
  95. data/lib/active_scaffold/helpers/view_helpers.rb +35 -13
  96. data/lib/active_scaffold/locale/de.rb +120 -0
  97. data/lib/active_scaffold/locale/en.rb +119 -0
  98. data/lib/active_scaffold/version.rb +2 -2
  99. data/lib/active_scaffold.rb +12 -27
  100. data/lib/active_scaffold_env.rb +3 -3
  101. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +1 -1
  102. metadata +84 -86
  103. data/.gitignore +0 -42
  104. data/frontends/default/views/_render_field.js.rjs +0 -10
  105. data/frontends/default/views/add_existing.js.rjs +0 -17
  106. data/frontends/default/views/destroy.js.rjs +0 -23
  107. data/frontends/default/views/form_messages.js.rjs +0 -1
  108. data/frontends/default/views/list.js.rjs +0 -1
  109. data/frontends/default/views/on_action_update.js.rjs +0 -10
  110. data/frontends/default/views/on_create.js.rjs +0 -41
  111. data/frontends/default/views/on_mark_all.js.rjs +0 -12
  112. data/frontends/default/views/on_update.js.rjs +0 -28
  113. data/frontends/default/views/update_column.js.rjs +0 -13
  114. data/frontends/default/views/update_row.js.rjs +0 -1
  115. data/lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js +0 -36
  116. data/lib/active_scaffold/bridges/tiny_mce/public/javascripts/prototype/tiny_mce_bridge.js +0 -21
  117. data/lib/active_scaffold/locale/de.yml +0 -120
  118. data/lib/active_scaffold/locale/en.yml +0 -115
  119. data/lib/active_scaffold_assets.rb +0 -45
@@ -1,22 +1,8 @@
1
-
2
-
3
1
  ActiveScaffold::Bridges.bridge "DatePicker" do
4
2
  install do
5
- directory = File.dirname(__FILE__)
6
- source = File.join(directory, "public/javascripts/date_picker_bridge.js")
7
- destination = File.join(Rails.root, "public/javascripts/active_scaffold/default/")
8
-
9
- if ActiveScaffold.js_framework == :jquery
10
- require File.join(directory, "lib/datepicker_bridge.rb")
11
- unless defined?(ACTIVE_SCAFFOLD_INSTALL_ASSETS) && ACTIVE_SCAFFOLD_INSTALL_ASSETS == false
12
- FileUtils.cp(source, destination)
13
- ActiveScaffold::Bridges::DatePickerBridge.localization(File.join(destination, 'date_picker_bridge.js'))
14
- end
15
- else
16
- # make sure that jquery files are removed
17
- FileUtils.rm(File.join(destination, 'date_picker_bridge.js')) if File.exist?(File.join(destination, 'date_picker_bridge.js'))
18
- end
3
+ require File.join(File.dirname(__FILE__), "lib/datepicker_bridge.rb") if ActiveScaffold.js_framework == :jquery
19
4
  end
5
+
20
6
 
21
7
  install? do
22
8
  true
@@ -34,90 +34,121 @@ module ActiveScaffold
34
34
  '%a' => 'D',
35
35
  '%A' => 'DD',
36
36
  '%b' => 'M',
37
- '%B' => 'MM',
37
+ '$B' => 'MM',
38
38
  '%d' => 'dd',
39
39
  '%e' => 'd',
40
40
  '%j' => 'oo',
41
41
  '%m' => 'mm',
42
42
  '%y' => 'y',
43
43
  '%Y' => 'yy',
44
- '%H' => 'HH', # options ampm => false
44
+ '%H' => 'hh', # options ampm => false
45
45
  '%I' => 'hh', # options ampm => true
46
46
  '%M' => 'mm',
47
47
  '%p' => 'tt',
48
48
  '%S' => 'ss'
49
49
  }
50
50
 
51
- def self.localization(js_file)
52
- localization = "jQuery(function($){
51
+ def self.localization
52
+ "jQuery(function($){
53
53
  if (typeof($.datepicker) === 'object') {
54
- $.datepicker.regional['#{I18n.locale}'] = #{date_options.to_json};
54
+ #{date_options_for_locales}
55
55
  $.datepicker.setDefaults($.datepicker.regional['#{I18n.locale}']);
56
56
  }
57
57
  if (typeof($.timepicker) === 'object') {
58
- $.timepicker.regional['#{I18n.locale}'] = #{datetime_options.to_json};
58
+ #{datetime_options_for_locales}
59
59
  $.timepicker.setDefaults($.timepicker.regional['#{I18n.locale}']);
60
60
  }
61
61
  });\n"
62
- prepend_js_file(js_file, localization)
63
62
  end
64
-
65
- def self.date_options
66
- date_options = I18n.translate! 'date'
67
- date_picker_options = { :closeText => as_(:close),
68
- :prevText => as_(:previous),
69
- :nextText => as_(:next),
70
- :currentText => as_(:today),
71
- :monthNames => date_options[:month_names][1, (date_options[:month_names].length - 1)],
72
- :monthNamesShort => date_options[:abbr_month_names][1, (date_options[:abbr_month_names].length - 1)],
73
- :dayNames => date_options[:day_names],
74
- :dayNamesShort => date_options[:abbr_day_names],
75
- :dayNamesMin => date_options[:abbr_day_names],
76
- :changeYear => true,
77
- :changeMonth => true,
78
- }
79
63
 
64
+ def self.date_options_for_locales
65
+ I18n.available_locales.collect do |locale|
66
+ locale_date_options = date_options(locale)
67
+ if locale_date_options
68
+ "$.datepicker.regional['#{locale}'] = #{locale_date_options.to_json};"
69
+ else
70
+ nil
71
+ end
72
+ end.compact.join('')
73
+ end
74
+
75
+ def self.date_options(locale)
80
76
  begin
81
- as_date_picker_options = I18n.translate! 'active_scaffold.date_picker_options'
82
- date_picker_options.merge!(as_date_picker_options) if as_date_picker_options.is_a? Hash
77
+ date_options = I18n.translate! 'date', :locale => locale
78
+ date_picker_options = { :closeText => as_(:close),
79
+ :prevText => as_(:previous),
80
+ :nextText => as_(:next),
81
+ :currentText => as_(:today),
82
+ :monthNames => date_options[:month_names][1, (date_options[:month_names].length - 1)],
83
+ :monthNamesShort => date_options[:abbr_month_names][1, (date_options[:abbr_month_names].length - 1)],
84
+ :dayNames => date_options[:day_names],
85
+ :dayNamesShort => date_options[:abbr_day_names],
86
+ :dayNamesMin => date_options[:abbr_day_names],
87
+ :changeYear => true,
88
+ :changeMonth => true,
89
+ }
90
+
91
+ begin
92
+ as_date_picker_options = I18n.translate! 'active_scaffold.date_picker_options'
93
+ date_picker_options.merge!(as_date_picker_options) if as_date_picker_options.is_a? Hash
94
+ rescue
95
+ Rails.logger.warn "ActiveScaffold: Missing date picker localization for your locale: #{locale}"
96
+ end
97
+
98
+ js_format = self.to_datepicker_format(date_options[:formats][:default])
99
+ date_picker_options[:dateFormat] = js_format unless js_format.nil?
100
+ date_picker_options
83
101
  rescue
84
- Rails.logger.warn "ActiveScaffold: Missing date picker localization for your locale: #{I18n.locale}"
102
+ if locale == I18n.locale
103
+ raise
104
+ else
105
+ nil
106
+ end
85
107
  end
108
+ end
86
109
 
87
- js_format = self.to_datepicker_format(date_options[:formats][:default])
88
- date_picker_options[:dateFormat] = js_format unless js_format.nil?
89
- date_picker_options
110
+ def self.datetime_options_for_locales
111
+ I18n.available_locales.collect do |locale|
112
+ locale_datetime_options = datetime_options(locale)
113
+ if locale_datetime_options
114
+ "$.timepicker.regional['#{locale}'] = #{locale_datetime_options.to_json};"
115
+ else
116
+ nil
117
+ end
118
+ end.compact.join('')
90
119
  end
91
120
 
92
- def self.datetime_options
93
- rails_time_format = I18n.translate! 'time.formats.default'
94
- datetime_options = I18n.translate! 'datetime.prompts'
95
- datetime_picker_options = {:ampm => false,
96
- :hourText => datetime_options[:hour],
97
- :minuteText => datetime_options[:minute],
98
- :secondText => datetime_options[:second],
99
- }
100
-
121
+ def self.datetime_options(locale)
101
122
  begin
102
- as_datetime_picker_options = I18n.translate! 'active_scaffold.datetime_picker_options'
103
- datetime_picker_options.merge!(as_datetime_picker_options) if as_datetime_picker_options.is_a? Hash
123
+ rails_time_format = I18n.translate! 'time.formats.default', :locale => locale
124
+ datetime_options = I18n.translate! 'datetime.prompts', :locale => locale
125
+ datetime_picker_options = {:ampm => false,
126
+ :hourText => datetime_options[:hour],
127
+ :minuteText => datetime_options[:minute],
128
+ :secondText => datetime_options[:second],
129
+ }
130
+
131
+ begin
132
+ as_datetime_picker_options = I18n.translate! 'active_scaffold.datetime_picker_options'
133
+ datetime_picker_options.merge!(as_datetime_picker_options) if as_datetime_picker_options.is_a? Hash
134
+ rescue
135
+ Rails.logger.warn "ActiveScaffold: Missing datetime picker localization for your locale: #{locale}"
136
+ end
137
+
138
+ date_format, time_format = self.split_datetime_format(self.to_datepicker_format(rails_time_format))
139
+ datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
140
+ unless time_format.nil?
141
+ datetime_picker_options[:timeFormat] = time_format
142
+ datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
143
+ end
144
+ datetime_picker_options
104
145
  rescue
105
- Rails.logger.warn "ActiveScaffold: Missing datetime picker localization for your locale: #{I18n.locale}"
106
- end
107
-
108
- date_format, time_format = self.split_datetime_format(self.to_datepicker_format(rails_time_format))
109
- datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
110
- unless time_format.nil?
111
- datetime_picker_options[:timeFormat] = time_format
112
- datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
146
+ if locale == I18n.locale
147
+ raise
148
+ else
149
+ nil
150
+ end
113
151
  end
114
- datetime_picker_options
115
- end
116
-
117
- def self.prepend_js_file(js_file, prepend)
118
- content = File.binread(js_file)
119
- content.gsub!(/\A/, prepend)
120
- File.open(js_file, 'wb') { |file| file.write(content) }
121
152
  end
122
153
 
123
154
  def self.to_datepicker_format(rails_format)
@@ -137,13 +168,12 @@ module ActiveScaffold
137
168
  def self.split_datetime_format(datetime_format)
138
169
  date_format = datetime_format
139
170
  time_format = nil
140
- time_start_indicators = %w{HH hh mm tt ss}
171
+ time_start_indicators = %w{hh mm tt ss}
141
172
  unless datetime_format.nil?
142
173
  start_indicator = time_start_indicators.detect {|indicator| datetime_format.include?(indicator)}
143
174
  unless start_indicator.nil?
144
175
  pos_time_format = datetime_format.index(start_indicator)
145
176
  date_format = datetime_format.to(pos_time_format - 1)
146
- date_format.strip!
147
177
  time_format = datetime_format.from(pos_time_format)
148
178
  end
149
179
  end
@@ -1,6 +1,6 @@
1
1
  ActiveScaffold::Bridges.bridge "FileColumn" do
2
2
  install do
3
- if ActiveScaffold::Config::Core.instance_method_names.include?("initialize_with_file_column")
3
+ if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_file_column")
4
4
  raise RuntimeError, "We've detected that you have active_scaffold_file_column_bridge installed. This plugin has been moved to core. Please remove active_scaffold_file_column_bridge to prevent any conflicts"
5
5
  end
6
6
  require File.join(File.dirname(__FILE__), "lib/as_file_column_bridge")
@@ -24,7 +24,7 @@ module ActiveScaffold::Config
24
24
  }
25
25
  end
26
26
 
27
- alias_method_chain :initialize, :file_column unless self.instance_method_names.include?("initialize_without_file_column")
27
+ alias_method_chain :initialize, :file_column unless self.instance_methods.include?("initialize_without_file_column")
28
28
 
29
29
  def configure_file_column_field(field)
30
30
  # set list_ui first because it gets its default value from form_ui
@@ -5,7 +5,7 @@ module ActiveScaffold
5
5
  module FileColumnHelpers
6
6
  class << self
7
7
  def file_column_fields(klass)
8
- klass.instance_method_names.grep(/_just_uploaded\?$/).collect{|m| m[0..-16].to_sym }
8
+ klass.instance_methods.grep(/_just_uploaded\?$/).collect{|m| m[0..-16].to_sym }
9
9
  end
10
10
 
11
11
  def generate_delete_helpers(klass)
@@ -1,6 +1,6 @@
1
1
  ActiveScaffold::Bridges.bridge "Paperclip" do
2
2
  install do
3
- if ActiveScaffold::Config::Core.instance_method_names.include?("initialize_with_paperclip")
3
+ if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_paperclip")
4
4
  raise RuntimeError, "We've detected that you have active_scaffold_paperclip_bridge installed. This plugin has been moved to core. Please remove active_scaffold_paperclip_bridge to prevent any conflicts"
5
5
  end
6
6
  require File.join(File.dirname(__FILE__), "lib/form_ui")
@@ -7,7 +7,7 @@ module ActiveScaffold
7
7
  self.thumbnail_style = :thumbnail
8
8
 
9
9
  def self.generate_delete_helper(klass, field)
10
- klass.class_eval <<-EOF, __FILE__, __LINE__ + 1 unless klass.methods.include?("delete_#{field}=")
10
+ klass.class_eval <<-EOF, __FILE__, __LINE__ + 1 unless klass.instance_methods.include?("delete_#{field}=")
11
11
  attr_reader :delete_#{field}
12
12
 
13
13
  def delete_#{field}=(value)
@@ -23,4 +23,4 @@ module ActiveScaffold
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -73,13 +73,13 @@ module ActiveScaffold
73
73
  range_type, range = value[:range].downcase.split('_')
74
74
  format = active_scaffold_human_condition_date_bridge_range_format(range_type, range)
75
75
  from, to = controller.class.date_bridge_from_to(column, value)
76
- "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value[:range].downcase).downcase} (#{I18n.l(from, :format => format)})" unless from.nil?
76
+ "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value[:range].downcase).downcase} (#{I18n.l(from, :format => format)})"
77
77
  when 'PAST', 'FUTURE'
78
78
  from, to = controller.class.date_bridge_from_to(column, value)
79
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}" unless from.nil? || to.nil?
79
+ "#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}"
80
80
  else
81
81
  from, to = controller.class.date_bridge_from_to(column, value)
82
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{I18n.l(from)} #{value[:opt] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}" unless from.nil? || (value[:opt] == 'BETWEEN' && to.nil?)
82
+ "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{I18n.l(from)} #{value[:opt] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
83
83
  end
84
84
  end
85
85
 
@@ -1,18 +1,6 @@
1
1
  ActiveScaffold::Bridges.bridge "TinyMCE" do
2
2
  install do
3
3
  require File.join(File.dirname(__FILE__), "lib/tiny_mce_bridge.rb")
4
- directory = File.dirname(__FILE__)
5
- destination = File.join(Rails.root, "public/javascripts/active_scaffold/default/")
6
-
7
- if ActiveScaffold.js_framework == :jquery
8
- source = File.join(directory, "public/javascripts/jquery/tiny_mce_bridge.js")
9
- FileUtils.rm(File.join(destination, 'tiny_mce_bridge.js')) if File.exist?(File.join(destination, 'tiny_mce_bridge.js'))
10
- FileUtils.cp(source, destination)
11
- else
12
- source = File.join(directory, "public/javascripts/prototype/tiny_mce_bridge.js")
13
- FileUtils.rm(File.join(destination, 'tiny_mce_bridge.js')) if File.exist?(File.join(destination, 'tiny_mce_bridge.js'))
14
- FileUtils.cp(source, destination)
15
- end unless defined?(ACTIVE_SCAFFOLD_INSTALL_ASSETS) && ACTIVE_SCAFFOLD_INSTALL_ASSETS == false
16
4
  end
17
5
 
18
6
  install? do
@@ -7,7 +7,7 @@ module ActiveScaffold
7
7
  def initialize_with_validation_reflection(name, active_record_class)
8
8
  initialize_without_validation_reflection(name, active_record_class)
9
9
  column_names = [name]
10
- column_names << @association.primary_key_name if @association
10
+ column_names << @association.foreign_key if @association
11
11
  self.required = column_names.any? do |column_name|
12
12
  active_record_class.reflect_on_validations_for(column_name.to_sym).any? do |val|
13
13
  val.macro == :validates_presence_of or (val.macro == :validates_inclusion_of and not val.options[:allow_nil] and not val.options[:allow_blank])
@@ -26,7 +26,7 @@ module ActiveScaffold::Config
26
26
 
27
27
  # define a default action_group for this action
28
28
  # e.g. 'members.crud'
29
- class_inheritable_accessor :action_group
29
+ class_attribute :action_group
30
30
 
31
31
  # action_group this action should belong to
32
32
  attr_accessor :action_group
@@ -167,14 +167,7 @@ module ActiveScaffold::Config
167
167
  klass = "ActiveScaffold::Config::#{titled_name}".constantize rescue nil
168
168
  if klass
169
169
  if @actions.include? underscored_name
170
- @action_configs[name] ||= klass.new(self)
171
- eigenclass = class << self; self; end
172
- eigenclass.class_eval do
173
- define_method(name) do
174
- @action_configs[name]
175
- end
176
- end
177
- return send(name)
170
+ return @action_configs[underscored_name] ||= klass.new(self)
178
171
  else
179
172
  raise "#{titled_name} is not enabled. Please enable it or remove any references in your configuration (e.g. config.#{underscored_name}.columns = [...])."
180
173
  end
@@ -16,7 +16,7 @@ module ActiveScaffold::Config
16
16
 
17
17
  # the ActionLink for this action
18
18
  cattr_accessor :link
19
- @@link = ActiveScaffold::DataStructures::ActionLink.new('destroy', :label => :delete, :type => :member, :confirm => :are_you_sure_to_delete, :method => :delete, :crud_type => :delete, :position => false, :parameters => {:destroy_action => true}, :security_method => :delete_authorized?, :ignore_method => :delete_ignore?)
19
+ @@link = ActiveScaffold::DataStructures::ActionLink.new('destroy', :label => :delete, :type => :member, :confirm => :are_you_sure_to_delete, :method => :delete, :crud_type => :delete, :position => false, :parameters => {:destroy_action => true}, :security_method => :delete_authorized?)
20
20
 
21
21
  # whether we should refresh list after destroy or not
22
22
  cattr_accessor :refresh_list
@@ -6,7 +6,6 @@ module ActiveScaffold::Config
6
6
  @core = core_config
7
7
 
8
8
  @text_search = self.class.text_search
9
- @or_delimiter = self.class.or_delimiter
10
9
 
11
10
  # start with the ActionLink defined globally
12
11
  @link = self.class.link.clone
@@ -29,11 +28,6 @@ module ActiveScaffold::Config
29
28
  cattr_accessor :text_search
30
29
  @@text_search = :full
31
30
 
32
- # delimiter to seperate or search string such us: name = Paul,Bernd,Klaus
33
- # will search for Paul Or Bernd Or Klaus
34
- cattr_accessor :or_delimiter
35
- @@or_delimiter = ','
36
-
37
31
  # instance-level configuration
38
32
  # ----------------------------
39
33
 
@@ -56,33 +50,18 @@ module ActiveScaffold::Config
56
50
  # * false: LIKE ?
57
51
  # Default is :full
58
52
  attr_accessor :text_search
59
-
60
- attr_accessor :or_delimiter
61
53
 
62
54
  # the ActionLink for this action
63
55
  attr_accessor :link
64
56
 
65
57
  # rarely searched columns may be placed in a hidden subgroup
66
- def optional_columns=(optionals)
58
+ def optional_columns=(optionals)
67
59
  @optional_columns= Array(optionals)
68
60
  end
69
61
 
70
62
  def optional_columns
71
63
  @optional_columns ||= []
72
64
  end
73
-
74
- # columns which should support or searches
75
- # eg like 'x' or ... like 'y'
76
- def or_columns=(or_columns)
77
- @or_columns = Array(or_columns)
78
- end
79
-
80
- def or_columns
81
- unless @or_columns
82
- self.or_columns = @core.columns.collect{|c| c.name if @core.columns._inheritable.include?(c.name) and c.searchable? and c.column and c.column.text?}.compact
83
- end
84
- @or_columns
85
- end
86
65
 
87
66
  # default search params
88
67
  # default_params = {:title => {"from"=>"test", "to"=>"", "opt"=>"%?%"}}
@@ -128,11 +128,6 @@ module ActiveScaffold::Config
128
128
  attr_accessor :nested_auto_open
129
129
 
130
130
  class UserSettings < UserSettings
131
- def initialize(conf, storage, params)
132
- super(conf,storage,params)
133
- @sorting = nil
134
- end
135
-
136
131
  # This label has alread been localized.
137
132
  def label
138
133
  @session[:label] ? @session[:label] : @conf.label
@@ -164,20 +159,17 @@ module ActiveScaffold::Config
164
159
  end
165
160
 
166
161
  def sorting
167
- if @sorting.nil?
168
- # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
169
- @session['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
170
- @session['sort'] = nil if @params['sort_direction'] == 'reset'
171
-
172
- if @session['sort']
173
- sorting = @conf.sorting.clone
174
- sorting.set(*@session['sort'])
175
- @sorting = sorting
176
- else
177
- @sorting = default_sorting
178
- end
162
+ # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
163
+ @session['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
164
+ @session['sort'] = nil if @params['sort_direction'] == 'reset'
165
+
166
+ if @session['sort']
167
+ sorting = @conf.sorting.clone
168
+ sorting.set(*@session['sort'])
169
+ return sorting
170
+ else
171
+ return default_sorting
179
172
  end
180
- @sorting
181
173
  end
182
174
 
183
175
  def count_includes
@@ -67,6 +67,15 @@ module ActiveScaffold::DataStructures
67
67
  def confirm?
68
68
  @confirm ? true : false
69
69
  end
70
+
71
+ # if the action uses a DHTML based (i.e. 2-phase) confirmation
72
+ attr_writer :dhtml_confirm
73
+ def dhtml_confirm
74
+ @dhtml_confirm
75
+ end
76
+ def dhtml_confirm?
77
+ @dhtml_confirm
78
+ end
70
79
 
71
80
  # what method to call on the controller to see if this action_link should be visible
72
81
  # note that this is only the UI part of the security. to prevent URL hax0rz, you also need security on requests (e.g. don't execute update method unless authorized).
@@ -173,7 +173,7 @@ module ActiveScaffold::DataStructures
173
173
  protected
174
174
 
175
175
  def skip_action_link(controller, link, *args)
176
- (!link.ignore_method.nil? && controller.respond_to?(link.ignore_method) && controller.send(link.ignore_method, *args)) || ((link.security_method_set? or controller.respond_to? link.security_method) and !controller.send(link.security_method, *args))
176
+ (!link.ignore_method.nil? and controller.try(link.ignore_method, *args)) || ((link.security_method_set? or controller.respond_to? link.security_method) and !controller.send(link.security_method, *args))
177
177
  end
178
178
 
179
179
  # called during clone or dup. makes the clone/dup deeper.
@@ -181,26 +181,6 @@ module ActiveScaffold::DataStructures
181
181
  # to modify the default order of columns
182
182
  attr_accessor :weight
183
183
 
184
- # whether the field should be stripped when search values or form values are read for this value
185
- attr_writer :stripable
186
- def stripable?
187
- @stripable
188
- end
189
-
190
- def stripped_value(value)
191
- if stripable?
192
- begin
193
- value.strip
194
- rescue
195
- Rails.logger.error("stripped_value: column #{self.name} is a db text column, but value is nt a string: #{value.inspect}. Please define column[:#{self.name}].stripable = false in config")
196
- value
197
- end
198
- else
199
- value
200
- end
201
- end
202
-
203
-
204
184
  # to set how many associated records a column with plural association must show in list
205
185
  cattr_accessor :associated_limit
206
186
  @@associated_limit = 3
@@ -248,11 +228,6 @@ module ActiveScaffold::DataStructures
248
228
  def plural_association?
249
229
  self.association and [:has_many, :has_and_belongs_to_many].include? self.association.macro
250
230
  end
251
-
252
- def belongs_to_association?
253
- self.association && self.association.macro == :belongs_to
254
- end
255
-
256
231
  def through_association?
257
232
  self.association and self.association.options[:through]
258
233
  end
@@ -303,7 +278,6 @@ module ActiveScaffold::DataStructures
303
278
  @options = {:format => :i18n_number} if @column.try(:number?)
304
279
  @form_ui = :checkbox if @column and @column.type == :boolean
305
280
  @form_ui = :textarea if @column and @column.type == :text
306
- @stripable = true if @column and @column.text?
307
281
  @allow_add_existing = true
308
282
  @form_ui = self.class.association_form_ui if @association && self.class.association_form_ui
309
283
 
@@ -321,7 +295,7 @@ module ActiveScaffold::DataStructures
321
295
  # just the field (not table.field)
322
296
  def field_name
323
297
  return nil if virtual?
324
- column ? @active_record_class.connection.quote_column_name(column.name) : association.primary_key_name
298
+ column ? @active_record_class.connection.quote_column_name(column.name) : association.foreign_key
325
299
  end
326
300
 
327
301
  def <=>(other_column)
@@ -337,7 +311,7 @@ module ActiveScaffold::DataStructures
337
311
  self.sort = false
338
312
  else
339
313
  if self.singular_association?
340
- self.sort = {:method => "#{self.name}.nil? ? '' : #{self.name}.to_label"}
314
+ self.sort = {:method => "#{self.name}.to_s"}
341
315
  elsif self.plural_association?
342
316
  self.sort = {:method => "#{self.name}.join(',')"}
343
317
  else
@@ -348,7 +322,7 @@ module ActiveScaffold::DataStructures
348
322
 
349
323
  def initialize_search_sql
350
324
  self.search_sql = unless self.virtual?
351
- if association.nil? || self.belongs_to_association?
325
+ if association.nil?
352
326
  self.field.to_s
353
327
  elsif !self.polymorphic_association?
354
328
  [association.klass.table_name, association.klass.primary_key].collect! do |str|
@@ -363,7 +337,7 @@ module ActiveScaffold::DataStructures
363
337
 
364
338
  # the table.field name for this column, if applicable
365
339
  def field
366
- @field ||= [@active_record_class.connection.quote_column_name(@table), field_name].join('.')
340
+ @field ||= [@active_record_class.connection.quote_table_name(@table), field_name].join('.')
367
341
  end
368
342
 
369
343
  def estimate_weight
@@ -98,13 +98,13 @@ module ActiveScaffold::DataStructures
98
98
 
99
99
  def iterate_model_associations(model)
100
100
  @constrained_fields = []
101
- @constrained_fields << association.primary_key_name.to_sym unless association.belongs_to?
101
+ @constrained_fields << association.foreign_key.to_sym unless association.belongs_to?
102
102
  model.reflect_on_all_associations.each do |current|
103
- if !current.belongs_to? && association.primary_key_name == current.association_foreign_key
103
+ if !current.belongs_to? && association.foreign_key == current.association_foreign_key
104
104
  constrained_fields << current.name.to_sym
105
105
  @child_association = current if current.klass == @parent_model
106
106
  end
107
- if association.primary_key_name == current.primary_key_name
107
+ if association.foreign_key == current.foreign_key
108
108
  # show columns for has_many and has_one child associationes
109
109
  constrained_fields << current.name.to_sym if current.belongs_to?
110
110
  @child_association = current
@@ -9,7 +9,7 @@ module ActiveScaffold::DataStructures
9
9
  end
10
10
 
11
11
  def set_default_sorting(model)
12
- model_scope = model.send(:current_scoped_methods)
12
+ model_scope = model.send(:build_default_scope)
13
13
  order_clause = model_scope.arel.order_clauses.join(",") if model_scope
14
14
 
15
15
  # If an ORDER BY clause is found set default sorting according to it, else
@@ -0,0 +1,8 @@
1
+ module ActiveScaffold
2
+ #do not use module Rails... cause Rails.logger will fail
3
+ # not sure if it is a must though...
4
+ #module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ #end
8
+ end
@@ -0,0 +1,22 @@
1
+ # wrap the action rendering for ActiveScaffold controllers
2
+ module ActionController #:nodoc:
3
+ class Base
4
+ def render_with_active_scaffold(*args, &block)
5
+ if self.class.uses_active_scaffold? and params[:adapter] and @rendering_adapter.nil?
6
+ @rendering_adapter = true # recursion control
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
9
+ render :partial => params[:adapter][1..-1],
10
+ :locals => {:payload => render_to_string(opts.merge(:layout => false), &block).html_safe},
11
+ :use_full_path => true, :layout => false
12
+ @rendering_adapter = nil # recursion control
13
+ else
14
+ render_without_active_scaffold(*args, &block)
15
+ end
16
+ end
17
+ alias_method_chain :render, :active_scaffold
18
+
19
+ # Rails 2.x implementation is post-initialization on :active_scaffold method
20
+ end
21
+ end
22
+