active_scaffold 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +18 -0
- data/app/assets/javascripts/active_scaffold.js.erb +8 -0
- data/app/assets/javascripts/jquery/active_scaffold.js +11 -7
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +19 -0
- data/app/assets/javascripts/prototype/active_scaffold.js +2 -0
- data/app/assets/stylesheets/active_scaffold_layout.css +5 -1
- data/app/views/active_scaffold_overrides/_field_search.html.erb +2 -2
- data/app/views/active_scaffold_overrides/_form_association.html.erb +5 -5
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +21 -16
- data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +8 -8
- data/app/views/active_scaffold_overrides/_horizontal_subform_header.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_list.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_list_calculations.html.erb +5 -7
- data/app/views/active_scaffold_overrides/_list_inline_adapter.html.erb +1 -12
- data/app/views/active_scaffold_overrides/_list_pagination.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_list_record.html.erb +2 -2
- data/app/views/active_scaffold_overrides/_list_with_header.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_render_field.js.erb +1 -1
- data/app/views/active_scaffold_overrides/_update_calculations.js.erb +1 -0
- data/app/views/active_scaffold_overrides/_vertical_subform.html.erb +2 -4
- data/app/views/active_scaffold_overrides/destroy.js.erb +1 -1
- data/app/views/active_scaffold_overrides/edit_associated.js.erb +2 -2
- data/config/locales/de.yml +109 -109
- data/config/locales/en.yml +109 -111
- data/config/locales/es.yml +112 -113
- data/config/locales/fr.yml +119 -125
- data/config/locales/hu.yml +109 -110
- data/config/locales/ja.yml +109 -110
- data/config/locales/ru.yml +119 -121
- data/lib/active_scaffold.rb +2 -2
- data/lib/active_scaffold/actions/common_search.rb +7 -3
- data/lib/active_scaffold/actions/core.rb +1 -0
- data/lib/active_scaffold/actions/field_search.rb +2 -1
- data/lib/active_scaffold/actions/list.rb +7 -1
- data/lib/active_scaffold/actions/subform.rb +2 -4
- data/lib/active_scaffold/attribute_params.rb +2 -4
- data/lib/active_scaffold/bridges/calendar_date_select.rb +1 -1
- data/lib/active_scaffold/bridges/date_picker.rb +4 -1
- data/lib/active_scaffold/bridges/date_picker/helper.rb +6 -6
- data/lib/active_scaffold/bridges/file_column.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +1 -1
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +1 -1
- data/lib/active_scaffold/config/base.rb +6 -1
- data/lib/active_scaffold/config/core.rb +16 -0
- data/lib/active_scaffold/config/list.rb +4 -0
- data/lib/active_scaffold/data_structures/column.rb +10 -3
- data/lib/active_scaffold/extensions/action_view_rendering.rb +10 -5
- data/lib/active_scaffold/helpers/association_helpers.rb +20 -5
- data/lib/active_scaffold/helpers/form_column_helpers.rb +31 -21
- data/lib/active_scaffold/helpers/list_column_helpers.rb +8 -5
- data/lib/active_scaffold/helpers/pagination_helpers.rb +8 -0
- data/lib/active_scaffold/helpers/search_column_helpers.rb +20 -6
- data/lib/active_scaffold/helpers/view_helpers.rb +6 -6
- data/lib/active_scaffold/version.rb +1 -1
- data/test/bridges/paperclip_test.rb +2 -2
- data/vendor/assets/javascripts/getprototypeof.js +12 -0
- data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +1 -1
- metadata +5 -5
- data/app/views/active_scaffold_overrides/_search_attribute.html.erb +0 -10
@@ -41,7 +41,7 @@ module ActiveScaffold
|
|
41
41
|
# TODO: move empty_field_text and logic in here?
|
42
42
|
# TODO: we need to distinguish between the automatic links *we* create and the ones that the dev specified. some logic may not apply if the dev specified the link.
|
43
43
|
def render_list_column(text, column, record)
|
44
|
-
if column.link
|
44
|
+
if column.link && !skip_action_link?(column.link, record)
|
45
45
|
link = column.link
|
46
46
|
associated = record.send(column.association.name) if column.association
|
47
47
|
render_action_link(link, record, :link => text, :authorized => link.action.nil? || column_link_authorized?(link, column, record, associated))
|
@@ -200,7 +200,7 @@ module ActiveScaffold
|
|
200
200
|
|
201
201
|
def inplace_edit?(record, column)
|
202
202
|
if column.inplace_edit
|
203
|
-
editable = controller.send(:update_authorized?, record) if controller.respond_to?(:update_authorized
|
203
|
+
editable = controller.send(:update_authorized?, record) if controller.respond_to?(:update_authorized?, true)
|
204
204
|
editable ||= record.authorized_for?(:crud_type => :update, :column => column.name)
|
205
205
|
end
|
206
206
|
end
|
@@ -222,11 +222,11 @@ module ActiveScaffold
|
|
222
222
|
|
223
223
|
def inplace_edit_control(column)
|
224
224
|
if inplace_edit?(active_scaffold_config.model, column) and inplace_edit_cloning?(column)
|
225
|
-
old_record, @record = @record, new_model
|
225
|
+
old_record, @record = @record, new_model # TODO remove when relying on @record is removed
|
226
226
|
column = column.clone
|
227
227
|
column.options = column.options.clone
|
228
228
|
column.form_ui = :select if (column.association && column.form_ui.nil?)
|
229
|
-
options = active_scaffold_input_options(column)
|
229
|
+
options = active_scaffold_input_options(column).merge(:object => new_model)
|
230
230
|
options[:class] = "#{options[:class]} inplace_field"
|
231
231
|
content_tag(:div, active_scaffold_input_for(column, nil, options), :style => "display:none;", :class => inplace_edit_control_css_class).tap do
|
232
232
|
@record = old_record
|
@@ -302,6 +302,9 @@ module ActiveScaffold
|
|
302
302
|
:remote => true, :method => :get}
|
303
303
|
url_options = params_for(:action => :index, :page => 1,
|
304
304
|
:sort => column.name, :sort_direction => sort_direction)
|
305
|
+
unless active_scaffold_config.store_user_settings
|
306
|
+
url_options.merge!(:search => search_params) if search_params.present?
|
307
|
+
end
|
305
308
|
link_to column_heading_label(column), url_options, options
|
306
309
|
else
|
307
310
|
content_tag(:p, column_heading_label(column))
|
@@ -315,7 +318,7 @@ module ActiveScaffold
|
|
315
318
|
def render_nested_view(action_links, record)
|
316
319
|
rendered = []
|
317
320
|
action_links.member.each do |link|
|
318
|
-
if link.nested_link? && link.column && @nested_auto_open[link.column.name] && @records.length <= @nested_auto_open[link.column.name] && controller.respond_to?(:render_component_into_view)
|
321
|
+
if link.nested_link? && link.column && @nested_auto_open[link.column.name] && @records.length <= @nested_auto_open[link.column.name] && controller.respond_to?(:render_component_into_view, true)
|
319
322
|
link_url_options = {:adapter => '_list_inline_adapter', :format => :js}.merge(action_link_url_options(link, record))
|
320
323
|
link_id = get_action_link_id(link, record)
|
321
324
|
rendered << (controller.send(:render_component_into_view, link_url_options) + javascript_tag("ActiveScaffold.ActionLink.get('#{link_id}').set_opened();"))
|
@@ -6,6 +6,14 @@ module ActiveScaffold
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def pagination_ajax_links(current_page, url_options, options, inner_window, outer_window)
|
9
|
+
unless active_scaffold_config.store_user_settings
|
10
|
+
url_options.merge!(:search => search_params) if search_params.present?
|
11
|
+
if active_scaffold_config.list.user.user_sorting?
|
12
|
+
column, direction = active_scaffold_config.list.user.sorting.first
|
13
|
+
url_options.merge!(:sort => column.name, :sort_direction => direction)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
start_number = current_page.number - inner_window
|
10
18
|
end_number = current_page.number + inner_window
|
11
19
|
start_number = 1 if start_number <= 0
|
@@ -4,12 +4,12 @@ module ActiveScaffold
|
|
4
4
|
module SearchColumnHelpers
|
5
5
|
# This method decides which input to use for the given column.
|
6
6
|
# It does not do any rendering. It only decides which method is responsible for rendering.
|
7
|
-
def active_scaffold_search_for(column)
|
8
|
-
options
|
7
|
+
def active_scaffold_search_for(column, options = nil)
|
8
|
+
options ||= active_scaffold_search_options(column)
|
9
9
|
|
10
10
|
# first, check if the dev has created an override for this specific field for search
|
11
11
|
if (method = override_search_field(column))
|
12
|
-
send(method, @record, options)
|
12
|
+
send(method, options[:object] || @record, options)
|
13
13
|
|
14
14
|
# second, check if the dev has specified a valid search_ui for this column, using specific ui for searches
|
15
15
|
elsif column.search_ui and (method = override_search(column.search_ui))
|
@@ -21,7 +21,7 @@ module ActiveScaffold
|
|
21
21
|
|
22
22
|
# fourth, check if the dev has created an override for this specific field
|
23
23
|
elsif (method = override_form_field(column))
|
24
|
-
send(method, @record, options)
|
24
|
+
send(method, options[:object] || @record, options)
|
25
25
|
|
26
26
|
# fallback: we get to make the decision
|
27
27
|
else
|
@@ -51,6 +51,16 @@ module ActiveScaffold
|
|
51
51
|
{ :name => "search[#{column.name}]", :class => "#{column.name}-input", :id => "search_#{column.name}", :value => field_search_params[column.name] }
|
52
52
|
end
|
53
53
|
|
54
|
+
def search_attribute(column, record)
|
55
|
+
column_options = active_scaffold_search_options(column).merge(:object => record)
|
56
|
+
field = active_scaffold_search_for column, column_options
|
57
|
+
%|<dl><dt>#{label_tag search_label_for(column, column_options), search_column_label(column, record)}</dt><dd>#{field}</dd></dl>|.html_safe
|
58
|
+
end
|
59
|
+
|
60
|
+
def search_label_for(column, options)
|
61
|
+
options[:id] unless [:range, :integer, :decimal, :float, :string, :date_picker, :datetime_picker, :calendar_date_select].include? column.search_ui
|
62
|
+
end
|
63
|
+
|
54
64
|
##
|
55
65
|
## Search input methods
|
56
66
|
##
|
@@ -114,7 +124,7 @@ module ActiveScaffold
|
|
114
124
|
select_options << [as_(:true), true]
|
115
125
|
select_options << [as_(:false), false]
|
116
126
|
|
117
|
-
select_tag(options[:name], options_for_select(select_options, column.column.type_cast(field_search_params[column.name])))
|
127
|
+
select_tag(options[:name], options_for_select(select_options, column.column.type_cast(field_search_params[column.name])), :id => options[:id])
|
118
128
|
end
|
119
129
|
# we can't use checkbox ui because it's not possible to decide whether search for this field or not
|
120
130
|
alias_method :active_scaffold_search_checkbox, :active_scaffold_search_boolean
|
@@ -123,7 +133,7 @@ module ActiveScaffold
|
|
123
133
|
select_options = []
|
124
134
|
select_options << [as_(:_select_), nil]
|
125
135
|
select_options.concat ActiveScaffold::Finder::NullComparators.collect {|comp| [as_(comp), comp]}
|
126
|
-
select_tag(options[:name], options_for_select(select_options, field_search_params[column.name]))
|
136
|
+
select_tag(options[:name], options_for_select(select_options, field_search_params[column.name]), :id => options[:id])
|
127
137
|
end
|
128
138
|
|
129
139
|
def field_search_params_range_values(column)
|
@@ -223,6 +233,10 @@ module ActiveScaffold
|
|
223
233
|
##
|
224
234
|
## Search column override signatures
|
225
235
|
##
|
236
|
+
|
237
|
+
def search_column_label(column, record)
|
238
|
+
column.label
|
239
|
+
end
|
226
240
|
|
227
241
|
def override_search_field(column)
|
228
242
|
override_helper column, 'search_column'
|
@@ -97,11 +97,11 @@ module ActiveScaffold
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def skip_action_link?(link, *args)
|
100
|
-
!link.ignore_method.nil? && controller.respond_to?(link.ignore_method) && controller.send(link.ignore_method, *args)
|
100
|
+
!link.ignore_method.nil? && controller.respond_to?(link.ignore_method, true) && controller.send(link.ignore_method, *args)
|
101
101
|
end
|
102
102
|
|
103
103
|
def action_link_authorized?(link, *args)
|
104
|
-
security_method = link.security_method_set? || controller.respond_to?(link.security_method)
|
104
|
+
security_method = link.security_method_set? || controller.respond_to?(link.security_method, true)
|
105
105
|
authorized = if security_method
|
106
106
|
controller.send(link.security_method, *args)
|
107
107
|
else
|
@@ -224,8 +224,8 @@ module ActiveScaffold
|
|
224
224
|
authorized = associated_for_authorized.authorized_for?(:crud_type => link.crud_type)
|
225
225
|
authorized = authorized and record.authorized_for?(:crud_type => :update, :column => column.name) if link.crud_type == :create
|
226
226
|
authorized
|
227
|
-
else
|
228
|
-
|
227
|
+
else
|
228
|
+
action_link_authorized?(link, record)
|
229
229
|
end
|
230
230
|
end
|
231
231
|
|
@@ -368,7 +368,7 @@ module ActiveScaffold
|
|
368
368
|
id = "#{column.association.name}-#{record.id}" unless record.nil?
|
369
369
|
end
|
370
370
|
end
|
371
|
-
action_id = "#{id_from_controller("#{link.controller}-") if params[:parent_controller] || link.controller != controller.controller_path}#{link.action}"
|
371
|
+
action_id = "#{id_from_controller("#{link.controller}-") if params[:parent_controller] || (link.controller && link.controller != controller.controller_path)}#{link.action}"
|
372
372
|
action_link_id(action_id, id)
|
373
373
|
end
|
374
374
|
|
@@ -462,7 +462,7 @@ module ActiveScaffold
|
|
462
462
|
|
463
463
|
def column_empty?(column_value)
|
464
464
|
empty = column_value.nil?
|
465
|
-
empty ||= column_value.blank?
|
465
|
+
empty ||= column_value != false && column_value.blank?
|
466
466
|
empty ||= [' ', active_scaffold_config.list.empty_field_text].include? column_value if String === column_value
|
467
467
|
return empty
|
468
468
|
end
|
@@ -29,8 +29,8 @@ class PaperclipTest < ActionView::TestCase
|
|
29
29
|
%w(logo_file_name logo_file_size logo_updated_at logo_content_type).each do |attr|
|
30
30
|
assert !config.columns._inheritable.include?(attr.to_sym)
|
31
31
|
end
|
32
|
-
assert Company.
|
33
|
-
assert Company.
|
32
|
+
assert Company.method_defined?(:delete_logo)
|
33
|
+
assert Company.method_defined?(:'delete_logo=')
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_delete
|
@@ -0,0 +1,12 @@
|
|
1
|
+
if ( typeof Object.getPrototypeOf !== "function" ) {
|
2
|
+
if ( typeof "test".__proto__ === "object" ) {
|
3
|
+
Object.getPrototypeOf = function(object){
|
4
|
+
return object.__proto__;
|
5
|
+
};
|
6
|
+
} else {
|
7
|
+
Object.getPrototypeOf = function(object){
|
8
|
+
// May break if the constructor has been tampered with
|
9
|
+
return object.constructor.prototype;
|
10
|
+
};
|
11
|
+
}
|
12
|
+
}
|
@@ -163,7 +163,7 @@
|
|
163
163
|
|
164
164
|
for (var attrName in this._defaults) {
|
165
165
|
if(this._defaults.hasOwnProperty(attrName)){
|
166
|
-
var attrValue = $input.
|
166
|
+
var attrValue = $input.data(attrName.toLowerCase());
|
167
167
|
if (attrValue) {
|
168
168
|
try {
|
169
169
|
inlineSettings[attrName] = eval(attrValue);
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 3.3.
|
9
|
+
- 1
|
10
|
+
version: 3.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Many, see README
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-06-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :development
|
@@ -146,7 +146,6 @@ files:
|
|
146
146
|
- app/views/active_scaffold_overrides/_render_field.js.erb
|
147
147
|
- app/views/active_scaffold_overrides/_row.html.erb
|
148
148
|
- app/views/active_scaffold_overrides/_search.html.erb
|
149
|
-
- app/views/active_scaffold_overrides/_search_attribute.html.erb
|
150
149
|
- app/views/active_scaffold_overrides/_show.html.erb
|
151
150
|
- app/views/active_scaffold_overrides/_show_columns.html.erb
|
152
151
|
- app/views/active_scaffold_overrides/_update_actions.html.erb
|
@@ -326,6 +325,7 @@ files:
|
|
326
325
|
- vendor/assets/images/ui-icons_ef8c08_256x240.png
|
327
326
|
- vendor/assets/images/ui-icons_ffd27a_256x240.png
|
328
327
|
- vendor/assets/images/ui-icons_ffffff_256x240.png
|
328
|
+
- vendor/assets/javascripts/getprototypeof.js
|
329
329
|
- vendor/assets/javascripts/jquery-ui-timepicker-addon.js
|
330
330
|
- vendor/assets/stylesheets/jquery-ui.css
|
331
331
|
- MIT-LICENSE
|