active_scaffold 3.0.26 → 3.1.3
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.
- data/CHANGELOG +1 -1
- data/{frontends/default → app/assets}/images/add.gif +0 -0
- data/{frontends/default → app/assets}/images/arrow_down.gif +0 -0
- data/{frontends/default → app/assets}/images/arrow_up.gif +0 -0
- data/{frontends/default → app/assets}/images/close.gif +0 -0
- data/{frontends/default → app/assets}/images/close_touch.png +0 -0
- data/{frontends/default → app/assets}/images/config.png +0 -0
- data/{frontends/default → app/assets}/images/cross.png +0 -0
- data/{frontends/default → app/assets}/images/gears.png +0 -0
- data/{frontends/default → app/assets}/images/indicator-small.gif +0 -0
- data/{frontends/default → app/assets}/images/indicator.gif +0 -0
- data/{frontends/default → app/assets}/images/magnifier.png +0 -0
- data/app/assets/javascripts/active_scaffold.js.erb +16 -0
- data/{frontends/default → app/assets}/javascripts/jquery/active_scaffold.js +16 -28
- data/app/assets/javascripts/jquery/active_scaffold.js~ +1036 -0
- data/{lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js → app/assets/javascripts/jquery/date_picker_bridge.js.erb} +3 -1
- data/{frontends/default → app/assets}/javascripts/jquery/jquery.editinplace.js +0 -0
- data/app/assets/javascripts/prototype/active_scaffold.js +1033 -0
- data/{frontends/default/javascripts/prototype/active_scaffold.js → app/assets/javascripts/prototype/active_scaffold.js~} +1 -0
- data/{frontends/default → app/assets}/javascripts/prototype/dhtml_history.js +0 -0
- data/{frontends/default → app/assets}/javascripts/prototype/form_enhancements.js +0 -0
- data/{frontends/default → app/assets}/javascripts/prototype/rico_corner.js +0 -0
- data/{frontends/default/stylesheets/stylesheet-ie.css → app/assets/stylesheets/active_scaffold-ie.css} +0 -0
- data/{frontends/default/stylesheets/stylesheet.css → app/assets/stylesheets/active_scaffold.css.erb} +29 -24
- data/{lib/active_scaffold/locale → config/locales}/de.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/en.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/es.yml +5 -0
- data/{lib/active_scaffold/locale → config/locales}/fr.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/hu.yml +13 -2
- data/{lib/active_scaffold/locale → config/locales}/ja.yml +9 -0
- data/{lib/active_scaffold/locale → config/locales}/ru.yml +3 -0
- data/frontends/default/views/_form.html.erb +1 -1
- data/frontends/default/views/_form_association.html.erb +1 -5
- data/frontends/default/views/_horizontal_subform.html.erb +7 -4
- data/frontends/default/views/_horizontal_subform.html.erb~ +2 -5
- data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
- data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
- data/frontends/default/views/_horizontal_subform_header.html.erb~ +1 -1
- data/frontends/default/views/_horizontal_subform_record.html.erb~ +1 -1
- data/frontends/default/views/_list_actions.html.erb +1 -1
- data/frontends/default/views/_list_messages.html.erb +1 -3
- data/frontends/default/views/_render_field.js.erb +20 -0
- data/frontends/default/views/_row.html.erb +3 -9
- data/frontends/default/views/_show.html.erb +2 -2
- data/frontends/default/views/add_existing.js.erb +20 -0
- data/frontends/default/views/destroy.js.erb +24 -0
- data/frontends/default/views/{edit_associated.js.rjs → edit_associated.js.erb} +3 -2
- data/frontends/default/views/form_messages.js.erb +1 -0
- data/frontends/default/views/list.js.erb +1 -0
- data/frontends/default/views/mark.js.rjs +6 -0
- data/frontends/default/views/on_action_update.js.erb +13 -0
- data/frontends/default/views/{on_create.js.erb~ → on_create.js.erb} +0 -0
- data/frontends/default/views/on_mark_all.js.erb +12 -0
- data/frontends/default/views/{on_update.js.erb~ → on_update.js.erb} +0 -0
- data/frontends/default/views/render_field.js.erb +1 -0
- data/frontends/default/views/search.html.erb +1 -1
- data/frontends/default/views/{update_column.js.erb~ → update_column.js.erb} +3 -3
- data/frontends/default/views/update_row.js.erb +1 -0
- data/lib/active_scaffold.rb +22 -46
- data/lib/active_scaffold/actions/core.rb +14 -6
- data/lib/active_scaffold/actions/core.rb~ +3 -3
- data/lib/active_scaffold/actions/create.rb +2 -5
- data/lib/active_scaffold/actions/create.rb~ +3 -2
- data/lib/active_scaffold/actions/delete.rb +1 -0
- data/lib/active_scaffold/actions/field_search.rb +1 -1
- data/lib/active_scaffold/actions/list.rb +10 -6
- data/lib/active_scaffold/actions/list.rb~ +3 -3
- data/lib/active_scaffold/actions/mark.rb +8 -8
- data/lib/active_scaffold/actions/nested.rb +2 -9
- data/lib/active_scaffold/actions/nested.rb~ +5 -7
- data/lib/active_scaffold/actions/search.rb +2 -1
- data/lib/active_scaffold/actions/subform.rb +1 -5
- data/lib/active_scaffold/actions/update.rb +1 -4
- data/lib/active_scaffold/actions/update.rb~ +5 -5
- data/lib/active_scaffold/attribute_params.rb +15 -26
- data/lib/active_scaffold/attribute_params.rb~ +1 -2
- data/lib/active_scaffold/bridges.rb +61 -0
- data/lib/active_scaffold/bridges/ancestry.rb +5 -0
- data/lib/active_scaffold/bridges/ancestry/{lib/ancestry_bridge.rb → ancestry_bridge.rb} +3 -3
- data/lib/active_scaffold/bridges/{calendar_date_select/bridge.rb → calendar_date_select.rb} +13 -5
- data/lib/active_scaffold/bridges/calendar_date_select/{lib/as_cds_bridge.rb → as_cds_bridge.rb} +4 -20
- data/lib/active_scaffold/bridges/cancan.rb +15 -0
- data/lib/active_scaffold/bridges/cancan/{lib/cancan_bridge.rb → cancan_bridge.rb} +2 -2
- data/lib/active_scaffold/bridges/carrierwave.rb +12 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +31 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +10 -0
- data/lib/active_scaffold/bridges/carrierwave/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/carrierwave/{lib/list_ui.rb → list_ui.rb} +1 -1
- data/lib/active_scaffold/bridges/country_helper.rb +9 -0
- data/lib/active_scaffold/bridges/country_helper/{lib/country_helper_bridge.rb → country_helper_bridge.rb} +5 -5
- data/lib/active_scaffold/bridges/date_picker.rb +23 -0
- data/lib/active_scaffold/bridges/date_picker/ext.rb +54 -0
- data/lib/active_scaffold/bridges/date_picker/helper.rb +188 -0
- data/lib/active_scaffold/bridges/dragonfly.rb +9 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +34 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +10 -0
- data/lib/active_scaffold/bridges/dragonfly/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/dragonfly/{lib/list_ui.rb → list_ui.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column.rb +11 -0
- data/lib/active_scaffold/bridges/file_column/{lib/as_file_column_bridge.rb → as_file_column_bridge.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +57 -0
- data/lib/active_scaffold/bridges/file_column/{lib/form_ui.rb → form_ui.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column/{lib/list_ui.rb → list_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/paperclip.rb +12 -0
- data/lib/active_scaffold/bridges/paperclip/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/paperclip/{lib/list_ui.rb → list_ui.rb} +3 -3
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +36 -0
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +24 -0
- data/lib/active_scaffold/bridges/record_select.rb +11 -0
- data/lib/active_scaffold/bridges/record_select/{lib/record_select_bridge.rb → helpers.rb} +5 -16
- data/lib/active_scaffold/bridges/record_select/helpers.rb~ +9 -14
- data/lib/active_scaffold/bridges/semantic_attributes.rb +5 -0
- data/lib/active_scaffold/bridges/semantic_attributes/{lib/semantic_attributes_bridge.rb → column.rb} +3 -3
- data/lib/active_scaffold/bridges/tiny_mce.rb +5 -0
- data/lib/active_scaffold/bridges/tiny_mce/{lib/tiny_mce_bridge.rb → helpers.rb} +16 -8
- data/lib/active_scaffold/config/base.rb +9 -1
- data/lib/active_scaffold/config/core.rb +1 -1
- data/lib/active_scaffold/config/create.rb +3 -10
- data/lib/active_scaffold/config/delete.rb +1 -2
- data/lib/active_scaffold/config/field_search.rb +1 -2
- data/lib/active_scaffold/config/form.rb +2 -6
- data/lib/active_scaffold/config/list.rb +8 -2
- data/lib/active_scaffold/config/nested.rb +2 -6
- data/lib/active_scaffold/config/search.rb +6 -2
- data/lib/active_scaffold/config/show.rb +1 -4
- data/lib/active_scaffold/config/subform.rb +1 -1
- data/lib/active_scaffold/config/update.rb +1 -6
- data/lib/active_scaffold/data_structures/action_columns.rb +3 -0
- data/lib/active_scaffold/data_structures/action_link.rb +14 -10
- data/lib/active_scaffold/data_structures/bridge.rb +22 -0
- data/lib/active_scaffold/data_structures/column.rb +36 -4
- data/lib/active_scaffold/data_structures/nested_info.rb +4 -4
- data/lib/active_scaffold/data_structures/set.rb +1 -6
- data/lib/active_scaffold/data_structures/sorting.rb +2 -2
- data/lib/active_scaffold/engine.rb +4 -0
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -2
- data/lib/active_scaffold/extensions/action_controller_rendering.rb~ +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +90 -93
- data/lib/active_scaffold/extensions/action_view_rendering.rb~ +1 -13
- data/lib/active_scaffold/extensions/active_association_reflection.rb +16 -7
- data/lib/active_scaffold/extensions/cache_association.rb +16 -0
- data/lib/active_scaffold/extensions/reverse_associations.rb +15 -13
- data/lib/active_scaffold/extensions/unsaved_associated.rb +1 -1
- data/lib/active_scaffold/finder.rb +40 -23
- data/lib/active_scaffold/finder.rb~ +3 -11
- data/lib/active_scaffold/helpers/association_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb +9 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb~ +12 -5
- data/lib/active_scaffold/helpers/form_column_helpers.rb +20 -21
- data/lib/active_scaffold/helpers/form_column_helpers.rb~ +2 -1
- data/lib/active_scaffold/helpers/id_helpers.rb +5 -5
- data/lib/active_scaffold/helpers/list_column_helpers.rb +14 -24
- data/lib/active_scaffold/helpers/list_column_helpers.rb~ +15 -20
- data/lib/active_scaffold/helpers/search_column_helpers.rb +10 -1
- data/lib/active_scaffold/helpers/search_column_helpers.rb~ +1 -1
- data/lib/active_scaffold/helpers/view_helpers.rb +14 -40
- data/lib/active_scaffold/helpers/view_helpers.rb~ +3 -3
- data/lib/active_scaffold/version.rb +2 -2
- data/lib/active_scaffold_env.rb +0 -2
- data/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
- data/test/bridges/bridge_test.rb +43 -0
- data/test/bridges/company.rb +81 -0
- data/test/bridges/paperclip_test.rb +68 -0
- data/test/bridges/tiny_mce_test.rb +27 -0
- data/test/bridges/unobtrusive_date_picker_test.rb +49 -0
- data/test/bridges/validation_reflection_test.rb +57 -0
- data/test/config/base_test.rb +1 -1
- data/test/config/core_test.rb +58 -0
- data/test/config/create_test.rb +8 -5
- data/test/config/delete_test.rb +33 -0
- data/test/config/field_search_test.rb +47 -0
- data/test/config/list_test.rb +64 -9
- data/test/config/nested_test.rb +62 -0
- data/test/config/search_test.rb +60 -0
- data/test/config/show_test.rb +5 -5
- data/test/config/subform_test.rb +17 -0
- data/test/config/update_test.rb +27 -4
- data/test/helpers/list_column_helpers_test.rb +16 -5
- data/test/helpers/pagination_helpers_test.rb +4 -0
- data/test/misc/attribute_params_test.rb +37 -1
- data/test/misc/finder_test.rb +0 -1
- data/test/misc/lang_test.rb +2 -3
- data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +2 -2
- data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +13 -7
- metadata +137 -154
- data/frontends/default/views/_list_with_header.html.erb~ +0 -32
- data/frontends/default/views/_render_field.js.rjs +0 -14
- data/frontends/default/views/_show.html.erb~ +0 -8
- data/frontends/default/views/_update_form.html.erb~ +0 -6
- data/frontends/default/views/add_existing.js.erb~ +0 -18
- data/frontends/default/views/add_existing.js.rjs +0 -17
- data/frontends/default/views/destroy.js.rjs +0 -23
- data/frontends/default/views/form_messages.js.rjs +0 -1
- data/frontends/default/views/list.js.rjs +0 -1
- data/frontends/default/views/on_action_update.js.rjs +0 -10
- data/frontends/default/views/on_create.js.rjs +0 -41
- data/frontends/default/views/on_mark_all.js.rjs +0 -12
- data/frontends/default/views/on_update.js.rjs +0 -28
- data/frontends/default/views/render_field.js.rjs +0 -1
- data/frontends/default/views/update_column.js.rjs +0 -13
- data/frontends/default/views/update_row.js.rjs +0 -1
- data/lib/active_scaffold.rb~ +0 -362
- data/lib/active_scaffold/bridges/ancestry/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/bridge.rb +0 -59
- data/lib/active_scaffold/bridges/cancan/bridge.rb +0 -12
- data/lib/active_scaffold/bridges/carrierwave/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +0 -33
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +0 -12
- data/lib/active_scaffold/bridges/country_helper/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/date_picker/bridge.rb +0 -24
- data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +0 -234
- data/lib/active_scaffold/bridges/dragonfly/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +0 -36
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +0 -12
- data/lib/active_scaffold/bridges/file_column/bridge.rb +0 -11
- data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +0 -59
- data/lib/active_scaffold/bridges/paperclip/bridge.rb +0 -12
- data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +0 -38
- data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +0 -26
- data/lib/active_scaffold/bridges/record_select/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/shared/date_bridge.rb~ +0 -209
- data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +0 -8
- data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +0 -21
- data/lib/active_scaffold/config/base.rb~ +0 -70
- data/lib/active_scaffold/config/nested.rb~ +0 -41
- data/lib/active_scaffold/constraints.rb~ +0 -186
- data/lib/active_scaffold/data_structures/action_link.rb~ +0 -179
- data/lib/active_scaffold/data_structures/nested_info.rb~ +0 -123
- data/lib/active_scaffold/extensions/action_view_resolver.rb +0 -7
- data/lib/active_scaffold/extensions/active_association_reflection.rb~ +0 -22
- data/lib/active_scaffold/extensions/unsaved_associated.rb~ +0 -62
- data/lib/active_scaffold_assets.rb +0 -45
- data/lib/generators/active_scaffold_setup/USAGE +0 -10
- data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +0 -59
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
ActiveScaffold::Bridges.bridge "FileColumn" do
|
|
2
|
-
install do
|
|
3
|
-
if ActiveScaffold::Config::Core.instance_methods.include?("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"
|
|
5
|
-
end
|
|
6
|
-
require File.join(File.dirname(__FILE__), "lib/as_file_column_bridge")
|
|
7
|
-
require File.join(File.dirname(__FILE__), "lib/form_ui")
|
|
8
|
-
require File.join(File.dirname(__FILE__), "lib/list_ui")
|
|
9
|
-
require File.join(File.dirname(__FILE__), "lib/file_column_helpers")
|
|
10
|
-
end
|
|
11
|
-
end
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Bridges
|
|
3
|
-
module Paperclip
|
|
4
|
-
module Lib
|
|
5
|
-
module FileColumnHelpers
|
|
6
|
-
class << self
|
|
7
|
-
def file_column_fields(klass)
|
|
8
|
-
klass.instance_methods.grep(/_just_uploaded\?$/).collect{|m| m[0..-16].to_sym }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def generate_delete_helpers(klass)
|
|
12
|
-
file_column_fields(klass).each { |field|
|
|
13
|
-
klass.send :class_eval, <<-EOF, __FILE__, __LINE__ + 1 unless klass.methods.include?("#{field}_with_delete=")
|
|
14
|
-
attr_reader :delete_#{field}
|
|
15
|
-
|
|
16
|
-
def delete_#{field}=(value)
|
|
17
|
-
value = (value=="true") if String===value
|
|
18
|
-
return unless value
|
|
19
|
-
|
|
20
|
-
# passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!
|
|
21
|
-
self.#{field} = nil unless self.#{field}_just_uploaded?
|
|
22
|
-
end
|
|
23
|
-
EOF
|
|
24
|
-
}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def klass_has_file_column_fields?(klass)
|
|
28
|
-
true unless file_column_fields(klass).empty?
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def file_column_fields
|
|
33
|
-
@file_column_fields||=FileColumnHelpers.file_column_fields(self)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def options_for_file_column_field(field)
|
|
37
|
-
self.allocate.send("#{field}_options")
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def field_has_image_version?(field, version="thumb")
|
|
41
|
-
begin
|
|
42
|
-
# the only way to get to the options of a particular field is to use the instance method
|
|
43
|
-
options = options_for_file_column_field(field)
|
|
44
|
-
versions = options[:magick][:versions]
|
|
45
|
-
raise unless versions.stringify_keys[version]
|
|
46
|
-
true
|
|
47
|
-
rescue
|
|
48
|
-
false
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def generate_delete_helpers
|
|
53
|
-
FileColumnHelpers.generate_delete_helpers(self)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
ActiveScaffold::Bridges.bridge "Paperclip" do
|
|
2
|
-
install do
|
|
3
|
-
if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_paperclip")
|
|
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
|
-
end
|
|
6
|
-
require File.join(File.dirname(__FILE__), "lib/form_ui")
|
|
7
|
-
require File.join(File.dirname(__FILE__), "lib/list_ui")
|
|
8
|
-
require File.join(File.dirname(__FILE__), "lib/paperclip_bridge_helpers")
|
|
9
|
-
require File.join(File.dirname(__FILE__), "lib/paperclip_bridge")
|
|
10
|
-
ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Paperclip::Lib::PaperclipBridge
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Bridges
|
|
3
|
-
module Paperclip
|
|
4
|
-
module Lib
|
|
5
|
-
module PaperclipBridge
|
|
6
|
-
def initialize_with_paperclip(model_id)
|
|
7
|
-
initialize_without_paperclip(model_id)
|
|
8
|
-
return unless self.model.respond_to?(:attachment_definitions) && !self.model.attachment_definitions.nil?
|
|
9
|
-
|
|
10
|
-
self.update.multipart = true
|
|
11
|
-
self.create.multipart = true
|
|
12
|
-
|
|
13
|
-
self.model.attachment_definitions.keys.each do |field|
|
|
14
|
-
configure_paperclip_field(field.to_sym)
|
|
15
|
-
# define the "delete" helper for use with active scaffold, unless it's already defined
|
|
16
|
-
ActiveScaffold::Bridges::Paperclip::Lib::PaperclipBridgeHelpers.generate_delete_helper(self.model, field)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.included(base)
|
|
21
|
-
base.alias_method_chain :initialize, :paperclip
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
def configure_paperclip_field(field)
|
|
26
|
-
self.columns << field
|
|
27
|
-
self.columns[field].form_ui ||= :paperclip
|
|
28
|
-
self.columns[field].params.add "delete_#{field}"
|
|
29
|
-
|
|
30
|
-
[:file_name, :content_type, :file_size, :updated_at].each do |f|
|
|
31
|
-
self.columns.exclude("#{field}_#{f}".to_sym)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Bridges
|
|
3
|
-
module Paperclip
|
|
4
|
-
module Lib
|
|
5
|
-
module PaperclipBridgeHelpers
|
|
6
|
-
mattr_accessor :thumbnail_style
|
|
7
|
-
self.thumbnail_style = :thumbnail
|
|
8
|
-
|
|
9
|
-
def self.generate_delete_helper(klass, field)
|
|
10
|
-
klass.class_eval <<-EOF, __FILE__, __LINE__ + 1 unless klass.methods.include?("delete_#{field}=")
|
|
11
|
-
attr_reader :delete_#{field}
|
|
12
|
-
|
|
13
|
-
def delete_#{field}=(value)
|
|
14
|
-
value = (value == "true") if String === value
|
|
15
|
-
return unless value
|
|
16
|
-
|
|
17
|
-
# passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!
|
|
18
|
-
self.#{field} = nil unless self.#{field}.dirty?
|
|
19
|
-
end
|
|
20
|
-
EOF
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Bridges
|
|
3
|
-
module Shared
|
|
4
|
-
module DateBridge
|
|
5
|
-
module SearchColumnHelpers
|
|
6
|
-
def active_scaffold_search_date_bridge(column, options)
|
|
7
|
-
current_search = {'from' => nil, 'to' => nil, 'opt' => 'BETWEEN',
|
|
8
|
-
'number' => 1, 'unit' => 'DAYS', 'range' => nil}
|
|
9
|
-
current_search.merge!(options[:value]) unless options[:value].nil?
|
|
10
|
-
tags = []
|
|
11
|
-
tags << active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
|
|
12
|
-
tags << active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
|
|
13
|
-
tags << active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
|
|
14
|
-
tags << active_scaffold_search_date_bridge_range_tag(column, options, current_search)
|
|
15
|
-
tags.join(" ").html_safe
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def active_scaffold_search_date_bridge_comparator_options(column)
|
|
19
|
-
select_options = ActiveScaffold::Finder::DateComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
|
|
20
|
-
select_options + ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
|
|
24
|
-
select_tag("#{options[:name]}[opt]", options_for_select(active_scaffold_search_date_bridge_comparator_options(column),current_search['opt']), :id => "#{options[:id]}_opt", :class => "as_search_range_option as_search_date_time_option")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
|
|
28
|
-
numeric_controls = "" <<
|
|
29
|
-
active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'from') <<
|
|
30
|
-
content_tag(:span, (" - " + active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'to')).html_safe,
|
|
31
|
-
:id => "#{options[:id]}_between", :class => "as_search_range_between", :style => "display:#{current_search['opt'] == 'BETWEEN' ? '' : 'none'}")
|
|
32
|
-
content_tag("span", numeric_controls.html_safe, :id => "#{options[:id]}_numeric", :style => "display:#{ActiveScaffold::Finder::NumericComparators.include?(current_search['opt']) ? '' : 'none'}")
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
|
|
36
|
-
active_scaffold_date_bridge_trend_tag(column, options,
|
|
37
|
-
{:name_prefix => 'search',
|
|
38
|
-
:number_value => current_search['number'],
|
|
39
|
-
:unit_value => current_search["unit"],
|
|
40
|
-
:show => (current_search['opt'] == 'PAST' || current_search['opt'] == 'FUTURE')})
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def active_scaffold_date_bridge_trend_tag(column, options, trend_options)
|
|
44
|
-
trend_controls = text_field_tag("#{trend_options[:name_prefix]}[#{column.name}][number]", trend_options[:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off') << " " <<
|
|
45
|
-
select_tag("#{trend_options[:name_prefix]}[#{column.name}][unit]",
|
|
46
|
-
options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:unit_value]),
|
|
47
|
-
:class => 'text-input')
|
|
48
|
-
content_tag("span", trend_controls.html_safe, :id => "#{options[:id]}_trend", :style => "display:#{trend_options[:show] ? '' : 'none'}")
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def active_scaffold_search_date_bridge_trend_units(column)
|
|
52
|
-
options = ActiveScaffold::Finder::DateUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]}
|
|
53
|
-
options = ActiveScaffold::Finder::TimeUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]} + options if column_datetime?(column)
|
|
54
|
-
options
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def active_scaffold_search_date_bridge_range_tag(column, options, current_search)
|
|
58
|
-
range_controls = select_tag("search[#{column.name}][range]",
|
|
59
|
-
options_for_select( ActiveScaffold::Finder::DateRanges.collect{|range| [as_(range.downcase.to_sym), range]}, current_search["range"]),
|
|
60
|
-
:class => 'text-input')
|
|
61
|
-
content_tag("span", range_controls.html_safe, :id => "#{options[:id]}_range", :style => "display:#{(current_search['opt'] == 'RANGE') ? '' : 'none'}")
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def column_datetime?(column)
|
|
65
|
-
(!column.column.nil? && [:datetime, :time].include?(column.column.type))
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
module HumanConditionHelpers
|
|
70
|
-
def active_scaffold_human_condition_date_bridge(column, value)
|
|
71
|
-
case value[:opt]
|
|
72
|
-
when 'RANGE'
|
|
73
|
-
range_type, range = value[:range].downcase.split('_')
|
|
74
|
-
format = active_scaffold_human_condition_date_bridge_range_format(range_type, range)
|
|
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)})"
|
|
77
|
-
when 'PAST', 'FUTURE'
|
|
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)}"
|
|
80
|
-
else
|
|
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) : ''}"
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def active_scaffold_human_condition_date_bridge_range_format(range_type, range)
|
|
87
|
-
case range
|
|
88
|
-
when 'week'
|
|
89
|
-
first_day_of_week = I18n.translate 'active_scaffold.date_picker_options.firstDay'
|
|
90
|
-
if first_day_of_week == 1
|
|
91
|
-
'%W %Y'
|
|
92
|
-
else
|
|
93
|
-
'%U %Y'
|
|
94
|
-
end
|
|
95
|
-
when 'month'
|
|
96
|
-
'%b %Y'
|
|
97
|
-
when 'year'
|
|
98
|
-
'%Y'
|
|
99
|
-
else
|
|
100
|
-
I18n.translate 'date.formats.default'
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
module Finder
|
|
106
|
-
module ClassMethods
|
|
107
|
-
def condition_for_date_bridge_type(column, value, like_pattern)
|
|
108
|
-
operator = ActiveScaffold::Finder::NumericComparators.include?(value[:opt]) && value[:opt] != 'BETWEEN' ? value[:opt] : nil
|
|
109
|
-
from_value, to_value = date_bridge_from_to(column, value)
|
|
110
|
-
|
|
111
|
-
if column.search_sql.is_a? Proc
|
|
112
|
-
column.search_sql.call(from_value, to_value, operator)
|
|
113
|
-
else
|
|
114
|
-
unless operator.nil?
|
|
115
|
-
["#{column.search_sql} #{value[:opt]} ?", from_value.to_s(:db)] unless from_value.nil?
|
|
116
|
-
else
|
|
117
|
-
["#{column.search_sql} BETWEEN ? AND ?", from_value.to_s(:db), to_value.to_s(:db)] unless from_value.nil? && to_value.nil?
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def date_bridge_from_to(column, value)
|
|
123
|
-
conversion = column.column.type == :date ? :to_date : :to_time
|
|
124
|
-
case value[:opt]
|
|
125
|
-
when 'RANGE'
|
|
126
|
-
date_bridge_from_to_for_range(column, value).collect(&conversion)
|
|
127
|
-
when 'PAST', 'FUTURE'
|
|
128
|
-
date_bridge_from_to_for_trend(column, value).collect(&conversion)
|
|
129
|
-
else
|
|
130
|
-
['from', 'to'].collect { |field| condition_value_for_datetime(value[field], conversion)}
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def date_bridge_now
|
|
135
|
-
Time.zone.now
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def date_bridge_from_to_for_trend(column, value)
|
|
139
|
-
case value['opt']
|
|
140
|
-
when "PAST"
|
|
141
|
-
trend_number = [value['number'].to_i, 1].max
|
|
142
|
-
now = date_bridge_now
|
|
143
|
-
if date_bridge_column_date?(column)
|
|
144
|
-
from = now.beginning_of_day.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
|
145
|
-
to = now.end_of_day
|
|
146
|
-
else
|
|
147
|
-
from = now.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
|
148
|
-
to = now
|
|
149
|
-
end
|
|
150
|
-
return from, to
|
|
151
|
-
when "FUTURE"
|
|
152
|
-
trend_number = [value['number'].to_i, 1].max
|
|
153
|
-
now = date_bridge_now
|
|
154
|
-
if date_bridge_column_date?(column)
|
|
155
|
-
from = now.beginning_of_day
|
|
156
|
-
to = now.end_of_day.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
|
157
|
-
else
|
|
158
|
-
from = now
|
|
159
|
-
to = now.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
|
160
|
-
end
|
|
161
|
-
return from, to
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def date_bridge_from_to_for_range(column, value)
|
|
166
|
-
case value[:range]
|
|
167
|
-
when 'TODAY'
|
|
168
|
-
return date_bridge_now.beginning_of_day, date_bridge_now.end_of_day
|
|
169
|
-
when 'YESTERDAY'
|
|
170
|
-
return date_bridge_now.ago(1.day).beginning_of_day, date_bridge_now.ago(1.day).end_of_day
|
|
171
|
-
when 'TOMORROW'
|
|
172
|
-
return date_bridge_now.in(1.day).beginning_of_day, date_bridge_now.in(1.day).end_of_day
|
|
173
|
-
else
|
|
174
|
-
range_type, range = value[:range].downcase.split('_')
|
|
175
|
-
raise ArgumentError unless ['week', 'month', 'year'].include?(range)
|
|
176
|
-
case range_type
|
|
177
|
-
when 'this'
|
|
178
|
-
return date_bridge_now.send("beginning_of_#{range}".to_sym), date_bridge_now.send("end_of_#{range}")
|
|
179
|
-
when 'prev'
|
|
180
|
-
return date_bridge_now.ago(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.ago(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
|
|
181
|
-
when 'next'
|
|
182
|
-
return date_bridge_now.in(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.in(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
|
|
183
|
-
else
|
|
184
|
-
return nil, nil
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
def date_bridge_column_date?(column)
|
|
190
|
-
if [:date_picker, :datetime_picker].include? column.form_ui
|
|
191
|
-
column.form_ui == :date_picker
|
|
192
|
-
else
|
|
193
|
-
(!column.column.nil? && [:date].include?(column.column.type))
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
ActiveScaffold::Finder.const_set('DateComparators', ["PAST", "FUTURE", "RANGE"])
|
|
204
|
-
ActiveScaffold::Finder.const_set('DateUnits', ["DAYS", "WEEKS", "MONTHS", "YEARS"])
|
|
205
|
-
ActiveScaffold::Finder.const_set('TimeUnits', ["SECONDS", "MINUTES", "HOURS"])
|
|
206
|
-
ActiveScaffold::Finder.const_set('DateRanges', ["TODAY", "YESTERDAY", "TOMORROW",
|
|
207
|
-
"THIS_WEEK", "PREV_WEEK", "NEXT_WEEK",
|
|
208
|
-
"THIS_MONTH", "PREV_MONTH", "NEXT_MONTH",
|
|
209
|
-
"THIS_YEAR", "PREV_YEAR", "NEXT_YEAR"])
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module ValidationReflectionBridge
|
|
3
|
-
def self.included(base)
|
|
4
|
-
base.class_eval { alias_method_chain :initialize, :validation_reflection }
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def initialize_with_validation_reflection(name, active_record_class)
|
|
8
|
-
initialize_without_validation_reflection(name, active_record_class)
|
|
9
|
-
column_names = [name]
|
|
10
|
-
column_names << @association.primary_key_name if @association
|
|
11
|
-
self.required = column_names.any? do |column_name|
|
|
12
|
-
active_record_class.reflect_on_validations_for(column_name.to_sym).any? do |val|
|
|
13
|
-
val.macro == :validates_presence_of or (val.macro == :validates_inclusion_of and not val.options[:allow_nil] and not val.options[:allow_blank])
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
ActiveScaffold::DataStructures::Column.class_eval do
|
|
20
|
-
include ActiveScaffold::ValidationReflectionBridge
|
|
21
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold::Config
|
|
2
|
-
class Base
|
|
3
|
-
include ActiveScaffold::Configurable
|
|
4
|
-
extend ActiveScaffold::Configurable
|
|
5
|
-
|
|
6
|
-
def initialize(core_config)
|
|
7
|
-
@core = core_config
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def self.inherited(subclass)
|
|
11
|
-
class << subclass
|
|
12
|
-
# the crud type of the action. possible values are :create, :read, :update, :delete, and nil.
|
|
13
|
-
# this is not a setting for the developer. it's self-description for the actions.
|
|
14
|
-
def crud_type; @crud_type; end
|
|
15
|
-
|
|
16
|
-
protected
|
|
17
|
-
|
|
18
|
-
def crud_type=(val)
|
|
19
|
-
raise ArgumentError, "unknown CRUD type #{val}" unless [:create, :read, :update, :delete].include?(val.to_sym)
|
|
20
|
-
@crud_type = val.to_sym
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# delegate
|
|
26
|
-
def crud_type; self.class.crud_type end
|
|
27
|
-
|
|
28
|
-
def label(model = @core.label(:count => 1))
|
|
29
|
-
@label.nil? ? model : as_(@label, :model => model)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
|
|
33
|
-
attr_accessor :user
|
|
34
|
-
|
|
35
|
-
# define a default action_group for this action
|
|
36
|
-
# e.g. 'members.crud'
|
|
37
|
-
class_attribute :action_group
|
|
38
|
-
|
|
39
|
-
# action_group this action should belong to
|
|
40
|
-
attr_accessor :action_group
|
|
41
|
-
|
|
42
|
-
class UserSettings
|
|
43
|
-
def initialize(conf, storage, params)
|
|
44
|
-
# the session hash relevant to this action
|
|
45
|
-
@session = storage
|
|
46
|
-
# all the request params
|
|
47
|
-
@params = params
|
|
48
|
-
# the configuration object for this action
|
|
49
|
-
@conf = conf
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def formats
|
|
54
|
-
@formats ||= []
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def formats=(val)
|
|
58
|
-
@formats=val
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
private
|
|
62
|
-
|
|
63
|
-
def columns=(val)
|
|
64
|
-
@columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
|
|
65
|
-
@columns.action = self
|
|
66
|
-
@columns.set_columns(@core.columns) if @columns.respond_to?(:set_columns)
|
|
67
|
-
@columns
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|