active_scaffold 3.3.0.rc2 → 3.3.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/app/assets/javascripts/jquery/active_scaffold.js +6 -1
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +2 -1
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +1 -3
- data/app/views/active_scaffold_overrides/_list_inline_adapter.html.erb +3 -1
- data/app/views/active_scaffold_overrides/_list_with_header.html.erb +1 -1
- data/app/views/active_scaffold_overrides/on_action_update.js.erb +1 -1
- data/app/views/active_scaffold_overrides/on_create.js.erb +13 -7
- data/lib/active_scaffold.rb +12 -4
- data/lib/active_scaffold/actions/core.rb +2 -1
- data/lib/active_scaffold/actions/create.rb +2 -2
- data/lib/active_scaffold/actions/list.rb +3 -0
- data/lib/active_scaffold/actions/nested.rb +1 -1
- data/lib/active_scaffold/actions/show.rb +0 -1
- data/lib/active_scaffold/attribute_params.rb +7 -2
- data/lib/active_scaffold/config/base.rb +11 -1
- data/lib/active_scaffold/config/list.rb +20 -11
- data/lib/active_scaffold/data_structures/column.rb +29 -4
- data/lib/active_scaffold/extensions/action_view_rendering.rb +5 -1
- data/lib/active_scaffold/finder.rb +5 -4
- data/lib/active_scaffold/helpers/list_column_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/view_helpers.rb +9 -8
- data/lib/active_scaffold/version.rb +1 -1
- metadata +5 -5
data/CHANGELOG
CHANGED
@@ -25,6 +25,7 @@
|
|
25
25
|
- Cosmetic fixes and improvements
|
26
26
|
- Fix multipart persistent update form
|
27
27
|
- Support jquery 1.9 (jquery-rails 2.2.0 gem)
|
28
|
+
- Reduce usage of session
|
28
29
|
|
29
30
|
= 3.2.19 (not released yet)
|
30
31
|
- Avoid crashing when between is chosen and from or to is not filled
|
@@ -200,6 +200,11 @@ jQuery(document).ready(function($) {
|
|
200
200
|
ActiveScaffold[jQuery(this).val() == 'REPLACE' ? 'hide' : 'show'](jQuery(this).next().next());
|
201
201
|
return true;
|
202
202
|
});
|
203
|
+
|
204
|
+
jQuery(document).on('click', '.active-scaffold .sub-form a.destroy', function(event) {
|
205
|
+
event.preventDefault();
|
206
|
+
ActiveScaffold.delete_subform_record($(this).data('delete-id'));
|
207
|
+
});
|
203
208
|
|
204
209
|
jQuery(document).on('click', 'a[data-popup]', function(e) {
|
205
210
|
window.open(jQuery(this).attr('href'));
|
@@ -692,7 +697,7 @@ var ActiveScaffold = {
|
|
692
697
|
render_form_field: function(source, content, options) {
|
693
698
|
if (typeof(source) == 'string') source = '#' + source;
|
694
699
|
var source = jQuery(source);
|
695
|
-
var element = source.closest('.
|
700
|
+
var element = source.closest('.sub-form-record');
|
696
701
|
if (element.length == 0) {
|
697
702
|
element = source.closest('form > ol.form');
|
698
703
|
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<%# encoding: utf-8 %>
|
1
2
|
<%= ActiveScaffold::Bridges[:date_picker].localization %>
|
2
3
|
jQuery(document).on("focus", "input.date_picker", function(){
|
3
4
|
var date_picker = jQuery(this);
|
@@ -19,4 +20,4 @@ jQuery(document).on("focus", "input.datetime_picker", function(){
|
|
19
20
|
}
|
20
21
|
}
|
21
22
|
return true;
|
22
|
-
});
|
23
|
+
});
|
@@ -62,9 +62,7 @@
|
|
62
62
|
<% if show_actions -%>
|
63
63
|
<%= content_tag column_tag, :class => "actions" do %>
|
64
64
|
<% if record_column.plural_association? and (@record.authorized_for?(:crud_type => :delete) or not [:destroy, :delete_all].include?(record_column.association.options[:dependent])) %>
|
65
|
-
|
66
|
-
<%= link_to as_(:remove), '#', :class => 'destroy', :id => destroy_id , :onclick => "ActiveScaffold.delete_subform_record(\"#{tr_id}\"); return false;", :style=> "display: none;" %>
|
67
|
-
<%= javascript_tag("ActiveScaffold.show('#{destroy_id}');") if !locked %>
|
65
|
+
<%= link_to as_(:remove), '#', :class => 'destroy', :id => "#{options[:id]}-destroy" , :data => {:delete_id => tr_id} unless locked %>
|
68
66
|
<% end %>
|
69
67
|
<% unless @record.new_record? %>
|
70
68
|
<input type="hidden" name="<%= options[:name] -%>" id="<%= options[:id] -%>" value="<%= @record.id -%>" />
|
@@ -12,10 +12,12 @@
|
|
12
12
|
<%# nested_id, allows us to remove a nested scaffold programmatically %>
|
13
13
|
<tr class="inline-adapter" id="<%= element_row_id :action => :nested %>">
|
14
14
|
<td colspan="<%= column_count %>" class="inline-adapter-cell">
|
15
|
+
<% if controller.send(:successful?) %>
|
15
16
|
<div class="<%= "#{params[:action]}-view" if params[:action] %> <%= "#{nested? ? nested.name : id_from_controller(params[:controller])}-view" %> view">
|
16
17
|
<%= link_to(as_(:close), '', :class => 'inline-adapter-close as_cancel', :remote => true, :title => as_(:close)) -%>
|
17
18
|
<%= payload -%>
|
18
19
|
</div>
|
20
|
+
<% end %>
|
19
21
|
</td>
|
20
22
|
</tr>
|
21
|
-
<%= javascript_tag("var action_link = ActiveScaffold.ActionLink.get('#{element_row_id(:action => :nested)}'); if (action_link) action_link.update_flash_messages('#{escape_javascript(render(:partial => 'messages').strip)}');") %>
|
23
|
+
<%= javascript_tag("setTimeout(function() { var action_link = ActiveScaffold.ActionLink.get('#{element_row_id(:action => :nested)}'); if (action_link) { action_link.update_flash_messages('#{escape_javascript(render(:partial => 'messages').strip)}');#{' action_link.close(); ActiveScaffold.scroll_to(action_link.scaffold(), ActiveScaffold.config.scroll_on_close == "checkInViewport");' unless controller.send(:successful?)} } }, 10);") %>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<%= render :partial => 'refresh_list' %>
|
17
17
|
<% end %>
|
18
18
|
<% else %>
|
19
|
-
<% flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br) if @record.errors.present? %>
|
19
|
+
<% flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br) if @record.try(:errors).present? %>
|
20
20
|
ActiveScaffold.replace_html('<%= active_scaffold_messages_id %>','<%= escape_javascript(render(:partial => 'messages')) %>');
|
21
21
|
ActiveScaffold.scroll_to('<%= active_scaffold_messages_id %>', true);
|
22
22
|
<% end %>
|
@@ -1,9 +1,13 @@
|
|
1
1
|
try {
|
2
2
|
<% form_selector = "#{element_form_id(:action => :create)}"
|
3
|
-
insert_at ||= :top
|
4
|
-
|
5
|
-
|
6
|
-
<%
|
3
|
+
insert_at ||= :top -%>
|
4
|
+
<% if active_scaffold_config.list.always_show_create -%>
|
5
|
+
<%= render :partial => 'update_messages' %>
|
6
|
+
<% else -%>
|
7
|
+
var action_link = ActiveScaffold.find_action_link('<%= form_selector %>');
|
8
|
+
action_link.update_flash_messages('<%= escape_javascript(render(:partial => 'messages')) %>');
|
9
|
+
<% end -%>
|
10
|
+
<% if controller.send :successful? -%>
|
7
11
|
<% if render_parent? %>
|
8
12
|
<% if nested_singular_association? %>
|
9
13
|
action_link.close(true);
|
@@ -12,16 +16,18 @@ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'mess
|
|
12
16
|
<% else %>
|
13
17
|
ActiveScaffold.reload('<%= url_for render_parent_options %>');
|
14
18
|
<% end %>
|
15
|
-
<% elsif
|
19
|
+
<% elsif active_scaffold_config.create.refresh_list %>
|
16
20
|
<%= render :partial => 'refresh_list' %>
|
17
21
|
<% elsif params[:parent_controller].nil? %>
|
18
22
|
<% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
|
19
|
-
ActiveScaffold.create_record_row(action_link.scaffold(),'<%= escape_javascript(new_row) %>', <%= {:insert_at => insert_at}.to_json.html_safe %>);
|
23
|
+
ActiveScaffold.create_record_row(action_link ? action_link.scaffold() : '<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {:insert_at => insert_at}.to_json.html_safe %>);
|
20
24
|
<%= render :partial => 'update_calculations', :formats => [:js] %>
|
21
25
|
<% end %>
|
22
26
|
|
23
27
|
<% unless render_parent? %>
|
24
|
-
<% if
|
28
|
+
<% if active_scaffold_config.list.always_show_create %>
|
29
|
+
ActiveScaffold.reset_form('<%= form_selector %>');
|
30
|
+
<% elsif active_scaffold_config.create.persistent %>
|
25
31
|
action_link.reload();
|
26
32
|
<% else %>
|
27
33
|
action_link.close();
|
data/lib/active_scaffold.rb
CHANGED
@@ -85,21 +85,29 @@ module ActiveScaffold
|
|
85
85
|
self.class.active_scaffold_config_for(klass)
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
88
|
+
def active_scaffold_session_storage_key(id = nil)
|
89
89
|
id ||= params[:eid] || "#{params[:controller]}#{"_#{nested.parent_id}" if nested?}"
|
90
|
-
|
90
|
+
"as:#{id}"
|
91
|
+
end
|
92
|
+
|
93
|
+
def active_scaffold_session_storage(id = nil)
|
94
|
+
session_index = active_scaffold_session_storage_key(id)
|
91
95
|
session[session_index] ||= {}
|
92
96
|
session[session_index]
|
93
97
|
end
|
94
98
|
|
99
|
+
def clear_storage
|
100
|
+
session_index = active_scaffold_session_storage_key
|
101
|
+
session.delete(session_index) unless session[session_index].present?
|
102
|
+
end
|
103
|
+
|
95
104
|
# 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.
|
96
105
|
def handle_user_settings
|
97
106
|
if self.class.uses_active_scaffold?
|
98
107
|
active_scaffold_config.actions.each do |action_name|
|
99
108
|
conf_instance = active_scaffold_config.send(action_name) rescue next
|
100
109
|
next if conf_instance.class::UserSettings == ActiveScaffold::Config::Base::UserSettings # if it hasn't been extended, skip it
|
101
|
-
active_scaffold_session_storage
|
102
|
-
conf_instance.user = conf_instance.class::UserSettings.new(conf_instance, active_scaffold_session_storage[action_name], params)
|
110
|
+
conf_instance.user = conf_instance.class::UserSettings.new(conf_instance, active_scaffold_session_storage, params)
|
103
111
|
end
|
104
112
|
end
|
105
113
|
end
|
@@ -4,6 +4,7 @@ module ActiveScaffold::Actions
|
|
4
4
|
base.class_eval do
|
5
5
|
prepend_before_filter :register_constraints_with_action_columns, :unless => :nested?
|
6
6
|
after_filter :clear_flashes
|
7
|
+
after_filter :clear_storage
|
7
8
|
rescue_from ActiveScaffold::RecordNotAllowed, ActiveScaffold::ActionNotAllowed, :with => :deny_access
|
8
9
|
end
|
9
10
|
base.helper_method :nested?
|
@@ -118,7 +119,7 @@ module ActiveScaffold::Actions
|
|
118
119
|
# circumvent this method by setting @success directly.
|
119
120
|
def successful?
|
120
121
|
if @successful.nil?
|
121
|
-
|
122
|
+
true
|
122
123
|
else
|
123
124
|
@successful
|
124
125
|
end
|
@@ -47,7 +47,7 @@ module ActiveScaffold::Actions
|
|
47
47
|
return_to_main
|
48
48
|
end
|
49
49
|
else
|
50
|
-
if
|
50
|
+
if active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
|
51
51
|
list
|
52
52
|
else
|
53
53
|
render(:action => 'create')
|
@@ -118,7 +118,7 @@ module ActiveScaffold::Actions
|
|
118
118
|
# You may override the method to customize.
|
119
119
|
|
120
120
|
def create_ignore?
|
121
|
-
|
121
|
+
active_scaffold_config.list.always_show_create
|
122
122
|
end
|
123
123
|
|
124
124
|
def create_authorized?
|
@@ -85,6 +85,9 @@ module ActiveScaffold::Actions
|
|
85
85
|
:pagination => active_scaffold_config.list.pagination
|
86
86
|
})
|
87
87
|
end
|
88
|
+
if active_scaffold_config.list.auto_select_columns
|
89
|
+
options[:select] = active_scaffold_config.list.columns.map(&:select_columns).compact.flatten + active_scaffold_config.columns[active_scaffold_config.model.primary_key].select_columns
|
90
|
+
end
|
88
91
|
|
89
92
|
page = find_page(options)
|
90
93
|
total_pages = page.pager.number_of_pages
|
@@ -32,7 +32,7 @@ module ActiveScaffold::Actions
|
|
32
32
|
|
33
33
|
def configure_nested
|
34
34
|
if nested?
|
35
|
-
|
35
|
+
active_scaffold_config.list.user.label = if nested.belongs_to?
|
36
36
|
as_(:nested_of_model, :nested_model => active_scaffold_config.model.model_name.human, :parent_model => nested_parent_record.to_label)
|
37
37
|
else
|
38
38
|
as_(:nested_for_model, :nested_model => active_scaffold_config.list.label, :parent_model => nested_parent_record.to_label)
|
@@ -9,7 +9,6 @@ module ActiveScaffold::Actions
|
|
9
9
|
# just render action_confirmation message for destroy
|
10
10
|
unless params.delete :destroy_action
|
11
11
|
do_show
|
12
|
-
successful?
|
13
12
|
respond_to_action(:show)
|
14
13
|
else
|
15
14
|
@record = find_if_allowed(params[:id], :read) if params[:id] && params[:id] && params[:id].to_i > 0
|
@@ -74,7 +74,8 @@ module ActiveScaffold
|
|
74
74
|
association_proxy.each { |record| record.send("#{a.reverse}=", parent_record) }
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
|
+
flash[:warning] = parent_record.errors.to_a.join("\n") if parent_record.errors.present?
|
78
79
|
parent_record
|
79
80
|
end
|
80
81
|
|
@@ -110,7 +111,11 @@ module ActiveScaffold
|
|
110
111
|
end
|
111
112
|
|
112
113
|
def column_value_for_datetime_type(parent_record, column, value)
|
113
|
-
self.class.condition_value_for_datetime(column, value, self.class.datetime_conversion_for_condition(column))
|
114
|
+
new_value = self.class.condition_value_for_datetime(column, value, self.class.datetime_conversion_for_condition(column))
|
115
|
+
if new_value.nil? && value.present?
|
116
|
+
parent_record.errors.add column.name, :invalid
|
117
|
+
end
|
118
|
+
new_value
|
114
119
|
end
|
115
120
|
|
116
121
|
def column_value_from_param_simple_value(parent_record, column, value)
|
@@ -42,13 +42,23 @@ module ActiveScaffold::Config
|
|
42
42
|
attr_accessor :action_group
|
43
43
|
|
44
44
|
class UserSettings
|
45
|
-
def initialize(conf, storage, params)
|
45
|
+
def initialize(conf, storage, params, action = :base)
|
46
46
|
# the session hash relevant to this action
|
47
47
|
@session = storage
|
48
48
|
# all the request params
|
49
49
|
@params = params
|
50
50
|
# the configuration object for this action
|
51
51
|
@conf = conf
|
52
|
+
@action = action
|
53
|
+
end
|
54
|
+
|
55
|
+
def [](key)
|
56
|
+
@session[@action][key] if @action && @session[@action]
|
57
|
+
end
|
58
|
+
|
59
|
+
def []=(key, value)
|
60
|
+
@session[@action] ||= {}
|
61
|
+
@session[@action][key] = value
|
52
62
|
end
|
53
63
|
end
|
54
64
|
|
@@ -24,6 +24,7 @@ module ActiveScaffold::Config
|
|
24
24
|
@always_show_search = self.class.always_show_search
|
25
25
|
@always_show_create = self.class.always_show_create
|
26
26
|
@messages_above_header = self.class.messages_above_header
|
27
|
+
@auto_select_columns = self.class.auto_select_columns
|
27
28
|
end
|
28
29
|
|
29
30
|
# global level configuration
|
@@ -80,6 +81,10 @@ module ActiveScaffold::Config
|
|
80
81
|
cattr_accessor :always_show_create
|
81
82
|
@@always_show_create = false
|
82
83
|
|
84
|
+
# Enable auto select columns on list, so only columns needed for list columns are selected
|
85
|
+
cattr_accessor :auto_select_columns
|
86
|
+
@@auto_select_columns = false
|
87
|
+
|
83
88
|
# instance-level configuration
|
84
89
|
# ----------------------------
|
85
90
|
|
@@ -182,29 +187,33 @@ module ActiveScaffold::Config
|
|
182
187
|
# it allows for more css styling
|
183
188
|
attr_accessor :wrap_tag
|
184
189
|
|
190
|
+
# Enable auto select columns on list, so only columns needed for list columns are selected
|
191
|
+
attr_accessor :auto_select_columns
|
192
|
+
|
185
193
|
class UserSettings < UserSettings
|
186
194
|
def initialize(conf, storage, params)
|
187
|
-
super(conf,storage,params)
|
195
|
+
super(conf, storage, params, :list)
|
188
196
|
@sorting = nil
|
189
197
|
end
|
190
198
|
|
199
|
+
attr_writer :label
|
191
200
|
# This label has alread been localized.
|
192
201
|
def label
|
193
|
-
@
|
202
|
+
@label || @conf.label
|
194
203
|
end
|
195
204
|
|
196
205
|
def per_page
|
197
|
-
|
198
|
-
|
206
|
+
self['per_page'] = @params['limit'].to_i if @params.has_key? 'limit'
|
207
|
+
self['per_page'] || @conf.per_page
|
199
208
|
end
|
200
209
|
|
201
210
|
def page
|
202
|
-
|
203
|
-
|
211
|
+
self['page'] = @params['page'] if @params.has_key? 'page'
|
212
|
+
self['page'] || 1
|
204
213
|
end
|
205
214
|
|
206
215
|
def page=(value = nil)
|
207
|
-
|
216
|
+
self['page'] = value
|
208
217
|
end
|
209
218
|
|
210
219
|
attr_reader :nested_default_sorting
|
@@ -221,12 +230,12 @@ module ActiveScaffold::Config
|
|
221
230
|
def sorting
|
222
231
|
if @sorting.nil?
|
223
232
|
# we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
|
224
|
-
|
225
|
-
|
233
|
+
self['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
|
234
|
+
self['sort'] = nil if @params['sort_direction'] == 'reset'
|
226
235
|
|
227
|
-
if
|
236
|
+
if self['sort']
|
228
237
|
sorting = @conf.sorting.clone
|
229
|
-
sorting.set(
|
238
|
+
sorting.set(*self['sort'])
|
230
239
|
@sorting = sorting
|
231
240
|
else
|
232
241
|
@sorting = default_sorting
|
@@ -22,6 +22,9 @@ module ActiveScaffold::DataStructures
|
|
22
22
|
# Whether to enable add_existing for this column
|
23
23
|
attr_accessor :allow_add_existing
|
24
24
|
|
25
|
+
# What columns load from main table
|
26
|
+
attr_accessor :select_columns
|
27
|
+
|
25
28
|
# Any extra parameters this particular column uses. This is for create/update purposes.
|
26
29
|
def params
|
27
30
|
# lazy initialize
|
@@ -172,7 +175,7 @@ module ActiveScaffold::DataStructures
|
|
172
175
|
end
|
173
176
|
|
174
177
|
# a collection of columns to load when eager loading is disabled, if it's nil all columns will be loaded
|
175
|
-
attr_accessor :
|
178
|
+
attr_accessor :select_associated_columns
|
176
179
|
|
177
180
|
# describes how to search on a column
|
178
181
|
# search = true default, uses intelligent search sql
|
@@ -293,6 +296,24 @@ module ActiveScaffold::DataStructures
|
|
293
296
|
@show_blank_record = self.class.show_blank_record
|
294
297
|
@send_form_on_update_column = self.class.send_form_on_update_column
|
295
298
|
@actions_for_association_links = self.class.actions_for_association_links.clone if @association
|
299
|
+
@select_columns = if @association.nil? && @column
|
300
|
+
[field]
|
301
|
+
elsif polymorphic_association?
|
302
|
+
[field, quoted_field(@active_record_class.connection.quote_column_name(@association.foreign_type))]
|
303
|
+
elsif @association
|
304
|
+
if self.association.macro == :belongs_to
|
305
|
+
[field]
|
306
|
+
else
|
307
|
+
columns = []
|
308
|
+
if active_record_class.columns_hash[count_column = "#{@association.name}_count"]
|
309
|
+
columns << quoted_field(@active_record_class.connection.quote_column_name(count_column))
|
310
|
+
end
|
311
|
+
if @association.through_reflection.try(:macro) == :belongs_to
|
312
|
+
columns << quoted_field(@active_record_class.connection.quote_column_name(@association.through_reflection.foreign_key))
|
313
|
+
end
|
314
|
+
columns
|
315
|
+
end
|
316
|
+
end
|
296
317
|
|
297
318
|
self.number = @column.try(:number?)
|
298
319
|
@options = {:format => :i18n_number} if self.number?
|
@@ -305,8 +326,8 @@ module ActiveScaffold::DataStructures
|
|
305
326
|
# default all the configurable variables
|
306
327
|
self.css_class = ''
|
307
328
|
self.required = active_record_class.validators_on(self.name).any? do |val|
|
308
|
-
ActiveModel::Validations::PresenceValidator === val
|
309
|
-
ActiveModel::Validations::InclusionValidator === val
|
329
|
+
!val.options[:if] && !val.options[:unless] && (ActiveModel::Validations::PresenceValidator === val ||
|
330
|
+
(ActiveModel::Validations::InclusionValidator === val && !val.options[:allow_nil] && !val.options[:allow_blank])
|
310
331
|
)
|
311
332
|
end
|
312
333
|
self.sort = true
|
@@ -356,11 +377,15 @@ module ActiveScaffold::DataStructures
|
|
356
377
|
|
357
378
|
# the table.field name for this column, if applicable
|
358
379
|
def field
|
359
|
-
@field ||=
|
380
|
+
@field ||= quoted_field(field_name)
|
360
381
|
end
|
361
382
|
|
362
383
|
protected
|
363
384
|
|
385
|
+
def quoted_field(name)
|
386
|
+
[@active_record_class.quoted_table_name, name].join('.')
|
387
|
+
end
|
388
|
+
|
364
389
|
def initialize_sort
|
365
390
|
if self.virtual?
|
366
391
|
# we don't automatically enable method sorting for virtual columns because it's slow, and we expect fewer complaints this way.
|
@@ -43,7 +43,11 @@ module ActionView::Helpers #:nodoc:
|
|
43
43
|
constraints = options[:constraints]
|
44
44
|
conditions = options[:conditions]
|
45
45
|
eid = Digest::MD5.hexdigest(params[:controller] + remote_controller.to_s + constraints.to_s + conditions.to_s)
|
46
|
-
|
46
|
+
eid_info = {}
|
47
|
+
eid_info[:constraints] = constraints if constraints
|
48
|
+
eid_info[:conditions] = conditions if conditions
|
49
|
+
eid_info[:list] = {:label => args.first[:label]} if args.first[:label]
|
50
|
+
session["as:#{eid}"] = eid_info
|
47
51
|
options[:params] ||= {}
|
48
52
|
options[:params].merge! :eid => eid, :embedded => true
|
49
53
|
|
@@ -324,7 +324,8 @@ module ActiveScaffold
|
|
324
324
|
finder_options = { :reorder => options[:sorting].try(:clause),
|
325
325
|
:conditions => search_conditions,
|
326
326
|
:joins => joins_for_finder,
|
327
|
-
:includes => full_includes
|
327
|
+
:includes => full_includes,
|
328
|
+
:select => options[:select]}
|
328
329
|
|
329
330
|
finder_options.merge! custom_finder_options
|
330
331
|
finder_options
|
@@ -348,7 +349,7 @@ module ActiveScaffold
|
|
348
349
|
# returns a Paginator::Page (not from ActiveRecord::Paginator) for the given parameters
|
349
350
|
# See finder_options for valid options
|
350
351
|
def find_page(options = {})
|
351
|
-
options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination
|
352
|
+
options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination, :select
|
352
353
|
options[:per_page] ||= 999999999
|
353
354
|
options[:page] ||= 1
|
354
355
|
|
@@ -392,8 +393,8 @@ module ActiveScaffold
|
|
392
393
|
|
393
394
|
def append_to_query(query, options)
|
394
395
|
options.assert_valid_keys :where, :select, :group, :reorder, :limit, :offset, :joins, :includes, :lock, :readonly, :from, :conditions
|
395
|
-
query = apply_conditions(query, *options
|
396
|
-
options.reject{|k, v| v.blank?}.inject(query) do |query, (k, v)|
|
396
|
+
query = apply_conditions(query, *options[:conditions]) if options[:conditions]
|
397
|
+
options.reject{|k, v| k == :conditions || v.blank?}.inject(query) do |query, (k, v)|
|
397
398
|
query.send((k.to_sym), v)
|
398
399
|
end
|
399
400
|
end
|
@@ -187,7 +187,7 @@ module ActiveScaffold
|
|
187
187
|
if column.associated_limit.nil?
|
188
188
|
Rails.logger.warn "ActiveScaffold: Enable eager loading for #{column.name} association to reduce SQL queries"
|
189
189
|
elsif column.associated_limit > 0
|
190
|
-
value.target = value.find(:all, :limit => column.associated_limit + 1, :select => column.
|
190
|
+
value.target = value.find(:all, :limit => column.associated_limit + 1, :select => column.select_associated_columns)
|
191
191
|
elsif @cache_associations
|
192
192
|
value.target = size.to_i.zero? ? [] : [nil]
|
193
193
|
end
|
@@ -169,7 +169,7 @@ module ActiveScaffold
|
|
169
169
|
options.delete :link if link.crud_type == :create
|
170
170
|
end
|
171
171
|
if link.action.nil? || (link.type == :member && options.has_key?(:authorized) && !options[:authorized])
|
172
|
-
action_link_html(link, nil, options
|
172
|
+
action_link_html(link, nil, {:link => options[:link], :class => "disabled #{link.action}#{" #{link.html_options[:class]}" unless link.html_options[:class].blank?}"}, record)
|
173
173
|
else
|
174
174
|
url = action_link_url(link, record)
|
175
175
|
html_options = action_link_html_options(link, record, options)
|
@@ -321,9 +321,10 @@ module ActiveScaffold
|
|
321
321
|
url_options
|
322
322
|
end
|
323
323
|
|
324
|
-
def action_link_html_options(link, record,
|
324
|
+
def action_link_html_options(link, record, options)
|
325
325
|
link_id = get_action_link_id(link, record)
|
326
|
-
html_options
|
326
|
+
html_options = link.html_options.merge(:class => [link.html_options[:class], link.action.to_s].compact.join(' '))
|
327
|
+
html_options[:link] = options[:link] if options[:link]
|
327
328
|
|
328
329
|
# Needs to be in html_options to as the adding _method to the url is no longer supported by Rails
|
329
330
|
html_options[:method] = link.method if link.method != :get
|
@@ -331,7 +332,7 @@ module ActiveScaffold
|
|
331
332
|
html_options[:data] = {}
|
332
333
|
html_options[:data][:confirm] = link.confirm(record.try(:to_label)) if link.confirm?
|
333
334
|
if link.inline?
|
334
|
-
html_options[:class]
|
335
|
+
html_options[:class] << ' as_action'
|
335
336
|
html_options[:data][:position] = link.position if link.position
|
336
337
|
html_options[:data][:action] = link.action
|
337
338
|
html_options[:data][:cancel_refresh] = true if link.refresh_on_close
|
@@ -345,13 +346,12 @@ module ActiveScaffold
|
|
345
346
|
html_options[:remote] = true unless link.page? || link.popup?
|
346
347
|
if link.dhtml_confirm?
|
347
348
|
unless link.inline?
|
348
|
-
html_options[:class]
|
349
|
+
html_options[:class] << ' as_action'
|
349
350
|
html_options[:page_link] = 'true'
|
350
351
|
end
|
351
352
|
html_options[:dhtml_confirm] = link.dhtml_confirm.value
|
352
353
|
html_options[:onclick] = link.dhtml_confirm.onclick_function(controller, link_id)
|
353
354
|
end
|
354
|
-
html_options[:class] += " #{link.html_options[:class]}" unless link.html_options[:class].blank?
|
355
355
|
html_options
|
356
356
|
end
|
357
357
|
|
@@ -512,8 +512,9 @@ module ActiveScaffold
|
|
512
512
|
def override_helper(column, suffix)
|
513
513
|
@_override_helpers ||= {}
|
514
514
|
@_override_helpers[suffix] ||= {}
|
515
|
-
|
516
|
-
@_override_helpers[suffix][column.name]
|
515
|
+
@_override_helpers[suffix][@record.class.name] ||= {}
|
516
|
+
return @_override_helpers[suffix][@record.class.name][column.name] if @_override_helpers[suffix][@record.class.name].include? column.name
|
517
|
+
@_override_helpers[suffix][@record.class.name][column.name] = begin
|
517
518
|
method_with_class = override_helper_name(column, suffix, true)
|
518
519
|
if respond_to?(method_with_class)
|
519
520
|
method_with_class
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 2488911141
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 3
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 3.3.0.
|
11
|
+
- 3
|
12
|
+
version: 3.3.0.rc3
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Many, see README
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2013-
|
20
|
+
date: 2013-03-06 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
type: :development
|
@@ -443,7 +443,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
443
443
|
requirements: []
|
444
444
|
|
445
445
|
rubyforge_project:
|
446
|
-
rubygems_version: 1.8.
|
446
|
+
rubygems_version: 1.8.23
|
447
447
|
signing_key:
|
448
448
|
specification_version: 3
|
449
449
|
summary: Rails 3.1 Version of activescaffold supporting prototype and jquery
|