active_scaffold 3.4.17 → 3.4.18
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.
- checksums.yaml +4 -4
- data/CHANGELOG +12 -1
- data/README.md +8 -4
- data/app/assets/javascripts/jquery/active_scaffold.js +82 -67
- data/app/assets/stylesheets/active_scaffold.scss +1 -1
- data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
- data/app/assets/stylesheets/blue-theme.css +1 -1
- data/app/views/active_scaffold_overrides/_form_association.html.erb +3 -3
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +3 -3
- data/app/views/active_scaffold_overrides/_show_columns.html.erb +1 -1
- data/lib/active_scaffold.rb +16 -16
- data/lib/active_scaffold/actions/common_search.rb +13 -11
- data/lib/active_scaffold/actions/core.rb +85 -78
- data/lib/active_scaffold/actions/create.rb +29 -28
- data/lib/active_scaffold/actions/delete.rb +17 -17
- data/lib/active_scaffold/actions/field_search.rb +18 -19
- data/lib/active_scaffold/actions/list.rb +30 -22
- data/lib/active_scaffold/actions/mark.rb +1 -1
- data/lib/active_scaffold/actions/nested.rb +78 -65
- data/lib/active_scaffold/actions/search.rb +13 -10
- data/lib/active_scaffold/actions/show.rb +10 -6
- data/lib/active_scaffold/actions/subform.rb +1 -2
- data/lib/active_scaffold/actions/update.rb +39 -31
- data/lib/active_scaffold/active_record_permissions.rb +14 -15
- data/lib/active_scaffold/attribute_params.rb +42 -43
- data/lib/active_scaffold/bridges.rb +22 -12
- data/lib/active_scaffold/bridges/ancestry.rb +1 -1
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +6 -6
- data/lib/active_scaffold/bridges/bitfields.rb +1 -1
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -13
- data/lib/active_scaffold/bridges/calendar_date_select.rb +5 -5
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +17 -20
- data/lib/active_scaffold/bridges/cancan.rb +1 -1
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +8 -9
- data/lib/active_scaffold/bridges/carrierwave.rb +4 -4
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +9 -8
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +11 -10
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +7 -6
- data/lib/active_scaffold/bridges/chosen.rb +1 -1
- data/lib/active_scaffold/bridges/chosen/helpers.rb +4 -4
- data/lib/active_scaffold/bridges/country_helper.rb +1 -1
- data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +259 -260
- data/lib/active_scaffold/bridges/date_picker.rb +2 -2
- data/lib/active_scaffold/bridges/date_picker/ext.rb +9 -11
- data/lib/active_scaffold/bridges/date_picker/helper.rb +61 -67
- data/lib/active_scaffold/bridges/dragonfly.rb +4 -4
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +9 -8
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +11 -10
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +6 -5
- data/lib/active_scaffold/bridges/file_column.rb +5 -5
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +20 -23
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +20 -23
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +13 -14
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +7 -8
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +18 -22
- data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +5 -4
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +2 -10
- data/lib/active_scaffold/bridges/paper_trail.rb +7 -5
- data/lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb +4 -3
- data/lib/active_scaffold/bridges/paperclip.rb +5 -5
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +11 -10
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +6 -5
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +10 -9
- data/lib/active_scaffold/bridges/record_select.rb +1 -1
- data/lib/active_scaffold/bridges/record_select/helpers.rb +28 -28
- data/lib/active_scaffold/bridges/semantic_attributes.rb +1 -1
- data/lib/active_scaffold/bridges/semantic_attributes/column.rb +1 -1
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +58 -52
- data/lib/active_scaffold/bridges/tiny_mce.rb +2 -2
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -3
- data/lib/active_scaffold/config/base.rb +9 -10
- data/lib/active_scaffold/config/core.rb +24 -29
- data/lib/active_scaffold/config/create.rb +0 -1
- data/lib/active_scaffold/config/field_search.rb +8 -10
- data/lib/active_scaffold/config/form.rb +5 -5
- data/lib/active_scaffold/config/list.rb +21 -20
- data/lib/active_scaffold/config/mark.rb +3 -3
- data/lib/active_scaffold/config/nested.rb +11 -10
- data/lib/active_scaffold/config/search.rb +2 -3
- data/lib/active_scaffold/config/show.rb +1 -1
- data/lib/active_scaffold/config/update.rb +1 -2
- data/lib/active_scaffold/configurable.rb +9 -11
- data/lib/active_scaffold/constraints.rb +9 -8
- data/lib/active_scaffold/core.rb +72 -84
- data/lib/active_scaffold/data_structures/action_columns.rb +26 -25
- data/lib/active_scaffold/data_structures/action_link.rb +43 -43
- data/lib/active_scaffold/data_structures/action_links.rb +17 -15
- data/lib/active_scaffold/data_structures/actions.rb +5 -5
- data/lib/active_scaffold/data_structures/bridge.rb +6 -3
- data/lib/active_scaffold/data_structures/column.rb +110 -89
- data/lib/active_scaffold/data_structures/columns.rb +3 -3
- data/lib/active_scaffold/data_structures/error_message.rb +4 -6
- data/lib/active_scaffold/data_structures/nested_info.rb +43 -48
- data/lib/active_scaffold/data_structures/set.rb +7 -8
- data/lib/active_scaffold/data_structures/sorting.rb +38 -33
- data/lib/active_scaffold/delayed_setup.rb +5 -6
- data/lib/active_scaffold/engine.rb +4 -4
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +3 -4
- data/lib/active_scaffold/extensions/action_controller_rescueing.rb +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +5 -6
- data/lib/active_scaffold/extensions/left_outer_joins.rb +11 -11
- data/lib/active_scaffold/extensions/localize.rb +1 -1
- data/lib/active_scaffold/extensions/name_option_for_datetime.rb +1 -1
- data/lib/active_scaffold/extensions/paginator_extensions.rb +2 -5
- data/lib/active_scaffold/extensions/reverse_associations.rb +13 -13
- data/lib/active_scaffold/extensions/routing_mapper.rb +9 -9
- data/lib/active_scaffold/extensions/unsaved_associated.rb +9 -9
- data/lib/active_scaffold/finder.rb +90 -93
- data/lib/active_scaffold/helpers/association_helpers.rb +5 -5
- data/lib/active_scaffold/helpers/controller_helpers.rb +22 -19
- data/lib/active_scaffold/helpers/form_column_helpers.rb +115 -105
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +62 -35
- data/lib/active_scaffold/helpers/id_helpers.rb +6 -6
- data/lib/active_scaffold/helpers/list_column_helpers.rb +89 -94
- data/lib/active_scaffold/helpers/pagination_helpers.rb +9 -9
- data/lib/active_scaffold/helpers/search_column_helpers.rb +47 -44
- data/lib/active_scaffold/helpers/show_column_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/view_helpers.rb +86 -91
- data/lib/active_scaffold/marked_model.rb +10 -10
- data/lib/active_scaffold/paginator.rb +30 -34
- data/lib/active_scaffold/responds_to_parent.rb +27 -28
- data/lib/active_scaffold/tableless.rb +20 -15
- data/lib/active_scaffold/version.rb +1 -1
- data/lib/generators/active_scaffold/active_scaffold_generator.rb +8 -8
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +9 -9
- data/shoulda_macros/macros.rb +27 -22
- data/test/bridges/bridge_test.rb +38 -29
- data/test/bridges/date_picker_test.rb +1 -1
- data/test/bridges/paper_trail_test.rb +17 -0
- data/test/bridges/paperclip_test.rb +3 -2
- data/test/bridges/tiny_mce_test.rb +5 -2
- data/test/company.rb +25 -30
- data/test/config/base_test.rb +1 -1
- data/test/config/core_test.rb +9 -9
- data/test/config/create_test.rb +14 -8
- data/test/config/delete_test.rb +4 -4
- data/test/config/field_search_test.rb +6 -6
- data/test/config/list_test.rb +16 -16
- data/test/config/nested_test.rb +4 -4
- data/test/config/search_test.rb +8 -8
- data/test/config/show_test.rb +6 -6
- data/test/config/subform_test.rb +1 -1
- data/test/config/update_test.rb +5 -5
- data/test/const_mocker.rb +4 -4
- data/test/data_structures/action_columns_test.rb +4 -5
- data/test/data_structures/action_link_test.rb +1 -0
- data/test/data_structures/action_links_test.rb +5 -5
- data/test/data_structures/column_test.rb +9 -9
- data/test/data_structures/columns_test.rb +2 -2
- data/test/data_structures/error_message_test.rb +4 -5
- data/test/data_structures/set_test.rb +1 -2
- data/test/data_structures/sorting_test.rb +10 -10
- data/test/data_structures/validation_reflection_test.rb +8 -0
- data/test/extensions/routing_mapper_test.rb +2 -2
- data/test/helpers/list_column_helpers_test.rb +3 -2
- data/test/helpers/pagination_helpers_test.rb +5 -4
- data/test/helpers/search_column_helpers_test.rb +1 -1
- data/test/misc/active_record_permissions_test.rb +63 -50
- data/test/misc/attribute_params_test.rb +28 -26
- data/test/misc/calculation_test.rb +10 -3
- data/test/misc/configurable_test.rb +12 -13
- data/test/misc/constraints_test.rb +6 -6
- data/test/misc/convert_numbers_format_test.rb +7 -6
- data/test/misc/finder_test.rb +17 -12
- data/test/misc/lang_test.rb +3 -4
- data/test/misc/tableless_test.rb +2 -3
- data/test/mock_app/app/controllers/addresses_controller.rb +1 -1
- data/test/mock_app/app/controllers/buildings_controller.rb +1 -1
- data/test/mock_app/app/controllers/cars_controller.rb +1 -1
- data/test/mock_app/app/controllers/contacts_controller.rb +1 -1
- data/test/mock_app/app/controllers/people_controller.rb +1 -1
- data/test/mock_app/app/models/file_model.rb +2 -2
- data/test/mock_app/app/models/person.rb +1 -1
- data/test/mock_app/config/application.rb +3 -3
- data/test/mock_app/config/boot.rb +1 -1
- data/test/mock_app/config/environment.rb +1 -0
- data/test/mock_app/config/environments/development.rb +0 -1
- data/test/mock_app/config/environments/production.rb +1 -1
- data/test/mock_app/db/schema.rb +14 -15
- data/test/model_stub.rb +13 -16
- data/test/run_all.rb +5 -7
- data/test/test_helper.rb +12 -9
- 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__),
|
|
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 =
|
|
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
|
|
21
|
-
col_config =
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
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
|
-
|
|
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(
|
|
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
|
|
161
|
-
options[:style] = (options[:show].nil? || options[:show]) ? nil :
|
|
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
|
|
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
|
|
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__),
|
|
4
|
-
require File.join(File.dirname(__FILE__),
|
|
5
|
-
require File.join(File.dirname(__FILE__),
|
|
6
|
-
require File.join(File.dirname(__FILE__),
|
|
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
|
|
7
|
+
return unless model.respond_to?(:dragonfly_attachment_classes) && model.dragonfly_attachment_classes.present?
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
update.multipart = true
|
|
10
|
+
create.multipart = true
|
|
11
11
|
|
|
12
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
|
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(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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__),
|
|
7
|
-
require File.join(File.dirname(__FILE__),
|
|
8
|
-
require File.join(File.dirname(__FILE__),
|
|
9
|
-
require File.join(File.dirname(__FILE__),
|
|
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?(
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
17
|
-
|
|
16
|
+
model.generate_delete_helpers
|
|
17
|
+
|
|
18
18
|
# switch on multipart
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|