active_scaffold 3.0.26 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
File without changes
|
@@ -5,7 +5,7 @@ module ActiveScaffold
|
|
5
5
|
attachment = record.send("#{column.name}")
|
6
6
|
return nil unless attachment.present?
|
7
7
|
content = if attachment.image?
|
8
|
-
image_tag(attachment.thumb(column.options[:thumb] || ActiveScaffold::Bridges::Dragonfly::
|
8
|
+
image_tag(attachment.thumb(column.options[:thumb] || ActiveScaffold::Bridges::Dragonfly::DragonflyBridgeHelpers.thumbnail_style).url, :border => 0)
|
9
9
|
else
|
10
10
|
attachment.name
|
11
11
|
end
|
@@ -13,4 +13,4 @@ module ActiveScaffold
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ActiveScaffold::Bridges::FileColumn < ActiveScaffold::DataStructures::Bridge
|
2
|
+
def self.install
|
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__), "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
|
+
end
|
11
|
+
end
|
@@ -8,9 +8,9 @@ module ActiveScaffold::Config
|
|
8
8
|
def initialize_with_file_column(model_id)
|
9
9
|
initialize_without_file_column(model_id)
|
10
10
|
|
11
|
-
return unless ActiveScaffold::Bridges::
|
11
|
+
return unless ActiveScaffold::Bridges::FileColumn::FileColumnHelpers.klass_has_file_column_fields?(self.model)
|
12
12
|
|
13
|
-
self.model.send :extend, ActiveScaffold::Bridges::
|
13
|
+
self.model.send :extend, ActiveScaffold::Bridges::FileColumn::FileColumnHelpers
|
14
14
|
|
15
15
|
# include the "delete" helpers for use with active scaffold, unless they are already included
|
16
16
|
self.model.generate_delete_helpers
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Bridges
|
3
|
+
class FileColumn
|
4
|
+
module FileColumnHelpers
|
5
|
+
class << self
|
6
|
+
def file_column_fields(klass)
|
7
|
+
klass.instance_methods.grep(/_just_uploaded\?$/).collect{|m| m[0..-16].to_sym }
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate_delete_helpers(klass)
|
11
|
+
file_column_fields(klass).each { |field|
|
12
|
+
klass.send :class_eval, <<-EOF, __FILE__, __LINE__ + 1 unless klass.methods.include?("#{field}_with_delete=")
|
13
|
+
attr_reader :delete_#{field}
|
14
|
+
|
15
|
+
def delete_#{field}=(value)
|
16
|
+
value = (value=="true") if String===value
|
17
|
+
return unless value
|
18
|
+
|
19
|
+
# passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!
|
20
|
+
self.#{field} = nil unless self.#{field}_just_uploaded?
|
21
|
+
end
|
22
|
+
EOF
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def klass_has_file_column_fields?(klass)
|
27
|
+
true unless file_column_fields(klass).empty?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def file_column_fields
|
32
|
+
@file_column_fields||=FileColumnHelpers.file_column_fields(self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def options_for_file_column_field(field)
|
36
|
+
self.allocate.send("#{field}_options")
|
37
|
+
end
|
38
|
+
|
39
|
+
def field_has_image_version?(field, version="thumb")
|
40
|
+
begin
|
41
|
+
# the only way to get to the options of a particular field is to use the instance method
|
42
|
+
options = options_for_file_column_field(field)
|
43
|
+
versions = options[:magick][:versions]
|
44
|
+
raise unless versions.stringify_keys[version]
|
45
|
+
true
|
46
|
+
rescue
|
47
|
+
false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def generate_delete_helpers
|
52
|
+
FileColumnHelpers.generate_delete_helpers(self)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -15,7 +15,7 @@ module ActiveScaffold
|
|
15
15
|
content_tag(
|
16
16
|
:div,
|
17
17
|
get_column_value(@record, column) + " " +
|
18
|
-
|
18
|
+
custom_hidden_field_tag +
|
19
19
|
" | " +
|
20
20
|
content_tag(:a, as_(:remove_file), {:href => '#', :onclick => js_remove_file_code}),
|
21
21
|
{}
|
@@ -34,4 +34,4 @@ module ActiveScaffold
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ActiveScaffold::Bridges::Paperclip < ActiveScaffold::DataStructures::Bridge
|
2
|
+
def self.install
|
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__), "paperclip/form_ui")
|
7
|
+
require File.join(File.dirname(__FILE__), "paperclip/list_ui")
|
8
|
+
require File.join(File.dirname(__FILE__), "paperclip/paperclip_bridge_helpers")
|
9
|
+
require File.join(File.dirname(__FILE__), "paperclip/paperclip_bridge")
|
10
|
+
ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Paperclip::PaperclipBridge
|
11
|
+
end
|
12
|
+
end
|
File without changes
|
@@ -4,8 +4,8 @@ module ActiveScaffold
|
|
4
4
|
def active_scaffold_column_paperclip(column, record)
|
5
5
|
paperclip = record.send("#{column.name}")
|
6
6
|
return nil unless paperclip.file?
|
7
|
-
content = if paperclip.styles.include?(ActiveScaffold::Bridges::Paperclip::
|
8
|
-
image_tag(paperclip.url(ActiveScaffold::Bridges::Paperclip::
|
7
|
+
content = if paperclip.styles.include?(ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.thumbnail_style)
|
8
|
+
image_tag(paperclip.url(ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.thumbnail_style), :border => 0)
|
9
9
|
else
|
10
10
|
paperclip.original_filename
|
11
11
|
end
|
@@ -13,4 +13,4 @@ module ActiveScaffold
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
end
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Bridges
|
3
|
+
class Paperclip
|
4
|
+
module PaperclipBridge
|
5
|
+
def initialize_with_paperclip(model_id)
|
6
|
+
initialize_without_paperclip(model_id)
|
7
|
+
return unless self.model.respond_to?(:attachment_definitions) && !self.model.attachment_definitions.nil?
|
8
|
+
|
9
|
+
self.update.multipart = true
|
10
|
+
self.create.multipart = true
|
11
|
+
|
12
|
+
self.model.attachment_definitions.keys.each do |field|
|
13
|
+
configure_paperclip_field(field.to_sym)
|
14
|
+
# define the "delete" helper for use with active scaffold, unless it's already defined
|
15
|
+
ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.generate_delete_helper(self.model, field)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.included(base)
|
20
|
+
base.alias_method_chain :initialize, :paperclip
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def configure_paperclip_field(field)
|
25
|
+
self.columns << field
|
26
|
+
self.columns[field].form_ui ||= :paperclip
|
27
|
+
self.columns[field].params.add "delete_#{field}"
|
28
|
+
|
29
|
+
[:file_name, :content_type, :file_size, :updated_at].each do |f|
|
30
|
+
self.columns.exclude("#{field}_#{f}".to_sym)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Bridges
|
3
|
+
class Paperclip
|
4
|
+
module PaperclipBridgeHelpers
|
5
|
+
mattr_accessor :thumbnail_style
|
6
|
+
self.thumbnail_style = :thumbnail
|
7
|
+
|
8
|
+
def self.generate_delete_helper(klass, field)
|
9
|
+
klass.class_eval <<-EOF, __FILE__, __LINE__ + 1 unless klass.instance_methods.include?("delete_#{field}=")
|
10
|
+
attr_reader :delete_#{field}
|
11
|
+
|
12
|
+
def delete_#{field}=(value)
|
13
|
+
value = (value == "true") if String === value
|
14
|
+
return unless value
|
15
|
+
|
16
|
+
# passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!
|
17
|
+
self.#{field} = nil unless self.#{field}.dirty?
|
18
|
+
end
|
19
|
+
EOF
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ActiveScaffold::Bridges::RecordSelect < ActiveScaffold::DataStructures::Bridge
|
2
|
+
def self.install
|
3
|
+
require File.join(File.dirname(__FILE__), "record_select/helpers.rb")
|
4
|
+
end
|
5
|
+
def self.stylesheets
|
6
|
+
'record_select'
|
7
|
+
end
|
8
|
+
def self.javascripts
|
9
|
+
'record_select'
|
10
|
+
end
|
11
|
+
end
|
@@ -1,20 +1,9 @@
|
|
1
|
-
|
2
|
-
module
|
1
|
+
class ActiveScaffold::Bridges::RecordSelect
|
2
|
+
module Helpers
|
3
3
|
def self.included(base)
|
4
4
|
base.class_eval do
|
5
5
|
include FormColumnHelpers
|
6
6
|
include SearchColumnHelpers
|
7
|
-
include ViewHelpers
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
module ViewHelpers
|
12
|
-
def self.included(base)
|
13
|
-
base.alias_method_chain :active_scaffold_includes, :record_select
|
14
|
-
end
|
15
|
-
|
16
|
-
def active_scaffold_includes_with_record_select(*args)
|
17
|
-
active_scaffold_includes_without_record_select(*args) + record_select_includes
|
18
7
|
end
|
19
8
|
end
|
20
9
|
|
@@ -45,12 +34,12 @@ module ActiveScaffold
|
|
45
34
|
record_select_options = active_scaffold_input_text_options(
|
46
35
|
:controller => remote_controller,
|
47
36
|
:id => options[:id],
|
48
|
-
:class => options[:class]
|
37
|
+
:class => options[:class].gsub(/update_form/, '')
|
49
38
|
)
|
50
39
|
record_select_options.merge!(column.options)
|
51
40
|
if options['data-update_url']
|
52
41
|
record_select_options[:onchange] = %|function(id, label) {
|
53
|
-
ActiveScaffold.update_column(
|
42
|
+
ActiveScaffold.update_column(null, "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
|
54
43
|
}|
|
55
44
|
end
|
56
45
|
|
@@ -89,4 +78,4 @@ module ActiveScaffold
|
|
89
78
|
end
|
90
79
|
end
|
91
80
|
|
92
|
-
ActionView::Base.class_eval { include ActiveScaffold::
|
81
|
+
ActionView::Base.class_eval { include ActiveScaffold::Bridges::RecordSelect::Helpers }
|
@@ -16,8 +16,6 @@ class ActiveScaffold::Bridges::RecordSelect
|
|
16
16
|
active_scaffold_record_select(column, options, @record.send(column.name), multiple)
|
17
17
|
elsif column.plural_association?
|
18
18
|
active_scaffold_record_select(column, options, @record.send(column.name), true)
|
19
|
-
else
|
20
|
-
active_scaffold_record_select_autocomplete(column, options)
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
@@ -33,10 +31,17 @@ class ActiveScaffold::Bridges::RecordSelect
|
|
33
31
|
params.merge!({column.association.primary_key_name => ''})
|
34
32
|
end
|
35
33
|
|
36
|
-
record_select_options = active_scaffold_input_text_options(
|
37
|
-
:controller => remote_controller
|
34
|
+
record_select_options = active_scaffold_input_text_options(
|
35
|
+
:controller => remote_controller,
|
36
|
+
:id => options[:id],
|
37
|
+
:class => options[:class]
|
38
38
|
)
|
39
39
|
record_select_options.merge!(column.options)
|
40
|
+
if options['data-update_url']
|
41
|
+
record_select_options[:onchange] = %|function(id, label) {
|
42
|
+
ActiveScaffold.update_column(null, "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
|
43
|
+
}|
|
44
|
+
end
|
40
45
|
|
41
46
|
html = if multiple
|
42
47
|
record_multi_select_field(options[:name], value || [], record_select_options)
|
@@ -46,16 +51,6 @@ class ActiveScaffold::Bridges::RecordSelect
|
|
46
51
|
html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
|
47
52
|
html
|
48
53
|
end
|
49
|
-
|
50
|
-
def active_scaffold_record_select_autocomplete(column, options)
|
51
|
-
remote_controller = active_scaffold_controller_for(column.association.klass).controller_path
|
52
|
-
record_select_options = active_scaffold_input_text_options(options).merge(
|
53
|
-
:controller => remote_controller
|
54
|
-
)
|
55
|
-
html = record_select_autocomplete(options[:name], @record, record_select_options)
|
56
|
-
html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
|
57
|
-
html
|
58
|
-
end
|
59
54
|
end
|
60
55
|
|
61
56
|
module SearchColumnHelpers
|
data/lib/active_scaffold/bridges/semantic_attributes/{lib/semantic_attributes_bridge.rb → column.rb}
RENAMED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
module
|
1
|
+
class ActiveScaffold::Bridges::SemanticAttributes
|
2
|
+
module Column
|
3
3
|
def self.included(base)
|
4
4
|
base.class_eval { alias_method_chain :initialize, :semantic_attributes }
|
5
5
|
end
|
@@ -16,5 +16,5 @@ module ActiveScaffold
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
ActiveScaffold::DataStructures::Column.class_eval do
|
19
|
-
include ActiveScaffold::
|
19
|
+
include ActiveScaffold::Bridges::SemanticAttributes::Column
|
20
20
|
end
|
@@ -1,5 +1,13 @@
|
|
1
|
-
|
2
|
-
module
|
1
|
+
class ActiveScaffold::Bridges::TinyMce
|
2
|
+
module Helpers
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
include FormColumnHelpers
|
6
|
+
include SearchColumnHelpers
|
7
|
+
include ViewHelpers
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
3
11
|
module ViewHelpers
|
4
12
|
def active_scaffold_includes(*args)
|
5
13
|
if ActiveScaffold.js_framework == :jquery
|
@@ -28,11 +36,15 @@ ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
|
|
28
36
|
end
|
29
37
|
|
30
38
|
module FormColumnHelpers
|
39
|
+
def self.included(base)
|
40
|
+
base.alias_method_chain :onsubmit, :tiny_mce
|
41
|
+
end
|
42
|
+
|
31
43
|
def active_scaffold_input_text_editor(column, options)
|
32
44
|
options[:class] = "#{options[:class]} mceEditor #{column.options[:class]}".strip
|
33
45
|
html = []
|
34
46
|
html << send(override_input(:textarea), column, options)
|
35
|
-
html << javascript_tag("tinyMCE.execCommand('mceAddControl', false, '#{options[:id]}');") if request.xhr?
|
47
|
+
html << javascript_tag("tinyMCE.execCommand('mceAddControl', false, '#{options[:id]}');") if request.xhr? || params[:iframe]
|
36
48
|
html.join "\n"
|
37
49
|
end
|
38
50
|
|
@@ -54,8 +66,4 @@ ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
|
|
54
66
|
end
|
55
67
|
end
|
56
68
|
|
57
|
-
ActionView::Base.class_eval
|
58
|
-
include ActiveScaffold::TinyMceBridge::FormColumnHelpers
|
59
|
-
include ActiveScaffold::TinyMceBridge::SearchColumnHelpers
|
60
|
-
include ActiveScaffold::TinyMceBridge::ViewHelpers
|
61
|
-
end
|
69
|
+
ActionView::Base.class_eval { include ActiveScaffold::Bridges::TinyMce::Helpers }
|
@@ -3,6 +3,10 @@ module ActiveScaffold::Config
|
|
3
3
|
include ActiveScaffold::Configurable
|
4
4
|
extend ActiveScaffold::Configurable
|
5
5
|
|
6
|
+
def initialize(core_config)
|
7
|
+
@core = core_config
|
8
|
+
end
|
9
|
+
|
6
10
|
def self.inherited(subclass)
|
7
11
|
class << subclass
|
8
12
|
# the crud type of the action. possible values are :create, :read, :update, :delete, and nil.
|
@@ -21,12 +25,16 @@ module ActiveScaffold::Config
|
|
21
25
|
# delegate
|
22
26
|
def crud_type; self.class.crud_type end
|
23
27
|
|
28
|
+
def label(model = nil)
|
29
|
+
as_(@label, :model => model || @core.label(:count => 1))
|
30
|
+
end
|
31
|
+
|
24
32
|
# the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
|
25
33
|
attr_accessor :user
|
26
34
|
|
27
35
|
# define a default action_group for this action
|
28
36
|
# e.g. 'members.crud'
|
29
|
-
|
37
|
+
class_attribute :action_group
|
30
38
|
|
31
39
|
# action_group this action should belong to
|
32
40
|
attr_accessor :action_group
|
@@ -107,7 +107,7 @@ module ActiveScaffold::Config
|
|
107
107
|
|
108
108
|
def initialize(model_id)
|
109
109
|
# model_id is the only absolutely required configuration value. it is also not publicly accessible.
|
110
|
-
@model_id = model_id
|
110
|
+
@model_id = model_id
|
111
111
|
|
112
112
|
# inherit the actions list directly from the global level
|
113
113
|
@actions = self.class.actions.clone
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module ActiveScaffold::Config
|
2
2
|
class Create < ActiveScaffold::Config::Form
|
3
3
|
self.crud_type = :create
|
4
|
-
def initialize(
|
4
|
+
def initialize(core_config)
|
5
5
|
super
|
6
|
+
@label = :create_model
|
6
7
|
self.persistent = self.class.persistent
|
7
8
|
self.action_after_create = self.class.action_after_create
|
8
9
|
self.refresh_list = self.class.refresh_list
|
@@ -25,20 +26,12 @@ module ActiveScaffold::Config
|
|
25
26
|
|
26
27
|
# whether update form is opened after a create or not
|
27
28
|
cattr_accessor :action_after_create
|
28
|
-
@@action_after_create =
|
29
|
+
@@action_after_create = nil
|
29
30
|
|
30
31
|
# whether we should refresh list after create or not
|
31
32
|
cattr_accessor :refresh_list
|
32
33
|
@@refresh_list = false
|
33
34
|
|
34
|
-
# instance-level configuration
|
35
|
-
# ----------------------------
|
36
|
-
# the label= method already exists in the Form base class
|
37
|
-
def label(model = nil)
|
38
|
-
model ||= @core.label(:count => 1)
|
39
|
-
@label ? as_(@label) : as_(:create_model, :model => model)
|
40
|
-
end
|
41
|
-
|
42
35
|
# whether the form stays open after a create or not
|
43
36
|
attr_accessor :persistent
|
44
37
|
|