active_scaffold_vho 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +27 -0
- data/.document +5 -0
- data/CHANGELOG +179 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +20 -0
- data/MIT-LICENSE +20 -0
- data/README +63 -0
- data/Rakefile +53 -0
- data/frontends/default/images/add.gif +0 -0
- data/frontends/default/images/arrow_down.gif +0 -0
- data/frontends/default/images/arrow_up.gif +0 -0
- data/frontends/default/images/close.gif +0 -0
- data/frontends/default/images/config.png +0 -0
- data/frontends/default/images/cross.png +0 -0
- data/frontends/default/images/gears.png +0 -0
- data/frontends/default/images/indicator-small.gif +0 -0
- data/frontends/default/images/indicator.gif +0 -0
- data/frontends/default/images/magnifier.png +0 -0
- data/frontends/default/javascripts/jquery/active_scaffold.js +957 -0
- data/frontends/default/javascripts/jquery/jquery.editinplace.js +743 -0
- data/frontends/default/javascripts/prototype/active_scaffold.js +957 -0
- data/frontends/default/javascripts/prototype/dhtml_history.js +867 -0
- data/frontends/default/javascripts/prototype/form_enhancements.js +117 -0
- data/frontends/default/javascripts/prototype/rico_corner.js +370 -0
- data/frontends/default/stylesheets/stylesheet-ie.css +35 -0
- data/frontends/default/stylesheets/stylesheet.css +964 -0
- data/frontends/default/views/_action_group.html.erb +20 -0
- data/frontends/default/views/_add_existing_form.html.erb +30 -0
- data/frontends/default/views/_base_form.html.erb +45 -0
- data/frontends/default/views/_create_form.html.erb +8 -0
- data/frontends/default/views/_create_form_on_list.html.erb +6 -0
- data/frontends/default/views/_field_search.html.erb +32 -0
- data/frontends/default/views/_form.html.erb +24 -0
- data/frontends/default/views/_form_association.html.erb +14 -0
- data/frontends/default/views/_form_association_footer.html.erb +40 -0
- data/frontends/default/views/_form_attribute.html.erb +15 -0
- data/frontends/default/views/_form_hidden_attribute.html.erb +2 -0
- data/frontends/default/views/_form_messages.html.erb +5 -0
- data/frontends/default/views/_horizontal_subform.html.erb +19 -0
- data/frontends/default/views/_horizontal_subform_header.html.erb +10 -0
- data/frontends/default/views/_horizontal_subform_record.html.erb +37 -0
- data/frontends/default/views/_human_conditions.html.erb +1 -0
- data/frontends/default/views/_list.html.erb +18 -0
- data/frontends/default/views/_list_actions.html.erb +15 -0
- data/frontends/default/views/_list_calculations.html.erb +16 -0
- data/frontends/default/views/_list_column_headings.html.erb +12 -0
- data/frontends/default/views/_list_header.html.erb +10 -0
- data/frontends/default/views/_list_inline_adapter.html.erb +10 -0
- data/frontends/default/views/_list_messages.html.erb +32 -0
- data/frontends/default/views/_list_pagination.html.erb +11 -0
- data/frontends/default/views/_list_pagination_links.html.erb +9 -0
- data/frontends/default/views/_list_record.html.erb +14 -0
- data/frontends/default/views/_list_record_columns.html.erb +8 -0
- data/frontends/default/views/_list_with_header.html.erb +32 -0
- data/frontends/default/views/_messages.html.erb +10 -0
- data/frontends/default/views/_render_field.js.rjs +13 -0
- data/frontends/default/views/_row.html.erb +12 -0
- data/frontends/default/views/_search.html.erb +34 -0
- data/frontends/default/views/_search_attribute.html.erb +10 -0
- data/frontends/default/views/_show.html.erb +8 -0
- data/frontends/default/views/_show_columns.html.erb +15 -0
- data/frontends/default/views/_update_actions.html.erb +9 -0
- data/frontends/default/views/_update_form.html.erb +6 -0
- data/frontends/default/views/_vertical_subform.html.erb +12 -0
- data/frontends/default/views/_vertical_subform_record.html.erb +38 -0
- data/frontends/default/views/action_confirmation.html.erb +13 -0
- data/frontends/default/views/add_existing.js.rjs +17 -0
- data/frontends/default/views/add_existing_form.html.erb +5 -0
- data/frontends/default/views/create.html.erb +5 -0
- data/frontends/default/views/delete.html.erb +13 -0
- data/frontends/default/views/destroy.js.rjs +11 -0
- data/frontends/default/views/edit_associated.js.rjs +11 -0
- data/frontends/default/views/field_search.html.erb +5 -0
- data/frontends/default/views/form_messages.js.rjs +1 -0
- data/frontends/default/views/list.html.erb +1 -0
- data/frontends/default/views/list.js.rjs +1 -0
- data/frontends/default/views/on_action_update.js.rjs +8 -0
- data/frontends/default/views/on_create.js.rjs +41 -0
- data/frontends/default/views/on_update.js.rjs +28 -0
- data/frontends/default/views/search.html.erb +5 -0
- data/frontends/default/views/show.html.erb +5 -0
- data/frontends/default/views/update.html.erb +8 -0
- data/frontends/default/views/update_column.js.rjs +13 -0
- data/frontends/default/views/update_row.js.rjs +1 -0
- data/init.rb +9 -0
- data/lib/active_record_permissions.rb +134 -0
- data/lib/active_scaffold/actions/common_search.rb +22 -0
- data/lib/active_scaffold/actions/core.rb +170 -0
- data/lib/active_scaffold/actions/create.rb +145 -0
- data/lib/active_scaffold/actions/delete.rb +75 -0
- data/lib/active_scaffold/actions/field_search.rb +82 -0
- data/lib/active_scaffold/actions/list.rb +184 -0
- data/lib/active_scaffold/actions/mark.rb +50 -0
- data/lib/active_scaffold/actions/nested.rb +250 -0
- data/lib/active_scaffold/actions/search.rb +47 -0
- data/lib/active_scaffold/actions/show.rb +61 -0
- data/lib/active_scaffold/actions/subform.rb +17 -0
- data/lib/active_scaffold/actions/update.rb +141 -0
- data/lib/active_scaffold/attribute_params.rb +207 -0
- data/lib/active_scaffold/bridges/ancestry/bridge.rb +5 -0
- data/lib/active_scaffold/bridges/ancestry/lib/ancestry_bridge.rb +39 -0
- data/lib/active_scaffold/bridges/bridge.rb +52 -0
- data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +16 -0
- data/lib/active_scaffold/bridges/calendar_date_select/lib/as_cds_bridge.rb +79 -0
- data/lib/active_scaffold/bridges/carrierwave/bridge.rb +7 -0
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +38 -0
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +26 -0
- data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +35 -0
- data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +17 -0
- data/lib/active_scaffold/bridges/date_picker/bridge.rb +22 -0
- data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +225 -0
- data/lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js +22 -0
- data/lib/active_scaffold/bridges/file_column/bridge.rb +11 -0
- data/lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb +46 -0
- data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +59 -0
- data/lib/active_scaffold/bridges/file_column/lib/form_ui.rb +37 -0
- data/lib/active_scaffold/bridges/file_column/lib/list_ui.rb +26 -0
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
- data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +9 -0
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +15 -0
- data/lib/active_scaffold/bridges/paperclip/bridge.rb +10 -0
- data/lib/active_scaffold/bridges/paperclip/lib/form_ui.rb +27 -0
- data/lib/active_scaffold/bridges/paperclip/lib/list_ui.rb +16 -0
- data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +38 -0
- data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +26 -0
- data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +5 -0
- data/lib/active_scaffold/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb +20 -0
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +187 -0
- data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +5 -0
- data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +45 -0
- data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +8 -0
- data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +21 -0
- data/lib/active_scaffold/config/base.rb +62 -0
- data/lib/active_scaffold/config/core.rb +220 -0
- data/lib/active_scaffold/config/create.rb +51 -0
- data/lib/active_scaffold/config/delete.rb +34 -0
- data/lib/active_scaffold/config/field_search.rb +75 -0
- data/lib/active_scaffold/config/form.rb +47 -0
- data/lib/active_scaffold/config/list.rb +174 -0
- data/lib/active_scaffold/config/mark.rb +22 -0
- data/lib/active_scaffold/config/nested.rb +44 -0
- data/lib/active_scaffold/config/search.rb +69 -0
- data/lib/active_scaffold/config/show.rb +35 -0
- data/lib/active_scaffold/config/subform.rb +35 -0
- data/lib/active_scaffold/config/update.rb +46 -0
- data/lib/active_scaffold/configurable.rb +29 -0
- data/lib/active_scaffold/constraints.rb +184 -0
- data/lib/active_scaffold/data_structures/action_columns.rb +133 -0
- data/lib/active_scaffold/data_structures/action_link.rb +171 -0
- data/lib/active_scaffold/data_structures/action_links.rb +175 -0
- data/lib/active_scaffold/data_structures/actions.rb +45 -0
- data/lib/active_scaffold/data_structures/column.rb +351 -0
- data/lib/active_scaffold/data_structures/columns.rb +75 -0
- data/lib/active_scaffold/data_structures/error_message.rb +24 -0
- data/lib/active_scaffold/data_structures/nested_info.rb +123 -0
- data/lib/active_scaffold/data_structures/set.rb +62 -0
- data/lib/active_scaffold/data_structures/sorting.rb +168 -0
- data/lib/active_scaffold/finder.rb +333 -0
- data/lib/active_scaffold/helpers/association_helpers.rb +40 -0
- data/lib/active_scaffold/helpers/controller_helpers.rb +82 -0
- data/lib/active_scaffold/helpers/country_helpers.rb +352 -0
- data/lib/active_scaffold/helpers/form_column_helpers.rb +347 -0
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +59 -0
- data/lib/active_scaffold/helpers/id_helpers.rb +127 -0
- data/lib/active_scaffold/helpers/list_column_helpers.rb +361 -0
- data/lib/active_scaffold/helpers/pagination_helpers.rb +55 -0
- data/lib/active_scaffold/helpers/search_column_helpers.rb +243 -0
- data/lib/active_scaffold/helpers/show_column_helpers.rb +46 -0
- data/lib/active_scaffold/helpers/view_helpers.rb +356 -0
- data/lib/active_scaffold/locale/de.rb +120 -0
- data/lib/active_scaffold/locale/en.rb +119 -0
- data/lib/active_scaffold/locale/es.yml +115 -0
- data/lib/active_scaffold/locale/fr.rb +116 -0
- data/lib/active_scaffold/locale/hu.yml +63 -0
- data/lib/active_scaffold/locale/ja.yml +64 -0
- data/lib/active_scaffold/locale/ru.yml +119 -0
- data/lib/active_scaffold/marked_model.rb +38 -0
- data/lib/active_scaffold/version.rb +9 -0
- data/lib/active_scaffold.rb +345 -0
- data/lib/active_scaffold_assets.rb +45 -0
- data/lib/dhtml_confirm.rb +54 -0
- data/lib/environment.rb +14 -0
- data/lib/extensions/action_controller_rendering.rb +20 -0
- data/lib/extensions/action_view_rendering.rb +113 -0
- data/lib/extensions/action_view_resolver.rb +7 -0
- data/lib/extensions/active_association_reflection.rb +13 -0
- data/lib/extensions/active_record_offset.rb +12 -0
- data/lib/extensions/array.rb +7 -0
- data/lib/extensions/localize.rb +10 -0
- data/lib/extensions/name_option_for_datetime.rb +12 -0
- data/lib/extensions/nil_id_in_url_params.rb +7 -0
- data/lib/extensions/paginator_extensions.rb +26 -0
- data/lib/extensions/reverse_associations.rb +62 -0
- data/lib/extensions/routing_mapper.rb +34 -0
- data/lib/extensions/to_label.rb +8 -0
- data/lib/extensions/unsaved_associated.rb +61 -0
- data/lib/extensions/unsaved_record.rb +20 -0
- data/lib/extensions/usa_state.rb +46 -0
- data/lib/generators/active_scaffold/USAGE +29 -0
- data/lib/generators/active_scaffold/active_scaffold_generator.rb +20 -0
- data/lib/generators/active_scaffold_controller/USAGE +19 -0
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +28 -0
- data/lib/generators/active_scaffold_controller/templates/controller.rb +4 -0
- data/lib/generators/active_scaffold_setup/USAGE +10 -0
- data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +53 -0
- data/lib/paginator.rb +136 -0
- data/lib/responds_to_parent.rb +70 -0
- data/public/blank.html +33 -0
- data/shoulda_macros/macros.rb +136 -0
- data/test/bridges/bridge_test.rb +47 -0
- data/test/config/base_test.rb +15 -0
- data/test/config/create_test.rb +55 -0
- data/test/config/list_test.rb +74 -0
- data/test/config/show_test.rb +43 -0
- data/test/config/update_test.rb +17 -0
- data/test/const_mocker.rb +36 -0
- data/test/data_structures/action_columns_test.rb +113 -0
- data/test/data_structures/action_link_test.rb +78 -0
- data/test/data_structures/action_links_test.rb +78 -0
- data/test/data_structures/actions_test.rb +25 -0
- data/test/data_structures/association_column_test.rb +42 -0
- data/test/data_structures/column_test.rb +185 -0
- data/test/data_structures/columns_test.rb +69 -0
- data/test/data_structures/error_message_test.rb +28 -0
- data/test/data_structures/set_test.rb +86 -0
- data/test/data_structures/sorting_test.rb +126 -0
- data/test/data_structures/standard_column_test.rb +24 -0
- data/test/data_structures/virtual_column_test.rb +23 -0
- data/test/extensions/active_record_test.rb +45 -0
- data/test/extensions/array_test.rb +12 -0
- data/test/helpers/form_column_helpers_test.rb +31 -0
- data/test/helpers/list_column_helpers_test.rb +31 -0
- data/test/helpers/pagination_helpers_test.rb +55 -0
- data/test/misc/active_record_permissions_test.rb +154 -0
- data/test/misc/attribute_params_test.rb +110 -0
- data/test/misc/configurable_test.rb +96 -0
- data/test/misc/constraints_test.rb +193 -0
- data/test/misc/finder_test.rb +93 -0
- data/test/misc/lang_test.rb +12 -0
- data/test/mock_app/.gitignore +2 -0
- data/test/mock_app/app/controllers/application_controller.rb +10 -0
- data/test/mock_app/app/helpers/application_helper.rb +3 -0
- data/test/mock_app/config/boot.rb +110 -0
- data/test/mock_app/config/database.yml +16 -0
- data/test/mock_app/config/environment.rb +43 -0
- data/test/mock_app/config/environments/development.rb +17 -0
- data/test/mock_app/config/environments/production.rb +28 -0
- data/test/mock_app/config/environments/test.rb +28 -0
- data/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/mock_app/config/initializers/inflections.rb +10 -0
- data/test/mock_app/config/initializers/mime_types.rb +5 -0
- data/test/mock_app/config/initializers/new_rails_defaults.rb +19 -0
- data/test/mock_app/config/initializers/session_store.rb +15 -0
- data/test/mock_app/config/locales/en.yml +5 -0
- data/test/mock_app/config/routes.rb +43 -0
- data/test/mock_app/db/test.sqlite3 +1 -0
- data/test/mock_app/public/blank.html +33 -0
- data/test/mock_app/public/images/active_scaffold/DO_NOT_EDIT +2 -0
- data/test/mock_app/public/images/active_scaffold/default/add.gif +0 -0
- data/test/mock_app/public/images/active_scaffold/default/arrow_down.gif +0 -0
- data/test/mock_app/public/images/active_scaffold/default/arrow_up.gif +0 -0
- data/test/mock_app/public/images/active_scaffold/default/close.gif +0 -0
- data/test/mock_app/public/images/active_scaffold/default/cross.png +0 -0
- data/test/mock_app/public/images/active_scaffold/default/indicator-small.gif +0 -0
- data/test/mock_app/public/images/active_scaffold/default/indicator.gif +0 -0
- data/test/mock_app/public/images/active_scaffold/default/magnifier.png +0 -0
- data/test/mock_app/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
- data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +532 -0
- data/test/mock_app/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
- data/test/mock_app/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
- data/test/mock_app/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
- data/test/mock_app/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
- data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
- data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +839 -0
- data/test/model_stub.rb +55 -0
- data/test/run_all.rb +8 -0
- data/test/test_helper.rb +39 -0
- data/uninstall.rb +13 -0
- metadata +492 -0
@@ -0,0 +1,345 @@
|
|
1
|
+
unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 0
|
2
|
+
raise "This version of ActiveScaffold requires Rails 3.0 or higher. Please use an earlier version."
|
3
|
+
end
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'render_component'
|
7
|
+
rescue LoadError
|
8
|
+
end
|
9
|
+
begin
|
10
|
+
require 'verification'
|
11
|
+
rescue LoadError
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'active_record_permissions'
|
15
|
+
require 'dhtml_confirm'
|
16
|
+
require 'paginator'
|
17
|
+
require 'responds_to_parent'
|
18
|
+
|
19
|
+
require 'active_scaffold/version'
|
20
|
+
|
21
|
+
module ActiveScaffold
|
22
|
+
autoload :AttributeParams, 'active_scaffold/attribute_params'
|
23
|
+
autoload :Configurable, 'active_scaffold/configurable'
|
24
|
+
autoload :Constraints, 'active_scaffold/constraints'
|
25
|
+
autoload :Finder, 'active_scaffold/finder'
|
26
|
+
autoload :MarkedModel, 'active_scaffold/marked_model'
|
27
|
+
|
28
|
+
def self.active_scaffold_autoload_subdir(dir, mod=self)
|
29
|
+
Dir["#{File.dirname(__FILE__)}/active_scaffold/#{dir}/*.rb"].each { |file|
|
30
|
+
basename = File.basename(file, ".rb")
|
31
|
+
mod.module_eval {
|
32
|
+
autoload basename.camelcase.to_sym, "active_scaffold/#{dir}/#{basename}"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
module Actions
|
38
|
+
ActiveScaffold.active_scaffold_autoload_subdir('actions', self)
|
39
|
+
end
|
40
|
+
|
41
|
+
module Bridges
|
42
|
+
autoload :Bridge, 'active_scaffold/bridges/bridge'
|
43
|
+
end
|
44
|
+
|
45
|
+
module Config
|
46
|
+
ActiveScaffold.active_scaffold_autoload_subdir('config', self)
|
47
|
+
end
|
48
|
+
|
49
|
+
module DataStructures
|
50
|
+
ActiveScaffold.active_scaffold_autoload_subdir('data_structures', self)
|
51
|
+
end
|
52
|
+
|
53
|
+
module Helpers
|
54
|
+
ActiveScaffold.active_scaffold_autoload_subdir('helpers', self)
|
55
|
+
end
|
56
|
+
|
57
|
+
class ControllerNotFound < RuntimeError; end
|
58
|
+
class DependencyFailure < RuntimeError; end
|
59
|
+
class MalformedConstraint < RuntimeError; end
|
60
|
+
class RecordNotAllowed < SecurityError; end
|
61
|
+
class ActionNotAllowed < SecurityError; end
|
62
|
+
class ReverseAssociationRequired < RuntimeError; end
|
63
|
+
|
64
|
+
def self.included(base)
|
65
|
+
base.extend(ClassMethods)
|
66
|
+
base.module_eval do
|
67
|
+
# TODO: these should be in actions/core
|
68
|
+
before_filter :handle_user_settings
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.set_defaults(&block)
|
73
|
+
ActiveScaffold::Config::Core.configure &block
|
74
|
+
end
|
75
|
+
|
76
|
+
def active_scaffold_config
|
77
|
+
self.class.active_scaffold_config
|
78
|
+
end
|
79
|
+
|
80
|
+
def active_scaffold_config_for(klass)
|
81
|
+
self.class.active_scaffold_config_for(klass)
|
82
|
+
end
|
83
|
+
|
84
|
+
def active_scaffold_session_storage
|
85
|
+
id = params[:eid] || params[:controller]
|
86
|
+
session_index = "as:#{id}"
|
87
|
+
session[session_index] ||= {}
|
88
|
+
session[session_index]
|
89
|
+
end
|
90
|
+
|
91
|
+
# at some point we need to pass the session and params into config. we'll just take care of that before any particular action occurs by passing those hashes off to the UserSettings class of each action.
|
92
|
+
def handle_user_settings
|
93
|
+
if self.class.uses_active_scaffold?
|
94
|
+
active_scaffold_config.actions.each do |action_name|
|
95
|
+
conf_instance = active_scaffold_config.send(action_name) rescue next
|
96
|
+
next if conf_instance.class::UserSettings == ActiveScaffold::Config::Base::UserSettings # if it hasn't been extended, skip it
|
97
|
+
active_scaffold_session_storage[action_name] ||= {}
|
98
|
+
conf_instance.user = conf_instance.class::UserSettings.new(conf_instance, active_scaffold_session_storage[action_name], params)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.js_framework=(framework)
|
104
|
+
@@js_framework = framework
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.js_framework
|
108
|
+
@@js_framework ||= :prototype
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.root
|
112
|
+
File.dirname(__FILE__) + "/.."
|
113
|
+
end
|
114
|
+
|
115
|
+
module ClassMethods
|
116
|
+
def active_scaffold(model_id = nil, &block)
|
117
|
+
# initialize bridges here
|
118
|
+
ActiveScaffold::Bridges::Bridge.run_all
|
119
|
+
|
120
|
+
# converts Foo::BarController to 'bar' and FooBarsController to 'foo_bar' and AddressController to 'address'
|
121
|
+
model_id = self.to_s.split('::').last.sub(/Controller$/, '').pluralize.singularize.underscore unless model_id
|
122
|
+
|
123
|
+
# run the configuration
|
124
|
+
@active_scaffold_config = ActiveScaffold::Config::Core.new(model_id)
|
125
|
+
@active_scaffold_config_block = block
|
126
|
+
self.links_for_associations
|
127
|
+
|
128
|
+
@active_scaffold_overrides = []
|
129
|
+
ActionController::Base.view_paths.each do |dir|
|
130
|
+
active_scaffold_overrides_dir = File.join(dir.to_s,"active_scaffold_overrides")
|
131
|
+
@active_scaffold_overrides << active_scaffold_overrides_dir if File.exists?(active_scaffold_overrides_dir)
|
132
|
+
end
|
133
|
+
@active_scaffold_overrides.uniq! # Fix rails duplicating some view_paths
|
134
|
+
@active_scaffold_frontends = []
|
135
|
+
if active_scaffold_config.frontend.to_sym != :default
|
136
|
+
active_scaffold_custom_frontend_path = File.join(ActiveScaffold::Config::Core.plugin_directory, 'frontends', active_scaffold_config.frontend.to_s , 'views')
|
137
|
+
@active_scaffold_frontends << active_scaffold_custom_frontend_path
|
138
|
+
end
|
139
|
+
active_scaffold_default_frontend_path = File.join(ActiveScaffold::Config::Core.plugin_directory, 'frontends', 'default' , 'views')
|
140
|
+
@active_scaffold_frontends << active_scaffold_default_frontend_path
|
141
|
+
@active_scaffold_custom_paths = []
|
142
|
+
|
143
|
+
self.active_scaffold_superclasses_blocks.each {|superblock| self.active_scaffold_config.configure &superblock}
|
144
|
+
self.active_scaffold_config.sti_children = nil # reset sti_children if set in parent block
|
145
|
+
self.active_scaffold_config.configure &block if block_given?
|
146
|
+
self.active_scaffold_config._configure_sti unless self.active_scaffold_config.sti_children.nil?
|
147
|
+
self.active_scaffold_config._load_action_columns
|
148
|
+
|
149
|
+
# defines the attribute read methods on the model, so record.send() doesn't find protected/private methods instead
|
150
|
+
klass = self.active_scaffold_config.model
|
151
|
+
klass.define_attribute_methods unless klass.attribute_methods_generated?
|
152
|
+
# include the rest of the code into the controller: the action core and the included actions
|
153
|
+
module_eval do
|
154
|
+
include ActiveScaffold::Finder
|
155
|
+
include ActiveScaffold::Constraints
|
156
|
+
include ActiveScaffold::AttributeParams
|
157
|
+
include ActiveScaffold::Actions::Core
|
158
|
+
active_scaffold_config.actions.each do |mod|
|
159
|
+
name = mod.to_s.camelize
|
160
|
+
include "ActiveScaffold::Actions::#{name}".constantize
|
161
|
+
|
162
|
+
# sneak the action links from the actions into the main set
|
163
|
+
if link = active_scaffold_config.send(mod).link rescue nil
|
164
|
+
if link.is_a? Array
|
165
|
+
link.each {|current| active_scaffold_config.action_links.add_to_group(current, active_scaffold_config.send(mod).action_group)}
|
166
|
+
elsif link.is_a? ActiveScaffold::DataStructures::ActionLink
|
167
|
+
active_scaffold_config.action_links.add_to_group(link, active_scaffold_config.send(mod).action_group)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
active_scaffold_paths.each do |path|
|
173
|
+
self.append_view_path(ActionView::ActiveScaffoldResolver.new(path))
|
174
|
+
end
|
175
|
+
self._add_sti_create_links if self.active_scaffold_config.add_sti_create_links?
|
176
|
+
end
|
177
|
+
|
178
|
+
# To be called after include action modules
|
179
|
+
def _add_sti_create_links
|
180
|
+
new_action_link = active_scaffold_config.action_links.collection['new']
|
181
|
+
unless new_action_link.nil? || active_scaffold_config.sti_children.empty?
|
182
|
+
active_scaffold_config.action_links.collection.delete('new')
|
183
|
+
active_scaffold_config.sti_children.each do |child|
|
184
|
+
new_sti_link = Marshal.load(Marshal.dump(new_action_link)) # deep clone
|
185
|
+
new_sti_link.label = child.to_s.camelize.constantize.model_name.human
|
186
|
+
new_sti_link.parameters = {:parent_sti => controller_path}
|
187
|
+
new_sti_link.controller = Proc.new { active_scaffold_controller_for(child.to_s.camelize.constantize).controller_path }
|
188
|
+
active_scaffold_config.action_links.collection.create.add(new_sti_link)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Create the automatic column links. Note that this has to happen when configuration is *done*, because otherwise the Nested module could be disabled. Actually, it could still be disabled later, couldn't it?
|
194
|
+
def links_for_associations
|
195
|
+
return unless active_scaffold_config.actions.include? :list and active_scaffold_config.actions.include? :nested
|
196
|
+
active_scaffold_config.columns.each do |column|
|
197
|
+
next unless column.link.nil? and column.autolink?
|
198
|
+
#lazy load of action_link, cause it was really slowing down app in dev mode
|
199
|
+
#and might lead to trouble cause of cyclic constantization of controllers
|
200
|
+
#and might be unnecessary cause it is done before columns are configured
|
201
|
+
column.set_link(Proc.new {|col| link_for_association(col)})
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def link_for_association(column, options = {})
|
206
|
+
begin
|
207
|
+
controller = if column.polymorphic_association?
|
208
|
+
:polymorph
|
209
|
+
elsif options.include?(:controller)
|
210
|
+
"#{options[:controller].to_s.camelize}Controller".constantize
|
211
|
+
else
|
212
|
+
active_scaffold_controller_for(column.association.klass)
|
213
|
+
end
|
214
|
+
rescue ActiveScaffold::ControllerNotFound
|
215
|
+
controller = nil
|
216
|
+
end
|
217
|
+
|
218
|
+
unless controller.nil?
|
219
|
+
options.reverse_merge! :label => column.label, :position => :after, :type => :member, :controller => (controller == :polymorph ? controller : controller.controller_path), :column => column
|
220
|
+
options[:parameters] ||= {}
|
221
|
+
options[:parameters].reverse_merge! :parent_scaffold => controller_path, :association => column.association.name
|
222
|
+
if column.plural_association?
|
223
|
+
# note: we can't create nested scaffolds on :through associations because there's no reverse association.
|
224
|
+
|
225
|
+
ActiveScaffold::DataStructures::ActionLink.new('index', options) #unless column.through_association?
|
226
|
+
else
|
227
|
+
actions = [:create, :update, :show]
|
228
|
+
actions = controller.active_scaffold_config.actions unless controller == :polymorph
|
229
|
+
column.actions_for_association_links.delete :new unless actions.include? :create
|
230
|
+
column.actions_for_association_links.delete :edit unless actions.include? :update
|
231
|
+
column.actions_for_association_links.delete :show unless actions.include? :show
|
232
|
+
ActiveScaffold::DataStructures::ActionLink.new(:none, options.merge({:crud_type => nil, :html_options => {:class => column.name}}))
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def link_for_association_as_scope(scope, options = {})
|
238
|
+
options.reverse_merge! :label => scope, :position => :after, :type => :member, :controller => controller_path
|
239
|
+
options[:parameters] ||= {}
|
240
|
+
options[:parameters].reverse_merge! :parent_scaffold => controller_path, :named_scope => scope
|
241
|
+
ActiveScaffold::DataStructures::ActionLink.new('index', options)
|
242
|
+
end
|
243
|
+
|
244
|
+
def add_active_scaffold_path(path)
|
245
|
+
@active_scaffold_paths = nil # Force active_scaffold_paths to rebuild
|
246
|
+
@active_scaffold_custom_paths << path
|
247
|
+
end
|
248
|
+
|
249
|
+
def add_active_scaffold_override_path(path)
|
250
|
+
@active_scaffold_paths = nil # Force active_scaffold_paths to rebuild
|
251
|
+
@active_scaffold_overrides.unshift path
|
252
|
+
end
|
253
|
+
|
254
|
+
def active_scaffold_paths
|
255
|
+
return @active_scaffold_paths unless @active_scaffold_paths.nil?
|
256
|
+
|
257
|
+
#@active_scaffold_paths = ActionView::PathSet.new
|
258
|
+
@active_scaffold_paths = []
|
259
|
+
@active_scaffold_paths.concat @active_scaffold_overrides unless @active_scaffold_overrides.nil?
|
260
|
+
@active_scaffold_paths.concat @active_scaffold_custom_paths unless @active_scaffold_custom_paths.nil?
|
261
|
+
@active_scaffold_paths.concat @active_scaffold_frontends unless @active_scaffold_frontends.nil?
|
262
|
+
@active_scaffold_paths
|
263
|
+
end
|
264
|
+
|
265
|
+
def active_scaffold_config
|
266
|
+
if @active_scaffold_config.nil?
|
267
|
+
self.superclass.active_scaffold_config if self.superclass.respond_to? :active_scaffold_config
|
268
|
+
else
|
269
|
+
@active_scaffold_config
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def active_scaffold_config_block
|
274
|
+
@active_scaffold_config_block
|
275
|
+
end
|
276
|
+
|
277
|
+
def active_scaffold_superclasses_blocks
|
278
|
+
blocks = []
|
279
|
+
klass = self.superclass
|
280
|
+
while klass.respond_to? :active_scaffold_superclasses_blocks
|
281
|
+
blocks << klass.active_scaffold_config_block
|
282
|
+
klass = klass.superclass
|
283
|
+
end
|
284
|
+
blocks.compact.reverse
|
285
|
+
end
|
286
|
+
|
287
|
+
def active_scaffold_config_for(klass)
|
288
|
+
begin
|
289
|
+
controller = active_scaffold_controller_for(klass)
|
290
|
+
rescue ActiveScaffold::ControllerNotFound
|
291
|
+
config = ActiveScaffold::Config::Core.new(klass)
|
292
|
+
config._load_action_columns
|
293
|
+
config
|
294
|
+
else
|
295
|
+
controller.active_scaffold_config
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
# Tries to find a controller for the given ActiveRecord model.
|
300
|
+
# Searches in the namespace of the current controller for singular and plural versions of the conventional "#{model}Controller" syntax.
|
301
|
+
# You may override this method to customize the search routine.
|
302
|
+
def active_scaffold_controller_for(klass)
|
303
|
+
controller_namespace = self.to_s.split('::')[0...-1].join('::') + '::'
|
304
|
+
error_message = []
|
305
|
+
[controller_namespace, ''].each do |namespace|
|
306
|
+
["#{klass.to_s.underscore.pluralize}", "#{klass.to_s.underscore.pluralize.singularize}"].each do |controller_name|
|
307
|
+
begin
|
308
|
+
controller = "#{namespace}#{controller_name.camelize}Controller".constantize
|
309
|
+
rescue NameError => error
|
310
|
+
# Only rescue NameError associated with the controller constant not existing - not other compile errors
|
311
|
+
if error.message["uninitialized constant #{controller}"]
|
312
|
+
error_message << "#{namespace}#{controller_name.camelize}Controller"
|
313
|
+
next
|
314
|
+
else
|
315
|
+
raise
|
316
|
+
end
|
317
|
+
end
|
318
|
+
raise ActiveScaffold::ControllerNotFound, "#{controller} missing ActiveScaffold", caller unless controller.uses_active_scaffold?
|
319
|
+
raise ActiveScaffold::ControllerNotFound, "ActiveScaffold on #{controller} is not for #{klass} model.", caller unless controller.active_scaffold_config.model == klass
|
320
|
+
return controller
|
321
|
+
end
|
322
|
+
end
|
323
|
+
raise ActiveScaffold::ControllerNotFound, "Could not find " + error_message.join(" or "), caller
|
324
|
+
end
|
325
|
+
|
326
|
+
def uses_active_scaffold?
|
327
|
+
!active_scaffold_config.nil?
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
require 'environment'
|
333
|
+
|
334
|
+
##
|
335
|
+
## Run the install assets script, too, just to make sure
|
336
|
+
## But at least rescue the action in production
|
337
|
+
##
|
338
|
+
Rails::Application.initializer("active_scaffold.install_assets") do
|
339
|
+
begin
|
340
|
+
ActiveScaffoldAssets.copy_to_public(ActiveScaffold.root, {:clean_up_destination => true})
|
341
|
+
rescue
|
342
|
+
raise $! unless Rails.env == 'production'
|
343
|
+
end
|
344
|
+
end unless defined?(ACTIVE_SCAFFOLD_PLUGIN) && ACTIVE_SCAFFOLD_PLUGIN == true
|
345
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class ActiveScaffoldAssets
|
2
|
+
|
3
|
+
def self.copy_to_public(from, options = {})
|
4
|
+
unless defined?(ACTIVE_SCAFFOLD_INSTALL_ASSETS) && ACTIVE_SCAFFOLD_INSTALL_ASSETS == false
|
5
|
+
copy_files("/public", "/public", from)
|
6
|
+
available_frontends = Dir[File.join(from, 'frontends', '*')].collect { |d| File.basename d }
|
7
|
+
[:stylesheets, :javascripts, :images].each do |asset_type|
|
8
|
+
copy_asset_type(from, available_frontends, asset_type, options)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def self.copy_asset_type(from, available_frontends, asset_type, options = {})
|
16
|
+
path = "/public/#{asset_type}/active_scaffold"
|
17
|
+
copy_files(path, path, from)
|
18
|
+
|
19
|
+
File.open(File.join(Rails.root, path, 'DO_NOT_EDIT'), 'w') do |f|
|
20
|
+
f.puts "Any changes made to files in sub-folders will be lost."
|
21
|
+
f.puts "See http://activescaffold.com/tutorials/faq#custom-css."
|
22
|
+
end
|
23
|
+
|
24
|
+
available_frontends.each do |frontend|
|
25
|
+
if asset_type == :javascripts
|
26
|
+
file_mask = '*.js'
|
27
|
+
source = "/frontends/#{frontend}/#{asset_type}/#{ActiveScaffold.js_framework}"
|
28
|
+
else
|
29
|
+
file_mask = '*.*'
|
30
|
+
source = "/frontends/#{frontend}/#{asset_type}"
|
31
|
+
end
|
32
|
+
destination = "/public/#{asset_type}/active_scaffold/#{frontend}"
|
33
|
+
copy_files(source, destination, from, file_mask, options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.copy_files(source_path, destination_path, directory, file_mask = '*.*', options = {})
|
38
|
+
source, destination = File.join(directory, source_path), File.join(Rails.root, destination_path)
|
39
|
+
FileUtils.mkdir_p(destination) unless File.exist?(destination)
|
40
|
+
Dir.glob('*.so')
|
41
|
+
|
42
|
+
FileUtils.rm Dir.glob("#{destination}/*") if options[:clean_up_destination]
|
43
|
+
FileUtils.cp_r(Dir.glob("#{source}/#{file_mask}"), destination)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Matt Mower <matt@cominded.com>
|
2
|
+
#
|
3
|
+
# A base class for creating DHTML confirmation types.
|
4
|
+
#
|
5
|
+
# The real work is done by the onclick_function and onclick_handler methods. In
|
6
|
+
# general it should only be required to override the default onclick_handler
|
7
|
+
# method and provide the specific Javascript required to invoke the DHTML confirm
|
8
|
+
# dialog of your choice.
|
9
|
+
#
|
10
|
+
# It is up to this dialog, if the user confirms the intended action, to invoke
|
11
|
+
# the function window.gFireModalLink() to trigger the intended action of the link.
|
12
|
+
# For example, using the Modalbox library, you would use something like:
|
13
|
+
#
|
14
|
+
# Modalbox.hide( {
|
15
|
+
# afterHide: function() {
|
16
|
+
# window.gFireModalLink();
|
17
|
+
# } } );
|
18
|
+
#
|
19
|
+
# By default the only action recognized is :value which is used to add a
|
20
|
+
# dhtml_confirm attribute to the link <a> tag. This value is detected by the
|
21
|
+
# ActiveScaffold link and triggers the DHTML confirmation logic.
|
22
|
+
#
|
23
|
+
class DHTMLConfirm
|
24
|
+
attr_accessor :value, :message, :options
|
25
|
+
|
26
|
+
def initialize( options = {} )
|
27
|
+
@options = options
|
28
|
+
@value = @options.delete(:value) { |key| "yes" }
|
29
|
+
@message = @options.delete(:message) { |key| "Are you sure?" }
|
30
|
+
end
|
31
|
+
|
32
|
+
def onclick_function( controller, link_id )
|
33
|
+
script = <<-END
|
34
|
+
window.gFireModalLink = function() {
|
35
|
+
var link = $('#{link_id}').action_link;
|
36
|
+
link.open_action.call( link );
|
37
|
+
};
|
38
|
+
#{ensure_termination(onclick_handler(controller,link_id))}
|
39
|
+
return false;
|
40
|
+
END
|
41
|
+
# script = "window.gModalLink = $('#{link_id}').action_link;#{onclick_handler(controller,link_id)}return false;"
|
42
|
+
end
|
43
|
+
|
44
|
+
def onclick_handler( controller, link_id )
|
45
|
+
""
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
def ensure_termination( expression )
|
50
|
+
expression =~ /;$/ ? expression : "#{expression};"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
data/lib/environment.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# TODO: clean up extensions. some could be organized for autoloading, and others could be removed entirely.
|
2
|
+
Dir["#{File.dirname __FILE__}/extensions/*.rb"].each { |file| require file }
|
3
|
+
|
4
|
+
ActionController::Base.send(:include, ActiveScaffold)
|
5
|
+
ActionController::Base.send(:include, RespondsToParent)
|
6
|
+
ActionController::Base.send(:include, ActiveScaffold::Helpers::ControllerHelpers)
|
7
|
+
ActionView::Base.send(:include, ActiveScaffold::Helpers::ViewHelpers)
|
8
|
+
|
9
|
+
ActionController::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Controller}
|
10
|
+
ActiveRecord::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Model}
|
11
|
+
ActiveRecord::Base.class_eval {include ActiveRecordPermissions::Permissions}
|
12
|
+
|
13
|
+
I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'active_scaffold', 'locale', '*.{rb,yml}')]
|
14
|
+
#ActiveScaffold.js_framework = :jquery
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# wrap the action rendering for ActiveScaffold controllers
|
2
|
+
module ActionController #:nodoc:
|
3
|
+
class Base
|
4
|
+
def render_with_active_scaffold(*args, &block)
|
5
|
+
if self.class.uses_active_scaffold? and params[:adapter] and @rendering_adapter.nil?
|
6
|
+
@rendering_adapter = true # recursion control
|
7
|
+
# if we need an adapter, then we render the actual stuff to a string and insert it into the adapter template
|
8
|
+
render :partial => params[:adapter][1..-1],
|
9
|
+
:locals => {:payload => render_to_string(args.first.merge(:layout => false), &block)},
|
10
|
+
:use_full_path => true, :layout => false
|
11
|
+
@rendering_adapter = nil # recursion control
|
12
|
+
else
|
13
|
+
render_without_active_scaffold(*args, &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
alias_method_chain :render, :active_scaffold
|
17
|
+
|
18
|
+
# Rails 2.x implementation is post-initialization on :active_scaffold method
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module ActionView
|
2
|
+
class LookupContext
|
3
|
+
module ViewPaths
|
4
|
+
def find_all_templates(name, prefix = nil, partial = false)
|
5
|
+
templates = []
|
6
|
+
@view_paths.each do |resolver|
|
7
|
+
template = resolver.find_all(*args_for_lookup(name, prefix, partial)).first
|
8
|
+
templates << template unless template.nil?
|
9
|
+
end
|
10
|
+
templates
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# wrap the action rendering for ActiveScaffold views
|
17
|
+
module ActionView::Rendering #:nodoc:
|
18
|
+
# Adds two rendering options.
|
19
|
+
#
|
20
|
+
# ==render :super
|
21
|
+
#
|
22
|
+
# This syntax skips all template overrides and goes directly to the provided ActiveScaffold templates.
|
23
|
+
# Useful if you want to wrap an existing template. Just call super!
|
24
|
+
#
|
25
|
+
# ==render :active_scaffold => #{controller.to_s}, options = {}+
|
26
|
+
#
|
27
|
+
# Lets you embed an ActiveScaffold by referencing the controller where it's configured.
|
28
|
+
#
|
29
|
+
# You may specify options[:constraints] for the embedded scaffold. These constraints have three effects:
|
30
|
+
# * the scaffold's only displays records matching the constraint
|
31
|
+
# * all new records created will be assigned the constrained values
|
32
|
+
# * constrained columns will be hidden (they're pretty boring at this point)
|
33
|
+
#
|
34
|
+
# You may also specify options[:conditions] for the embedded scaffold. These only do 1/3 of what
|
35
|
+
# constraints do (they only limit search results). Any format accepted by ActiveRecord::Base.find is valid.
|
36
|
+
#
|
37
|
+
# Defining options[:label] lets you completely customize the list title for the embedded scaffold.
|
38
|
+
#
|
39
|
+
def render_with_active_scaffold(*args, &block)
|
40
|
+
if args.first == :super
|
41
|
+
options = args[1] || {}
|
42
|
+
options[:locals] ||= {}
|
43
|
+
options[:locals].reverse_merge!(@last_view[:locals] || {})
|
44
|
+
if @last_view[:templates].nil?
|
45
|
+
@last_view[:templates] = lookup_context.find_all_templates(@last_view[:view], controller_path, !@last_view[:is_template])
|
46
|
+
@last_view[:templates].shift
|
47
|
+
end
|
48
|
+
options[:template] = @last_view[:templates].shift
|
49
|
+
render_without_active_scaffold options
|
50
|
+
elsif args.first.is_a?(Hash) and args.first[:active_scaffold]
|
51
|
+
require 'digest/md5'
|
52
|
+
options = args.first
|
53
|
+
|
54
|
+
remote_controller = options[:active_scaffold]
|
55
|
+
constraints = options[:constraints]
|
56
|
+
conditions = options[:conditions]
|
57
|
+
eid = Digest::MD5.hexdigest(params[:controller] + remote_controller.to_s + constraints.to_s + conditions.to_s)
|
58
|
+
session["as:#{eid}"] = {:constraints => constraints, :conditions => conditions, :list => {:label => args.first[:label]}}
|
59
|
+
options[:params] ||= {}
|
60
|
+
options[:params].merge! :eid => eid, :embedded => true
|
61
|
+
|
62
|
+
id = "as_#{eid}-content"
|
63
|
+
url_options = {:controller => remote_controller.to_s, :action => 'index'}.merge(options[:params])
|
64
|
+
|
65
|
+
if respond_to? :render_component
|
66
|
+
render_component url_options
|
67
|
+
else
|
68
|
+
content_tag(:div, {:id => id}) do
|
69
|
+
url = url_for(url_options)
|
70
|
+
link_to(remote_controller.to_s, url, {:remote => true, :id => id}) <<
|
71
|
+
if ActiveScaffold.js_framework == :prototype
|
72
|
+
javascript_tag("new Ajax.Updater('#{id}', '#{url}', {method: 'get', evalScripts: true});")
|
73
|
+
elsif ActiveScaffold.js_framework == :jquery
|
74
|
+
javascript_tag("$('##{id}').load('#{url}');")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
else
|
80
|
+
options = args.first
|
81
|
+
if options.is_a?(Hash)
|
82
|
+
@last_view = {:view => options[:partial], :is_template => false} if options[:partial]
|
83
|
+
@last_view = {:view => options[:template], :is_template => !!options[:template]} if @last_view.nil? && options[:template]
|
84
|
+
@last_view[:locals] = options[:locals] if !@last_view.nil? && options[:locals]
|
85
|
+
end
|
86
|
+
render_without_active_scaffold(*args, &block)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
alias_method_chain :render, :active_scaffold
|
90
|
+
|
91
|
+
|
92
|
+
def partial_pieces(partial_path)
|
93
|
+
if partial_path.include?('/')
|
94
|
+
return File.dirname(partial_path), File.basename(partial_path)
|
95
|
+
else
|
96
|
+
return controller.class.controller_path, partial_path
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# This is the template finder logic, keep it updated with however we find stuff in rails
|
101
|
+
# currently this very similar to the logic in ActionBase::Base.render for options file
|
102
|
+
# TODO: Work with rails core team to find a better way to check for this.
|
103
|
+
def template_exists?(template_name, lookup_overrides = false)
|
104
|
+
begin
|
105
|
+
method = 'find_template'
|
106
|
+
method << '_without_active_scaffold' unless lookup_overrides
|
107
|
+
self.view_paths.send(method, template_name, @template_format)
|
108
|
+
return true
|
109
|
+
rescue ActionView::MissingTemplate => e
|
110
|
+
return false
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Bugfix: building an sti model from an association fails
|
2
|
+
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6306-collection-associations-build-method-not-supported-for-sti
|
3
|
+
ActiveRecord::Reflection::AssociationReflection.class_eval do
|
4
|
+
def build_association(*opts)
|
5
|
+
col = klass.inheritance_column.to_sym
|
6
|
+
if !col.nil? && opts.first.is_a?(Hash) && (opts.first.symbolize_keys[col])
|
7
|
+
sti_model = opts.first.delete(col)
|
8
|
+
sti_model.to_s.camelize.constantize.new(*opts)
|
9
|
+
else
|
10
|
+
klass.new(*opts)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Bugfix: Team.offset(1).limit(1) throws an error
|
2
|
+
ActiveRecord::Base.instance_eval do
|
3
|
+
def offset(*args, &block)
|
4
|
+
scoped.__send__(:offset, *args, &block)
|
5
|
+
rescue NoMethodError
|
6
|
+
if scoped.nil?
|
7
|
+
'depends on :allow_nil'
|
8
|
+
else
|
9
|
+
raise
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Object
|
2
|
+
def as_(key, options = {})
|
3
|
+
unless key.blank?
|
4
|
+
text = I18n.translate "#{key}", {:scope => [:active_scaffold], :default => key.is_a?(String) ? key : key.to_s.titleize}.merge(options)
|
5
|
+
# text = nil if text.include?('translation missing:')
|
6
|
+
end
|
7
|
+
text ||= key
|
8
|
+
text
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ActionView
|
2
|
+
module Helpers
|
3
|
+
class InstanceTag
|
4
|
+
private
|
5
|
+
def datetime_selector_with_name(options, html_options)
|
6
|
+
options.merge!(:prefix => options[:name].gsub(/\[[^\[]*\]$/,'')) if options[:name]
|
7
|
+
datetime_selector_without_name(options, html_options)
|
8
|
+
end
|
9
|
+
alias_method_chain :datetime_selector, :name
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|