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
@@ -88,7 +88,7 @@ module ActiveScaffold
|
|
88
88
|
else
|
89
89
|
options[:include_blank] ||= as_(:_select_)
|
90
90
|
end
|
91
|
-
select(:record, method,
|
91
|
+
select(:record, method, options_for_select, options, html_options)
|
92
92
|
end
|
93
93
|
|
94
94
|
def active_scaffold_search_text(column, options)
|
@@ -42,6 +42,12 @@ module ActiveScaffold
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
# This is the template finder logic, keep it updated with however we find stuff in rails
|
46
|
+
# currently this very similar to the logic in ActionBase::Base.render for options file
|
47
|
+
def template_exists?(template_name, partial = false)
|
48
|
+
lookup_context.exists? template_name, '', partial
|
49
|
+
end
|
50
|
+
|
45
51
|
def generate_temporary_id
|
46
52
|
(Time.now.to_f*1000).to_i.to_s
|
47
53
|
end
|
@@ -64,7 +70,7 @@ module ActiveScaffold
|
|
64
70
|
return false if column.polymorphic_association?
|
65
71
|
|
66
72
|
# A column shouldn't be in the subform if it's the reverse association to the parent
|
67
|
-
return false if column.association.
|
73
|
+
return false if column.association.inverse_for?(parent_record.class)
|
68
74
|
|
69
75
|
return true
|
70
76
|
end
|
@@ -78,42 +84,9 @@ module ActiveScaffold
|
|
78
84
|
(output << "<iframe id='#{action_iframe_id(url_for_options)}' name='#{action_iframe_id(url_for_options)}' style='display:none'></iframe>").html_safe
|
79
85
|
end
|
80
86
|
|
81
|
-
# Provides list of javascripts to include with +javascript_include_tag+
|
82
|
-
# You can use this with your javascripts like
|
83
|
-
# <%= javascript_include_tag :defaults, 'your_own_cool_script', active_scaffold_javascripts, :cache => true %>
|
84
|
-
def active_scaffold_javascripts(frontend = :default)
|
85
|
-
ActiveScaffold::Config::Core.javascripts(frontend).collect do |name|
|
86
|
-
ActiveScaffold::Config::Core.asset_path(name, frontend)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# Provides stylesheets to include with +stylesheet_link_tag+
|
91
|
-
def active_scaffold_stylesheets(frontend = :default)
|
92
|
-
[ActiveScaffold::Config::Core.asset_path("stylesheet.css", frontend)]
|
93
|
-
end
|
94
|
-
|
95
|
-
# Provides stylesheets for IE to include with +stylesheet_link_tag+
|
96
|
-
def active_scaffold_ie_stylesheets(frontend = :default)
|
97
|
-
[ActiveScaffold::Config::Core.asset_path("stylesheet-ie.css", frontend)]
|
98
|
-
end
|
99
|
-
|
100
|
-
# easy way to include ActiveScaffold assets
|
101
|
-
def active_scaffold_includes(*args)
|
102
|
-
frontend = args.first.is_a?(Symbol) ? args.shift : :default
|
103
|
-
options = args.first.is_a?(Hash) ? args.shift : {}
|
104
|
-
js = javascript_include_tag(*active_scaffold_javascripts(frontend).push(options))
|
105
|
-
|
106
|
-
css = stylesheet_link_tag(*active_scaffold_stylesheets(frontend).push(options))
|
107
|
-
options[:cache] += '_ie' if options[:cache].is_a? String
|
108
|
-
options[:concat] += '_ie' if options[:concat].is_a? String
|
109
|
-
ie_css = stylesheet_link_tag(*active_scaffold_ie_stylesheets(frontend).push(options))
|
110
|
-
|
111
|
-
js + "\n" + css + "\n<!--[if IE]>".html_safe + ie_css + "<![endif]-->\n".html_safe
|
112
|
-
end
|
113
|
-
|
114
87
|
# a general-use loading indicator (the "stuff is happening, please wait" feedback)
|
115
88
|
def loading_indicator_tag(options)
|
116
|
-
image_tag "
|
89
|
+
image_tag "indicator.gif", :style => "visibility:hidden;", :id => loading_indicator_id(options), :alt => "loading indicator", :class => "loading-indicator"
|
117
90
|
end
|
118
91
|
|
119
92
|
# Creates a javascript-based link that toggles the visibility of some element on the page.
|
@@ -161,17 +134,18 @@ module ActiveScaffold
|
|
161
134
|
|
162
135
|
def action_link_html_options(link, url_options, record, html_options)
|
163
136
|
link_id = get_action_link_id(url_options, record, link.column)
|
164
|
-
html_options.reverse_merge! link.html_options.merge(:class => link.action
|
137
|
+
html_options.reverse_merge! link.html_options.merge(:class => link.action)
|
165
138
|
|
166
139
|
# Needs to be in html_options to as the adding _method to the url is no longer supported by Rails
|
167
140
|
html_options[:method] = link.method if link.method != :get
|
168
141
|
|
169
|
-
html_options['data-confirm'] = link.confirm(record.try(:to_label)) if link.confirm?
|
170
|
-
html_options['data-position'] = link.position if link.position and link.inline?
|
171
142
|
html_options[:class] += ' as_action' if link.inline?
|
172
|
-
html_options[
|
143
|
+
html_options[:data] = {}
|
144
|
+
html_options[:data][:confirm] = link.confirm(record.try(:to_label)) if link.confirm?
|
145
|
+
html_options[:data][:position] = link.position if link.position and link.inline?
|
146
|
+
html_options[:data][:action] = link.action if link.inline?
|
173
147
|
if link.popup?
|
174
|
-
html_options[
|
148
|
+
html_options[:data][:popup] = true
|
175
149
|
html_options[:target] = '_blank'
|
176
150
|
end
|
177
151
|
html_options[:id] = link_id
|
@@ -70,7 +70,7 @@ module ActiveScaffold
|
|
70
70
|
return false if column.polymorphic_association?
|
71
71
|
|
72
72
|
# A column shouldn't be in the subform if it's the reverse association to the parent
|
73
|
-
return false if column.association.
|
73
|
+
return false if column.association.reverse_for?(parent_record.class)
|
74
74
|
|
75
75
|
return true
|
76
76
|
end
|
@@ -134,7 +134,7 @@ module ActiveScaffold
|
|
134
134
|
|
135
135
|
def action_link_html_options(link, url_options, record, html_options)
|
136
136
|
link_id = get_action_link_id(url_options, record, link.column)
|
137
|
-
html_options.reverse_merge! link.html_options.merge(:class => link.action
|
137
|
+
html_options.reverse_merge! link.html_options.merge(:class => link.action)
|
138
138
|
|
139
139
|
# Needs to be in html_options to as the adding _method to the url is no longer supported by Rails
|
140
140
|
html_options[:method] = link.method if link.method != :get
|
@@ -194,7 +194,7 @@ module ActiveScaffold
|
|
194
194
|
url_options[:eid] = link.eid
|
195
195
|
elsif link.parameters && link.parameters[:named_scope]
|
196
196
|
url_options[:assoc_id] = url_options.delete(:id)
|
197
|
-
link.eid = "#{controller_id.from(3)}_#{record.id}_#{link.parameters[:named_scope]}" unless
|
197
|
+
link.eid = "#{controller_id.from(3)}_#{record.id}_#{link.parameters[:named_scope]}" unless options.has_key?(:reuse_eid)
|
198
198
|
url_options[:eid] = link.eid
|
199
199
|
end
|
200
200
|
end
|
data/lib/active_scaffold_env.rb
CHANGED
@@ -9,5 +9,3 @@ ActionView::Base.send(:include, ActiveScaffold::Helpers::ViewHelpers)
|
|
9
9
|
ActionController::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Controller}
|
10
10
|
ActiveRecord::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Model}
|
11
11
|
ActiveRecord::Base.class_eval {include ActiveRecordPermissions::Permissions}
|
12
|
-
|
13
|
-
I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'active_scaffold', 'locale', '*.{rb,yml}')]
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.dirname(__FILE__), 'company')
|
3
|
+
|
4
|
+
class ActiveScaffoldDependentProtectTest < Test::Unit::TestCase
|
5
|
+
def test_destroy_protected_with_companies
|
6
|
+
protected_firm = Company.new(:with_companies)
|
7
|
+
assert !protected_firm.send(:authorized_for_delete?)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_destroy_protected_with_company
|
11
|
+
protected_firm = Company.new(:with_company)
|
12
|
+
assert !protected_firm.send(:authorized_for_delete?)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_destroy_protected_with_main_company
|
16
|
+
protected_firm = Company.new(:with_main_company)
|
17
|
+
assert !protected_firm.send(:authorized_for_delete?)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_destroy_protected_without_companies
|
21
|
+
protected_firm_without_companies = Company.new(:without_companies)
|
22
|
+
assert protected_firm_without_companies.send(:authorized_for_delete?)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_destroy_protected_without_company
|
26
|
+
protected_firm_without_company = Company.new(:without_company)
|
27
|
+
assert protected_firm_without_company.send(:authorized_for_delete?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_destroy_protected_without_main_company
|
31
|
+
protected_firm_without_main_company = Company.new(:without_main_company)
|
32
|
+
assert protected_firm_without_main_company.send(:authorized_for_delete?)
|
33
|
+
end
|
34
|
+
end
|
data/test/bridges/bridge_test.rb
CHANGED
@@ -32,6 +32,49 @@ class Bridges::BridgeTest < Test::Unit::TestCase
|
|
32
32
|
assert(bridge_will_be_installed("FileColumn"))
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
def test__dependent_protect_bridge
|
37
|
+
ConstMocker.mock("DependentProtect") do |cm|
|
38
|
+
cm.remove
|
39
|
+
assert(! bridge_will_be_installed("DependentProtect"))
|
40
|
+
cm.declare
|
41
|
+
assert(bridge_will_be_installed("DependentProtect"))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test__paperclip_bridge
|
46
|
+
ConstMocker.mock("Paperclip") do |cm|
|
47
|
+
cm.remove
|
48
|
+
assert(! bridge_will_be_installed("Paperclip"))
|
49
|
+
cm.declare
|
50
|
+
assert(bridge_will_be_installed("Paperclip"))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test__unobtrusive_date_picker_bridge
|
55
|
+
ConstMocker.mock("UnobtrusiveDatePicker") do |cm|
|
56
|
+
cm.remove
|
57
|
+
assert(! bridge_will_be_installed("UnobtrusiveDatePicker"))
|
58
|
+
cm.declare
|
59
|
+
assert(bridge_will_be_installed("UnobtrusiveDatePicker"))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test__validation_reflection_bridge
|
64
|
+
class << ActiveRecord::Base; undef_method :reflect_on_validations_for; end rescue nil
|
65
|
+
assert(! bridge_will_be_installed("ValidationReflection"))
|
66
|
+
class << ActiveRecord::Base; define_method :reflect_on_validations_for, lambda{}; end
|
67
|
+
assert(bridge_will_be_installed("ValidationReflection"))
|
68
|
+
end
|
69
|
+
|
70
|
+
def test__semantic_attributes_bridge
|
71
|
+
ConstMocker.mock("SemanticAttributes") do |cm|
|
72
|
+
cm.remove
|
73
|
+
assert(! bridge_will_be_installed("SemanticAttributes"))
|
74
|
+
cm.declare
|
75
|
+
assert(bridge_will_be_installed("SemanticAttributes"))
|
76
|
+
end
|
77
|
+
end
|
35
78
|
|
36
79
|
protected
|
37
80
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_record'
|
3
|
+
require 'active_record/reflection'
|
4
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/dependent_protect/lib/dependent_protect_bridge')
|
5
|
+
|
6
|
+
# Mocking everything necesary to test the plugin.
|
7
|
+
class Company
|
8
|
+
def initialize(with_or_without = nil)
|
9
|
+
@with_companies = with_or_without == :with_companies
|
10
|
+
@with_company = with_or_without == :with_company
|
11
|
+
@with_main_company = with_or_without == :with_main_company
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.columns_hash
|
15
|
+
{
|
16
|
+
'name' => ActiveRecord::ConnectionAdapters::Column.new('name', nil, 'varchar(255)'),
|
17
|
+
'date' => ActiveRecord::ConnectionAdapters::Column.new('date', nil, 'date'),
|
18
|
+
'datetime' => ActiveRecord::ConnectionAdapters::Column.new('datetime', nil, 'datetime'),
|
19
|
+
'logo_file_name' => ActiveRecord::ConnectionAdapters::Column.new('logo_file_name', nil, 'varchar(255)'),
|
20
|
+
'logo_content_type' => ActiveRecord::ConnectionAdapters::Column.new('logo_content_type', nil, 'varchar(255)'),
|
21
|
+
'logo_file_size' => ActiveRecord::ConnectionAdapters::Column.new('logo_file_size', nil, 'int(11)'),
|
22
|
+
'logo_updated_at' => ActiveRecord::ConnectionAdapters::Column.new('logo_updated_at', nil, 'datetime'),
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.columns
|
27
|
+
self.columns_hash.values
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.class_name
|
31
|
+
self.name
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.table_name
|
35
|
+
'companies'
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.attachment_definitions
|
39
|
+
{:logo => {}}
|
40
|
+
end
|
41
|
+
|
42
|
+
# not the real signature of the method, but forgive me
|
43
|
+
def self.before_destroy(s=nil)
|
44
|
+
@@before = s
|
45
|
+
end
|
46
|
+
|
47
|
+
include ActiveRecord::Reflection
|
48
|
+
include DependentProtectSecurity
|
49
|
+
|
50
|
+
def self.has_many(association_id, options = {})
|
51
|
+
reflection = create_reflection(:has_many, association_id, options, self)
|
52
|
+
end
|
53
|
+
def self.has_one(association_id, options = {})
|
54
|
+
reflection = create_reflection(:has_one, association_id, options, self)
|
55
|
+
end
|
56
|
+
def self.belongs_to(association_id, options = {})
|
57
|
+
reflection = create_reflection(:belongs_to, association_id, options, self)
|
58
|
+
end
|
59
|
+
has_many :companies, :dependent => :protect
|
60
|
+
has_one :company, :dependent => :protect
|
61
|
+
belongs_to :main_company, :dependent => :protect, :class_name => 'Company'
|
62
|
+
|
63
|
+
def companies
|
64
|
+
if @with_companies
|
65
|
+
[nil]
|
66
|
+
else
|
67
|
+
[]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def company
|
72
|
+
@with_company
|
73
|
+
end
|
74
|
+
|
75
|
+
def main_company
|
76
|
+
@with_main_company
|
77
|
+
end
|
78
|
+
|
79
|
+
def name
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.dirname(__FILE__), 'company')
|
3
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/paperclip/lib/paperclip_bridge')
|
4
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/paperclip/lib/paperclip_bridge_helpers')
|
5
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/paperclip/lib/form_ui')
|
6
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/paperclip/lib/list_ui')
|
7
|
+
|
8
|
+
class PaperclipCore < ActiveScaffold::Config::Core
|
9
|
+
include ActiveScaffold::PaperclipBridge
|
10
|
+
end
|
11
|
+
|
12
|
+
class PaperclipTest < ActionView::TestCase
|
13
|
+
include ActiveScaffold::Helpers::ViewHelpers
|
14
|
+
|
15
|
+
def test_initialization_without_paperclip
|
16
|
+
Company.expects(:attachment_definitions)
|
17
|
+
config = PaperclipCore.new(:company)
|
18
|
+
assert !config.create.multipart?
|
19
|
+
assert !config.update.multipart?
|
20
|
+
assert !config.columns.any? {|column| column.form_ui == :paperclip}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_initialization
|
24
|
+
config = PaperclipCore.new(:company)
|
25
|
+
assert config.create.multipart?
|
26
|
+
assert config.update.multipart?
|
27
|
+
assert_equal :paperclip, config.columns[:logo].form_ui
|
28
|
+
assert_equal [:delete_logo], config.columns[:logo].params.to_a
|
29
|
+
%w(logo_file_name logo_file_size logo_updated_at logo_content_type).each do |attr|
|
30
|
+
assert !config.columns._inheritable.include?(attr.to_sym)
|
31
|
+
end
|
32
|
+
assert Company.instance_methods.include?('delete_logo')
|
33
|
+
assert Company.instance_methods.include?('delete_logo=')
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_delete
|
37
|
+
PaperclipCore.new(:company)
|
38
|
+
company = Company.new
|
39
|
+
company.expects(:logo=).never
|
40
|
+
company.delete_logo = 'false'
|
41
|
+
|
42
|
+
company.expects(:logo).returns(stub(:dirty? => false))
|
43
|
+
company.expects(:logo=)
|
44
|
+
company.delete_logo = 'true'
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_list_ui
|
48
|
+
config = PaperclipCore.new(:company)
|
49
|
+
company = Company.new
|
50
|
+
|
51
|
+
company.stubs(:logo).returns(stub(:file? => true, :original_filename => 'file', :url => '/system/file', :styles => Company.attachment_definitions[:logo]))
|
52
|
+
assert_dom_equal '<a href="/system/file" onclick="window.open(this.href);return false;">file</a>', active_scaffold_column_paperclip(config.columns[:logo], company)
|
53
|
+
|
54
|
+
company.stubs(:logo).returns(stub(:file? => true, :original_filename => 'file', :url => '/system/file', :styles => {:thumbnail => '40x40'}))
|
55
|
+
assert_dom_equal '<a href="/system/file" onclick="window.open(this.href);return false;"><img src="/system/file" border="0" alt="File"/></a>', active_scaffold_column_paperclip(config.columns[:logo], company)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_form_ui
|
59
|
+
config = PaperclipCore.new(:company)
|
60
|
+
@record = Company.new
|
61
|
+
|
62
|
+
@record.stubs(:logo).returns(stub(:file? => true, :original_filename => 'file', :url => '/system/file', :styles => Company.attachment_definitions[:logo]))
|
63
|
+
assert_dom_equal '<div><a href="/system/file" onclick="window.open(this.href);return false;">file</a>|<a href="#" onclick="$(this).next().value=\'true\'; $(this).up().hide().next().show(); return false;">Remove or Replace file</a><input name="record[delete_logo]" type="hidden" id="record_delete_logo" value="false" /></div><div style="display: none"><input name="record[logo]" size="30" type="file" id="record_logo" /></div>', active_scaffold_input_paperclip(config.columns[:logo], :name => 'record[logo]', :id => 'record_logo')
|
64
|
+
|
65
|
+
@record.stubs(:logo).returns(stub(:file? => false))
|
66
|
+
assert_dom_equal '<input name="record[logo]" size="30" type="file" id="record_logo" />', active_scaffold_input_paperclip(config.columns[:logo], :name => 'record[logo]', :id => 'record_logo')
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.dirname(__FILE__), 'company')
|
3
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/tiny_mce/lib/tiny_mce_bridge')
|
4
|
+
|
5
|
+
class TinyMceTest < ActionView::TestCase
|
6
|
+
include ActiveScaffold::Helpers::ViewHelpers
|
7
|
+
include ActiveScaffold::TinyMceBridge
|
8
|
+
|
9
|
+
def test_includes
|
10
|
+
assert_match /.*<script type="text\/javascript">.*ActiveScaffold\.ActionLink\.Abstract\.prototype\.close = function\(\).*<\/script>.*/m, active_scaffold_includes
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_form_ui
|
14
|
+
config = PaperclipCore.new(:company)
|
15
|
+
@record = Company.new
|
16
|
+
self.expects(:request).returns(stub(:xhr? => true))
|
17
|
+
|
18
|
+
assert_dom_equal "<textarea name=\"record[name]\" class=\"name-input mceEditor\" id=\"record_name\"></textarea><script type=\"text/javascript\">\n//<![CDATA[\ntinyMCE.execCommand('mceAddControl', false, 'record_name');\n//]]>\n</script>", active_scaffold_input_text_editor(config.columns[:name], :name => 'record[name]', :id => 'record_name', :class => 'name-input')
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
def include_tiny_mce_if_needed; end
|
23
|
+
def tiny_mce_js; end
|
24
|
+
def using_tiny_mce?
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.dirname(__FILE__), 'company')
|
3
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/unobtrusive_date_picker/lib/unobtrusive_date_picker_bridge')
|
4
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/unobtrusive_date_picker/lib/view_helpers')
|
5
|
+
require File.join(File.dirname(__FILE__), '../../lib/bridges/unobtrusive_date_picker/lib/form_ui')
|
6
|
+
|
7
|
+
class UDPCore < ActiveScaffold::Config::Core
|
8
|
+
include ActiveScaffold::UnobtrusiveDatePickerBridge
|
9
|
+
end
|
10
|
+
|
11
|
+
class UnobtrusiveDatePickerTest < ActionView::TestCase
|
12
|
+
include ActiveScaffold::Helpers::ViewHelpers
|
13
|
+
include ActiveScaffold::UnobtrusiveDatePickerHelpers
|
14
|
+
|
15
|
+
def test_set_form_ui
|
16
|
+
config = UDPCore.new(:company)
|
17
|
+
assert_equal nil, config.columns[:name].form_ui, 'form_ui for name'
|
18
|
+
assert_equal :datepicker, config.columns[:date].form_ui, 'form_ui for date'
|
19
|
+
assert_equal :datepicker, config.columns[:datetime].form_ui, 'form_ui for datetime'
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_stylesheets
|
23
|
+
assert active_scaffold_stylesheets.include?('datepicker.css')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_javascripts
|
27
|
+
assert active_scaffold_javascripts.include?('datepicker.js')
|
28
|
+
assert active_scaffold_javascripts.include?('datepicker_lang/es.js')
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_form_ui
|
32
|
+
config = UDPCore.new(:company)
|
33
|
+
self.expects(:date_select).returns('')
|
34
|
+
self.expects(:date_picker).returns('')
|
35
|
+
assert active_scaffold_input_datepicker(config.columns[:date], :name => 'record[date]', :id => 'record_date')
|
36
|
+
|
37
|
+
self.expects(:datetime_select).returns('')
|
38
|
+
self.expects(:date_picker).returns('')
|
39
|
+
assert active_scaffold_input_datepicker(config.columns[:datetime], :name => 'record[datetime]', :id => 'record_datetime')
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def unobtrusive_datepicker_stylesheets
|
44
|
+
['datepicker.css']
|
45
|
+
end
|
46
|
+
def unobtrusive_datepicker_javascripts
|
47
|
+
['datepicker.js', 'datepicker_lang/es.js']
|
48
|
+
end
|
49
|
+
end
|