active_scaffold 3.4.17 → 3.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +12 -1
  3. data/README.md +8 -4
  4. data/app/assets/javascripts/jquery/active_scaffold.js +82 -67
  5. data/app/assets/stylesheets/active_scaffold.scss +1 -1
  6. data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
  7. data/app/assets/stylesheets/blue-theme.css +1 -1
  8. data/app/views/active_scaffold_overrides/_form_association.html.erb +3 -3
  9. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +3 -3
  10. data/app/views/active_scaffold_overrides/_show_columns.html.erb +1 -1
  11. data/lib/active_scaffold.rb +16 -16
  12. data/lib/active_scaffold/actions/common_search.rb +13 -11
  13. data/lib/active_scaffold/actions/core.rb +85 -78
  14. data/lib/active_scaffold/actions/create.rb +29 -28
  15. data/lib/active_scaffold/actions/delete.rb +17 -17
  16. data/lib/active_scaffold/actions/field_search.rb +18 -19
  17. data/lib/active_scaffold/actions/list.rb +30 -22
  18. data/lib/active_scaffold/actions/mark.rb +1 -1
  19. data/lib/active_scaffold/actions/nested.rb +78 -65
  20. data/lib/active_scaffold/actions/search.rb +13 -10
  21. data/lib/active_scaffold/actions/show.rb +10 -6
  22. data/lib/active_scaffold/actions/subform.rb +1 -2
  23. data/lib/active_scaffold/actions/update.rb +39 -31
  24. data/lib/active_scaffold/active_record_permissions.rb +14 -15
  25. data/lib/active_scaffold/attribute_params.rb +42 -43
  26. data/lib/active_scaffold/bridges.rb +22 -12
  27. data/lib/active_scaffold/bridges/ancestry.rb +1 -1
  28. data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +6 -6
  29. data/lib/active_scaffold/bridges/bitfields.rb +1 -1
  30. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -13
  31. data/lib/active_scaffold/bridges/calendar_date_select.rb +5 -5
  32. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +17 -20
  33. data/lib/active_scaffold/bridges/cancan.rb +1 -1
  34. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +8 -9
  35. data/lib/active_scaffold/bridges/carrierwave.rb +4 -4
  36. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +9 -8
  37. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +11 -10
  38. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +7 -6
  39. data/lib/active_scaffold/bridges/chosen.rb +1 -1
  40. data/lib/active_scaffold/bridges/chosen/helpers.rb +4 -4
  41. data/lib/active_scaffold/bridges/country_helper.rb +1 -1
  42. data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +259 -260
  43. data/lib/active_scaffold/bridges/date_picker.rb +2 -2
  44. data/lib/active_scaffold/bridges/date_picker/ext.rb +9 -11
  45. data/lib/active_scaffold/bridges/date_picker/helper.rb +61 -67
  46. data/lib/active_scaffold/bridges/dragonfly.rb +4 -4
  47. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +9 -8
  48. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +11 -10
  49. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +6 -5
  50. data/lib/active_scaffold/bridges/file_column.rb +5 -5
  51. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +20 -23
  52. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +20 -23
  53. data/lib/active_scaffold/bridges/file_column/form_ui.rb +13 -14
  54. data/lib/active_scaffold/bridges/file_column/list_ui.rb +7 -8
  55. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +18 -22
  56. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +5 -4
  57. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +2 -10
  58. data/lib/active_scaffold/bridges/paper_trail.rb +7 -5
  59. data/lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb +4 -3
  60. data/lib/active_scaffold/bridges/paperclip.rb +5 -5
  61. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +11 -10
  62. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +6 -5
  63. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +10 -9
  64. data/lib/active_scaffold/bridges/record_select.rb +1 -1
  65. data/lib/active_scaffold/bridges/record_select/helpers.rb +28 -28
  66. data/lib/active_scaffold/bridges/semantic_attributes.rb +1 -1
  67. data/lib/active_scaffold/bridges/semantic_attributes/column.rb +1 -1
  68. data/lib/active_scaffold/bridges/shared/date_bridge.rb +58 -52
  69. data/lib/active_scaffold/bridges/tiny_mce.rb +2 -2
  70. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -3
  71. data/lib/active_scaffold/config/base.rb +9 -10
  72. data/lib/active_scaffold/config/core.rb +24 -29
  73. data/lib/active_scaffold/config/create.rb +0 -1
  74. data/lib/active_scaffold/config/field_search.rb +8 -10
  75. data/lib/active_scaffold/config/form.rb +5 -5
  76. data/lib/active_scaffold/config/list.rb +21 -20
  77. data/lib/active_scaffold/config/mark.rb +3 -3
  78. data/lib/active_scaffold/config/nested.rb +11 -10
  79. data/lib/active_scaffold/config/search.rb +2 -3
  80. data/lib/active_scaffold/config/show.rb +1 -1
  81. data/lib/active_scaffold/config/update.rb +1 -2
  82. data/lib/active_scaffold/configurable.rb +9 -11
  83. data/lib/active_scaffold/constraints.rb +9 -8
  84. data/lib/active_scaffold/core.rb +72 -84
  85. data/lib/active_scaffold/data_structures/action_columns.rb +26 -25
  86. data/lib/active_scaffold/data_structures/action_link.rb +43 -43
  87. data/lib/active_scaffold/data_structures/action_links.rb +17 -15
  88. data/lib/active_scaffold/data_structures/actions.rb +5 -5
  89. data/lib/active_scaffold/data_structures/bridge.rb +6 -3
  90. data/lib/active_scaffold/data_structures/column.rb +110 -89
  91. data/lib/active_scaffold/data_structures/columns.rb +3 -3
  92. data/lib/active_scaffold/data_structures/error_message.rb +4 -6
  93. data/lib/active_scaffold/data_structures/nested_info.rb +43 -48
  94. data/lib/active_scaffold/data_structures/set.rb +7 -8
  95. data/lib/active_scaffold/data_structures/sorting.rb +38 -33
  96. data/lib/active_scaffold/delayed_setup.rb +5 -6
  97. data/lib/active_scaffold/engine.rb +4 -4
  98. data/lib/active_scaffold/extensions/action_controller_rendering.rb +3 -4
  99. data/lib/active_scaffold/extensions/action_controller_rescueing.rb +1 -1
  100. data/lib/active_scaffold/extensions/action_view_rendering.rb +5 -6
  101. data/lib/active_scaffold/extensions/left_outer_joins.rb +11 -11
  102. data/lib/active_scaffold/extensions/localize.rb +1 -1
  103. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +1 -1
  104. data/lib/active_scaffold/extensions/paginator_extensions.rb +2 -5
  105. data/lib/active_scaffold/extensions/reverse_associations.rb +13 -13
  106. data/lib/active_scaffold/extensions/routing_mapper.rb +9 -9
  107. data/lib/active_scaffold/extensions/unsaved_associated.rb +9 -9
  108. data/lib/active_scaffold/finder.rb +90 -93
  109. data/lib/active_scaffold/helpers/association_helpers.rb +5 -5
  110. data/lib/active_scaffold/helpers/controller_helpers.rb +22 -19
  111. data/lib/active_scaffold/helpers/form_column_helpers.rb +115 -105
  112. data/lib/active_scaffold/helpers/human_condition_helpers.rb +62 -35
  113. data/lib/active_scaffold/helpers/id_helpers.rb +6 -6
  114. data/lib/active_scaffold/helpers/list_column_helpers.rb +89 -94
  115. data/lib/active_scaffold/helpers/pagination_helpers.rb +9 -9
  116. data/lib/active_scaffold/helpers/search_column_helpers.rb +47 -44
  117. data/lib/active_scaffold/helpers/show_column_helpers.rb +2 -2
  118. data/lib/active_scaffold/helpers/view_helpers.rb +86 -91
  119. data/lib/active_scaffold/marked_model.rb +10 -10
  120. data/lib/active_scaffold/paginator.rb +30 -34
  121. data/lib/active_scaffold/responds_to_parent.rb +27 -28
  122. data/lib/active_scaffold/tableless.rb +20 -15
  123. data/lib/active_scaffold/version.rb +1 -1
  124. data/lib/generators/active_scaffold/active_scaffold_generator.rb +8 -8
  125. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +9 -9
  126. data/shoulda_macros/macros.rb +27 -22
  127. data/test/bridges/bridge_test.rb +38 -29
  128. data/test/bridges/date_picker_test.rb +1 -1
  129. data/test/bridges/paper_trail_test.rb +17 -0
  130. data/test/bridges/paperclip_test.rb +3 -2
  131. data/test/bridges/tiny_mce_test.rb +5 -2
  132. data/test/company.rb +25 -30
  133. data/test/config/base_test.rb +1 -1
  134. data/test/config/core_test.rb +9 -9
  135. data/test/config/create_test.rb +14 -8
  136. data/test/config/delete_test.rb +4 -4
  137. data/test/config/field_search_test.rb +6 -6
  138. data/test/config/list_test.rb +16 -16
  139. data/test/config/nested_test.rb +4 -4
  140. data/test/config/search_test.rb +8 -8
  141. data/test/config/show_test.rb +6 -6
  142. data/test/config/subform_test.rb +1 -1
  143. data/test/config/update_test.rb +5 -5
  144. data/test/const_mocker.rb +4 -4
  145. data/test/data_structures/action_columns_test.rb +4 -5
  146. data/test/data_structures/action_link_test.rb +1 -0
  147. data/test/data_structures/action_links_test.rb +5 -5
  148. data/test/data_structures/column_test.rb +9 -9
  149. data/test/data_structures/columns_test.rb +2 -2
  150. data/test/data_structures/error_message_test.rb +4 -5
  151. data/test/data_structures/set_test.rb +1 -2
  152. data/test/data_structures/sorting_test.rb +10 -10
  153. data/test/data_structures/validation_reflection_test.rb +8 -0
  154. data/test/extensions/routing_mapper_test.rb +2 -2
  155. data/test/helpers/list_column_helpers_test.rb +3 -2
  156. data/test/helpers/pagination_helpers_test.rb +5 -4
  157. data/test/helpers/search_column_helpers_test.rb +1 -1
  158. data/test/misc/active_record_permissions_test.rb +63 -50
  159. data/test/misc/attribute_params_test.rb +28 -26
  160. data/test/misc/calculation_test.rb +10 -3
  161. data/test/misc/configurable_test.rb +12 -13
  162. data/test/misc/constraints_test.rb +6 -6
  163. data/test/misc/convert_numbers_format_test.rb +7 -6
  164. data/test/misc/finder_test.rb +17 -12
  165. data/test/misc/lang_test.rb +3 -4
  166. data/test/misc/tableless_test.rb +2 -3
  167. data/test/mock_app/app/controllers/addresses_controller.rb +1 -1
  168. data/test/mock_app/app/controllers/buildings_controller.rb +1 -1
  169. data/test/mock_app/app/controllers/cars_controller.rb +1 -1
  170. data/test/mock_app/app/controllers/contacts_controller.rb +1 -1
  171. data/test/mock_app/app/controllers/people_controller.rb +1 -1
  172. data/test/mock_app/app/models/file_model.rb +2 -2
  173. data/test/mock_app/app/models/person.rb +1 -1
  174. data/test/mock_app/config/application.rb +3 -3
  175. data/test/mock_app/config/boot.rb +1 -1
  176. data/test/mock_app/config/environment.rb +1 -0
  177. data/test/mock_app/config/environments/development.rb +0 -1
  178. data/test/mock_app/config/environments/production.rb +1 -1
  179. data/test/mock_app/db/schema.rb +14 -15
  180. data/test/model_stub.rb +13 -16
  181. data/test/run_all.rb +5 -7
  182. data/test/test_helper.rb +12 -9
  183. metadata +19 -3
@@ -2,7 +2,7 @@ module ActiveScaffold::Bridges
2
2
  class DatePicker < ActiveScaffold::DataStructures::Bridge
3
3
  autoload :Helper, 'active_scaffold/bridges/date_picker/helper'
4
4
  def self.install
5
- require File.join(File.dirname(__FILE__), "date_picker/ext.rb")
5
+ require File.join(File.dirname(__FILE__), 'date_picker/ext.rb')
6
6
  end
7
7
  def self.install?
8
8
  ActiveScaffold.js_framework == :jquery && jquery_ui_included?
@@ -20,7 +20,7 @@ module ActiveScaffold::Bridges
20
20
  #{Helper.datetime_options_for_locales}
21
21
  $.timepicker.setDefaults($.timepicker.regional['#{::I18n.locale}']);
22
22
  }
23
- });\n"
23
+ });\n"
24
24
  end
25
25
  end
26
26
  end
@@ -1,28 +1,26 @@
1
1
  class File #:nodoc:
2
-
3
2
  unless File.respond_to?(:binread)
4
3
  def self.binread(file)
5
4
  File.open(file, 'rb') { |f| f.read }
6
5
  end
7
6
  end
8
-
9
- end
7
+ end
10
8
 
11
9
  ActiveScaffold::Config::Core.class_eval do
12
10
  def initialize_with_date_picker(model_id)
13
11
  initialize_without_date_picker(model_id)
14
-
15
- date_picker_fields = self.model.columns.collect{|c| {:name => c.name.to_sym, :type => c.type} if [:date, :datetime].include?(c.type) }.compact
12
+
13
+ date_picker_fields = model.columns.collect { |c| {:name => c.name.to_sym, :type => c.type} if [:date, :datetime].include?(c.type) }.compact
16
14
  # check to see if file column was used on the model
17
15
  return if date_picker_fields.empty?
18
-
16
+
19
17
  # automatically set the forum_ui to a date_picker or datetime_picker
20
- date_picker_fields.each{|field|
21
- col_config = self.columns[field[:name]]
18
+ date_picker_fields.each do |field|
19
+ col_config = columns[field[:name]]
22
20
  col_config.form_ui = (field[:type] == :date ? :date_picker : :datetime_picker)
23
- }
21
+ end
24
22
  end
25
-
23
+
26
24
  alias_method_chain :initialize, :date_picker
27
25
  end
28
26
 
@@ -62,7 +60,7 @@ ActiveScaffold::Finder::ClassMethods.module_eval do
62
60
  end
63
61
  end
64
62
  alias_method_chain :datetime_conversion_for_condition, :datepicker
65
-
63
+
66
64
  alias_method :condition_for_date_picker_type, :condition_for_date_bridge_type
67
65
  alias_method :condition_for_datetime_picker_type, :condition_for_date_picker_type
68
66
  end
@@ -19,43 +19,40 @@ module ActiveScaffold::Bridges
19
19
  /%S/ => 'ss',
20
20
  /%[cUWwxXZz]/ => ''
21
21
  }
22
-
22
+
23
23
  def self.date_options_for_locales
24
24
  I18n.available_locales.collect do |locale|
25
25
  locale_date_options = date_options(locale)
26
26
  if locale_date_options
27
27
  "$.datepicker.regional['#{locale}'] = #{locale_date_options.to_json};"
28
- else
29
- nil
30
28
  end
31
29
  end.compact.join('')
32
30
  end
33
-
31
+
34
32
  def self.date_options(locale)
35
- begin
36
- date_picker_options = { :closeText => as_(:close),
37
- :prevText => as_(:previous),
38
- :nextText => as_(:next),
39
- :currentText => as_(:today),
40
- :monthNames => I18n.translate!('date.month_names', :locale => locale)[1..-1],
41
- :monthNamesShort => I18n.translate!('date.abbr_month_names', :locale => locale)[1..-1],
42
- :dayNames => I18n.translate!('date.day_names', :locale => locale),
43
- :dayNamesShort => I18n.translate!('date.abbr_day_names', :locale => locale),
44
- :dayNamesMin => I18n.translate!('date.abbr_day_names', :locale => locale),
45
- :changeYear => true,
46
- :changeMonth => true,
47
- }
48
-
49
- as_date_picker_options = I18n.translate! :date_picker_options, :scope => :active_scaffold, :locale => locale, :default => ''
50
- date_picker_options.merge!(as_date_picker_options) if as_date_picker_options.is_a? Hash
51
- Rails.logger.warn "ActiveScaffold: Missing date picker localization for your locale: #{locale}" if as_date_picker_options.blank?
52
-
53
- js_format = self.to_datepicker_format(I18n.translate!('date.formats.default', :locale => locale, :default => ''))
54
- date_picker_options[:dateFormat] = js_format unless js_format.blank?
55
- date_picker_options
56
- rescue
57
- raise if locale == I18n.locale
58
- end
33
+ date_picker_options = {
34
+ :closeText => as_(:close),
35
+ :prevText => as_(:previous),
36
+ :nextText => as_(:next),
37
+ :currentText => as_(:today),
38
+ :monthNames => I18n.translate!('date.month_names', :locale => locale)[1..-1],
39
+ :monthNamesShort => I18n.translate!('date.abbr_month_names', :locale => locale)[1..-1],
40
+ :dayNames => I18n.translate!('date.day_names', :locale => locale),
41
+ :dayNamesShort => I18n.translate!('date.abbr_day_names', :locale => locale),
42
+ :dayNamesMin => I18n.translate!('date.abbr_day_names', :locale => locale),
43
+ :changeYear => true,
44
+ :changeMonth => true
45
+ }
46
+
47
+ as_date_picker_options = I18n.translate! :date_picker_options, :scope => :active_scaffold, :locale => locale, :default => ''
48
+ date_picker_options.merge!(as_date_picker_options) if as_date_picker_options.is_a? Hash
49
+ Rails.logger.warn "ActiveScaffold: Missing date picker localization for your locale: #{locale}" if as_date_picker_options.blank?
50
+
51
+ js_format = to_datepicker_format(I18n.translate!('date.formats.default', :locale => locale, :default => ''))
52
+ date_picker_options[:dateFormat] = js_format unless js_format.blank?
53
+ date_picker_options
54
+ rescue
55
+ raise if locale == I18n.locale
59
56
  end
60
57
 
61
58
  def self.datetime_options_for_locales
@@ -63,37 +60,34 @@ module ActiveScaffold::Bridges
63
60
  locale_datetime_options = datetime_options(locale)
64
61
  if locale_datetime_options
65
62
  "$.timepicker.regional['#{locale}'] = #{locale_datetime_options.to_json};"
66
- else
67
- nil
68
63
  end
69
64
  end.compact.join('')
70
65
  end
71
-
66
+
72
67
  def self.datetime_options(locale)
73
- begin
74
- rails_time_format = I18n.translate! 'time.formats.picker', :locale => locale, :default => '%a, %d %b %Y %H:%M:%S'
75
- datetime_picker_options = {:ampm => false,
76
- :hourText => I18n.translate!('datetime.prompts.hour', :locale => locale),
77
- :minuteText => I18n.translate!('datetime.prompts.minute', :locale => locale),
78
- :secondText => I18n.translate!('datetime.prompts.second', :locale => locale)
79
- }
80
-
81
- as_datetime_picker_options = I18n.translate! :datetime_picker_options, :scope => :active_scaffold, :locale => locale, :default => ''
82
- datetime_picker_options.merge!(as_datetime_picker_options) if as_datetime_picker_options.is_a? Hash
83
- Rails.logger.warn "ActiveScaffold: Missing datetime picker localization for your locale: #{locale}" if as_datetime_picker_options.blank?
84
-
85
- date_format, time_format = self.split_datetime_format(self.to_datepicker_format(rails_time_format))
86
- datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
87
- unless time_format.nil?
88
- datetime_picker_options[:timeFormat] = time_format
89
- datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
90
- end
91
- datetime_picker_options
92
- rescue
93
- raise if locale == I18n.locale
68
+ rails_time_format = I18n.translate! 'time.formats.picker', :locale => locale, :default => '%a, %d %b %Y %H:%M:%S'
69
+ datetime_picker_options = {
70
+ :ampm => false,
71
+ :hourText => I18n.translate!('datetime.prompts.hour', :locale => locale),
72
+ :minuteText => I18n.translate!('datetime.prompts.minute', :locale => locale),
73
+ :secondText => I18n.translate!('datetime.prompts.second', :locale => locale)
74
+ }
75
+
76
+ as_datetime_picker_options = I18n.translate! :datetime_picker_options, :scope => :active_scaffold, :locale => locale, :default => ''
77
+ datetime_picker_options.merge!(as_datetime_picker_options) if as_datetime_picker_options.is_a? Hash
78
+ Rails.logger.warn "ActiveScaffold: Missing datetime picker localization for your locale: #{locale}" if as_datetime_picker_options.blank?
79
+
80
+ date_format, time_format = split_datetime_format(to_datepicker_format(rails_time_format))
81
+ datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
82
+ unless time_format.nil?
83
+ datetime_picker_options[:timeFormat] = time_format
84
+ datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
94
85
  end
86
+ datetime_picker_options
87
+ rescue
88
+ raise if locale == I18n.locale
95
89
  end
96
-
90
+
97
91
  def self.to_datepicker_format(rails_format)
98
92
  return nil if rails_format.nil?
99
93
  if rails_format =~ /%[cUWwxXZz]/
@@ -107,27 +101,27 @@ module ActiveScaffold::Bridges
107
101
  end
108
102
  js_format
109
103
  end
110
-
104
+
111
105
  def self.split_datetime_format(datetime_format)
112
106
  date_format = datetime_format
113
107
  time_format = nil
114
- time_start_indicators = %w{HH hh mm tt ss}
108
+ time_start_indicators = %w(HH hh mm tt ss)
115
109
  unless datetime_format.nil?
116
- start_indicator = time_start_indicators.detect {|indicator| datetime_format.include?(indicator)}
110
+ start_indicator = time_start_indicators.detect { |indicator| datetime_format.include?(indicator) }
117
111
  unless start_indicator.nil?
118
112
  pos_time_format = datetime_format.index(start_indicator)
119
113
  date_format = datetime_format.to(pos_time_format - 1).strip
120
114
  time_format = datetime_format.from(pos_time_format).strip
121
115
  end
122
116
  end
123
- return date_format, time_format
117
+ [date_format, time_format]
124
118
  end
125
-
119
+
126
120
  module DatepickerColumnHelpers
127
121
  def datepicker_split_datetime_format(datetime_format)
128
122
  ActiveScaffold::Bridges::DatePicker::Helper.split_datetime_format(datetime_format)
129
123
  end
130
-
124
+
131
125
  def to_datepicker_format(rails_format)
132
126
  ActiveScaffold::Bridges::DatePicker::Helper.to_datepicker_format(rails_format)
133
127
  end
@@ -138,7 +132,7 @@ module ActiveScaffold::Bridges
138
132
  options['data-dateFormat'] = js_format unless js_format.nil?
139
133
  else
140
134
  rails_time_format = I18n.translate!("time.formats.#{format}")
141
- date_format, time_format = datepicker_split_datetime_format(self.to_datepicker_format(rails_time_format))
135
+ date_format, time_format = datepicker_split_datetime_format(to_datepicker_format(rails_time_format))
142
136
  options['data-dateFormat'] = date_format unless date_format.nil?
143
137
  unless time_format.nil?
144
138
  options['data-timeFormat'] = time_format
@@ -147,7 +141,7 @@ module ActiveScaffold::Bridges
147
141
  end unless format == :default
148
142
  end
149
143
  end
150
-
144
+
151
145
  module SearchColumnHelpers
152
146
  def active_scaffold_search_date_bridge_calendar_control(column, options, current_search, name)
153
147
  if current_search.is_a? Hash
@@ -157,21 +151,21 @@ module ActiveScaffold::Bridges
157
151
  end
158
152
  options = column.options.merge(options).except!(:include_blank, :discard_time, :discard_date, :value)
159
153
  options = active_scaffold_input_text_options(options.merge(column.options))
160
- options[:class] << " #{column.search_ui.to_s}"
161
- options[:style] = (options[:show].nil? || options[:show]) ? nil : "display: none"
154
+ options[:class] << " #{column.search_ui}"
155
+ options[:style] = (options[:show].nil? || options[:show]) ? nil : 'display: none'
162
156
  format = options.delete(:format) || (column.search_ui == :date_picker ? :default : :picker)
163
157
  datepicker_format_options(column, format, options)
164
158
  text_field_tag("#{options[:name]}[#{name}]", value ? l(value, :format => format) : nil, options.merge(:id => "#{options[:id]}_#{name}", :name => "#{options[:name]}[#{name}]", :object => nil))
165
159
  end
166
160
  end
167
-
161
+
168
162
  module FormColumnHelpers
169
163
  def active_scaffold_input_date_picker(column, options)
170
164
  record = options[:object]
171
- ActiveSupport::Deprecation.warn "Relying on @record is deprecated, include :object in html_options with record.", caller if record.nil? # TODO Remove when relying on @record is removed
172
- record ||= @record # TODO Remove when relying on @record is removed
165
+ ActiveSupport::Deprecation.warn 'Relying on @record is deprecated, include :object in html_options with record.', caller if record.nil? # TODO: Remove when relying on @record is removed
166
+ record ||= @record # TODO: Remove when relying on @record is removed
173
167
  options = active_scaffold_input_text_options(options.merge(column.options))
174
- options[:class] << " #{column.form_ui.to_s}"
168
+ options[:class] << " #{column.form_ui}"
175
169
 
176
170
  value = controller.class.condition_value_for_datetime(column, record.send(column.name), column.form_ui == :date_picker ? :to_date : :to_time)
177
171
  format = options.delete(:format) || (column.form_ui == :date_picker ? :default : :picker)
@@ -1,9 +1,9 @@
1
1
  class ActiveScaffold::Bridges::Dragonfly < ActiveScaffold::DataStructures::Bridge
2
2
  def self.install
3
- require File.join(File.dirname(__FILE__), "dragonfly/form_ui")
4
- require File.join(File.dirname(__FILE__), "dragonfly/list_ui")
5
- require File.join(File.dirname(__FILE__), "dragonfly/dragonfly_bridge_helpers")
6
- require File.join(File.dirname(__FILE__), "dragonfly/dragonfly_bridge")
3
+ require File.join(File.dirname(__FILE__), 'dragonfly/form_ui')
4
+ require File.join(File.dirname(__FILE__), 'dragonfly/list_ui')
5
+ require File.join(File.dirname(__FILE__), 'dragonfly/dragonfly_bridge_helpers')
6
+ require File.join(File.dirname(__FILE__), 'dragonfly/dragonfly_bridge')
7
7
  ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Dragonfly::DragonflyBridge
8
8
  end
9
9
  end
@@ -4,12 +4,12 @@ module ActiveScaffold
4
4
  module DragonflyBridge
5
5
  def initialize_with_dragonfly(model_id)
6
6
  initialize_without_dragonfly(model_id)
7
- return unless self.model.respond_to?(:dragonfly_attachment_classes) && self.model.dragonfly_attachment_classes.present?
7
+ return unless model.respond_to?(:dragonfly_attachment_classes) && model.dragonfly_attachment_classes.present?
8
8
 
9
- self.update.multipart = true
10
- self.create.multipart = true
9
+ update.multipart = true
10
+ create.multipart = true
11
11
 
12
- self.model.dragonfly_attachment_classes.each do |attachment|
12
+ model.dragonfly_attachment_classes.each do |attachment|
13
13
  configure_dragonfly_field(attachment.attribute)
14
14
  end
15
15
  end
@@ -19,13 +19,14 @@ module ActiveScaffold
19
19
  end
20
20
 
21
21
  private
22
+
22
23
  def configure_dragonfly_field(field)
23
- self.columns << field
24
- self.columns[field].form_ui ||= :dragonfly
25
- self.columns[field].params.add "remove_#{field}"
24
+ columns << field
25
+ columns[field].form_ui ||= :dragonfly
26
+ columns[field].params.add "remove_#{field}"
26
27
 
27
28
  [:name, :uid].each do |f|
28
- self.columns.exclude("#{field}_#{f}".to_sym)
29
+ columns.exclude("#{field}_#{f}".to_sym)
29
30
  end
30
31
  end
31
32
  end
@@ -3,8 +3,8 @@ module ActiveScaffold
3
3
  module FormColumnHelpers
4
4
  def active_scaffold_input_dragonfly(column, options)
5
5
  record = options[:object]
6
- ActiveSupport::Deprecation.warn "Relying on @record is deprecated, include :object in html_options with record.", caller if record.nil? # TODO Remove when relying on @record is removed
7
- record ||= @record # TODO Remove when relying on @record is removed
6
+ ActiveSupport::Deprecation.warn 'Relying on @record is deprecated, include :object in html_options with record.', caller if record.nil? # TODO: Remove when relying on @record is removed
7
+ record ||= @record # TODO: Remove when relying on @record is removed
8
8
  options = active_scaffold_input_text_options(options.merge(column.options))
9
9
 
10
10
  input = file_field(:record, column.name, options)
@@ -12,17 +12,18 @@ module ActiveScaffold
12
12
  if dragonfly.present?
13
13
  case ActiveScaffold.js_framework
14
14
  when :jquery
15
- js_remove_file_code = "jQuery(this).prev().val('true'); jQuery(this).parent().hide().next().show(); return false;";
15
+ js_remove_file_code = "jQuery(this).prev().val('true'); jQuery(this).parent().hide().next().show(); return false;"
16
16
  when :prototype
17
- js_remove_file_code = "$(this).previous().value='true'; $(this).up().hide().next().show(); return false;";
17
+ js_remove_file_code = "$(this).previous().value='true'; $(this).up().hide().next().show(); return false;"
18
18
  end
19
-
19
+
20
20
  content = active_scaffold_column_dragonfly(record, column)
21
- content_tag(:div,
22
- content + " | " +
23
- hidden_field(:record, "remove_#{column.name}", :value => "false") +
24
- content_tag(:a, as_(:remove_file), {:href => '#', :onclick => js_remove_file_code})
25
- ) + content_tag(:div, input, :style => "display: none")
21
+ content_tag(
22
+ :div,
23
+ content + ' | ' +
24
+ hidden_field(:record, "remove_#{column.name}", :value => 'false') +
25
+ content_tag(:a, as_(:remove_file), :href => '#', :onclick => js_remove_file_code)
26
+ ) + content_tag(:div, input, :style => 'display: none')
26
27
  else
27
28
  input
28
29
  end
@@ -4,11 +4,12 @@ module ActiveScaffold
4
4
  def active_scaffold_column_dragonfly(record, column)
5
5
  attachment = record.send("#{column.name}")
6
6
  return nil unless attachment.present?
7
- content = if attachment.image?
8
- image_tag(attachment.thumb(column.options[:thumb] || ActiveScaffold::Bridges::Dragonfly::DragonflyBridgeHelpers.thumbnail_style).url, :border => 0)
9
- else
10
- attachment.name
11
- end
7
+ content =
8
+ if attachment.image?
9
+ image_tag(attachment.thumb(column.options[:thumb] || ActiveScaffold::Bridges::Dragonfly::DragonflyBridgeHelpers.thumbnail_style).url, :border => 0)
10
+ else
11
+ attachment.name
12
+ end
12
13
  link_to(content, dragonfly_url_for_attachment(attachment, record, column), :target => '_blank')
13
14
  end
14
15
 
@@ -1,11 +1,11 @@
1
1
  class ActiveScaffold::Bridges::FileColumn < ActiveScaffold::DataStructures::Bridge
2
2
  def self.install
3
3
  if ActiveScaffold::Config::Core.method_defined?(:initialize_with_file_column)
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"
4
+ raise "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
- require File.join(File.dirname(__FILE__), "file_column/as_file_column_bridge")
7
- require File.join(File.dirname(__FILE__), "file_column/form_ui")
8
- require File.join(File.dirname(__FILE__), "file_column/list_ui")
9
- require File.join(File.dirname(__FILE__), "file_column/file_column_helpers")
6
+ require File.join(File.dirname(__FILE__), 'file_column/as_file_column_bridge')
7
+ require File.join(File.dirname(__FILE__), 'file_column/form_ui')
8
+ require File.join(File.dirname(__FILE__), 'file_column/list_ui')
9
+ require File.join(File.dirname(__FILE__), 'file_column/file_column_helpers')
10
10
  end
11
11
  end
@@ -7,40 +7,37 @@ module ActiveScaffold::Config
7
7
  attr_accessor :file_column_fields
8
8
  def initialize_with_file_column(model_id)
9
9
  initialize_without_file_column(model_id)
10
-
11
- return unless ActiveScaffold::Bridges::FileColumn::FileColumnHelpers.klass_has_file_column_fields?(self.model)
12
-
13
- self.model.send :extend, ActiveScaffold::Bridges::FileColumn::FileColumnHelpers
14
-
10
+
11
+ return unless ActiveScaffold::Bridges::FileColumn::FileColumnHelpers.klass_has_file_column_fields?(model)
12
+
13
+ model.send :extend, ActiveScaffold::Bridges::FileColumn::FileColumnHelpers
14
+
15
15
  # include the "delete" helpers for use with active scaffold, unless they are already included
16
- self.model.generate_delete_helpers
17
-
16
+ model.generate_delete_helpers
17
+
18
18
  # switch on multipart
19
- self.update.multipart = true
20
- self.create.multipart = true
21
-
22
- self.model.file_column_fields.each{ |field|
23
- configure_file_column_field(field)
24
- }
19
+ update.multipart = true
20
+ create.multipart = true
21
+
22
+ model.file_column_fields.each { |field| configure_file_column_field(field) }
25
23
  end
26
-
24
+
27
25
  alias_method_chain :initialize, :file_column unless self.method_defined?(:initialize_without_file_column)
28
-
26
+
29
27
  def configure_file_column_field(field)
30
28
  # set list_ui first because it gets its default value from form_ui
31
- self.columns[field].list_ui ||= self.model.field_has_image_version?(field, "thumb") ? :thumbnail : :download_link_with_filename
32
- self.columns[field].form_ui ||= :file_column
33
-
29
+ columns[field].list_ui ||= model.field_has_image_version?(field, 'thumb') ? :thumbnail : :download_link_with_filename
30
+ columns[field].form_ui ||= :file_column
31
+
34
32
  # these 2 parameters are necessary helper attributes for the file column that must be allowed to be set to the model by active scaffold.
35
- self.columns[field].params.add "#{field}_temp", "delete_#{field}"
36
-
33
+ columns[field].params.add "#{field}_temp", "delete_#{field}"
34
+
37
35
  # set null to false so active_scaffold wont set it to null
38
36
  # delete_file_column will take care of deleting a file or not.
39
- self.model.columns_hash[field.to_s].instance_variable_set("@null", false)
40
-
37
+ model.columns_hash[field.to_s].instance_variable_set('@null', false)
38
+
41
39
  rescue
42
40
  false
43
41
  end
44
-
45
42
  end
46
43
  end