active_scaffold 3.0.25 → 3.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/frontends/default/views/add_existing.js.erb~ +18 -0
- data/lib/active_scaffold/actions/create.rb~ +2 -3
- data/lib/active_scaffold/actions/update.rb~ +4 -2
- data/lib/active_scaffold/bridges/record_select/helpers.rb~ +6 -20
- data/lib/active_scaffold/data_structures/nested_info.rb +1 -1
- data/lib/active_scaffold/data_structures/nested_info.rb~ +3 -4
- data/lib/active_scaffold/extensions/active_association_reflection.rb~ +22 -0
- data/lib/active_scaffold/helpers/controller_helpers.rb~ +5 -12
- data/lib/active_scaffold/helpers/search_column_helpers.rb~ +1 -1
- data/lib/active_scaffold/version.rb +1 -1
- metadata +19 -17
@@ -0,0 +1,18 @@
|
|
1
|
+
<% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
|
2
|
+
ActiveScaffold.create_record_row('<%= active_scaffold_id %>', '<%= escape_javascript(new_row) %>', <%= {:insert_at => :top}.to_json.html_safe %>);
|
3
|
+
|
4
|
+
<% if active_scaffold_config.list.columns.any? {|c| c.calculation?} %>
|
5
|
+
ActiveScaffold.replace('<%= active_scaffold_calculations_id %>', '<%= escape_javascript(render(:partial => 'list_calculations')) %>');
|
6
|
+
<%end%>
|
7
|
+
|
8
|
+
<% if form_stays_open ||= true %>
|
9
|
+
<%# why not just re-render the form? that wouldn't utilize a possible do_new override which sets default values.%>
|
10
|
+
ActiveScaffold.reset_form('<%= element_form_id %>');
|
11
|
+
ActiveScaffold.replace_html('<%= element_messages_id(:action => :add_existing) %>', '<%= escape_javascript(render(:partial => 'form_messages')) %>');
|
12
|
+
<%# have to delay the focus, because there's no "firstElement" in prototype until at least one element is not disabled%>
|
13
|
+
<% if ActiveScaffold.js_framework == :prototype %>
|
14
|
+
ActiveScaffold.focus_first_element_of_form.defer('<%= element_form_id %>');
|
15
|
+
<% end %>
|
16
|
+
<% else %>
|
17
|
+
ActiveScaffold.find_action_link('<%element_form_id(:action => :new_existing)%>').close();
|
18
|
+
<% end %>
|
@@ -2,9 +2,6 @@ module ActiveScaffold::Actions
|
|
2
2
|
module Create
|
3
3
|
def self.included(base)
|
4
4
|
base.before_filter :create_authorized_filter, :only => [:new, :create]
|
5
|
-
base.verify :method => :post,
|
6
|
-
:only => :create,
|
7
|
-
:redirect_to => { :action => :index }
|
8
5
|
end
|
9
6
|
|
10
7
|
def new
|
@@ -106,6 +103,8 @@ module ActiveScaffold::Actions
|
|
106
103
|
create_save
|
107
104
|
end
|
108
105
|
rescue ActiveRecord::RecordInvalid
|
106
|
+
self.successful = false
|
107
|
+
flash[:error] = $!.messages
|
109
108
|
end
|
110
109
|
end
|
111
110
|
|
@@ -18,7 +18,7 @@ module ActiveScaffold::Actions
|
|
18
18
|
# for inline (inlist) editing
|
19
19
|
def update_column
|
20
20
|
do_update_column
|
21
|
-
|
21
|
+
@column_span_id = params[:editor_id] || params[:editorId]
|
22
22
|
end
|
23
23
|
|
24
24
|
protected
|
@@ -92,9 +92,11 @@ module ActiveScaffold::Actions
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
rescue ActiveRecord::RecordInvalid
|
95
|
+
self.successful = false
|
96
|
+
flash[:error] = $!.message
|
95
97
|
rescue ActiveRecord::StaleObjectError
|
96
98
|
@record.errors.add(:base, as_(:version_inconsistency))
|
97
|
-
self.successful=false
|
99
|
+
self.successful = false
|
98
100
|
rescue ActiveRecord::RecordNotSaved
|
99
101
|
@record.errors.add(:base, as_(:record_not_saved)) if @record.errors.empty?
|
100
102
|
self.successful = false
|
@@ -33,17 +33,10 @@ class ActiveScaffold::Bridges::RecordSelect
|
|
33
33
|
params.merge!({column.association.primary_key_name => ''})
|
34
34
|
end
|
35
35
|
|
36
|
-
record_select_options = active_scaffold_input_text_options(
|
37
|
-
:controller => remote_controller
|
38
|
-
:id => options[:id],
|
39
|
-
:class => options[:class].gsub(/update_form/, '')
|
36
|
+
record_select_options = active_scaffold_input_text_options(options).merge(
|
37
|
+
:controller => remote_controller
|
40
38
|
)
|
41
39
|
record_select_options.merge!(column.options)
|
42
|
-
if options['data-update_url']
|
43
|
-
record_select_options[:onchange] = %|function(id, label) {
|
44
|
-
ActiveScaffold.update_column(null, "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
|
45
|
-
}|
|
46
|
-
end
|
47
40
|
|
48
41
|
html = if multiple
|
49
42
|
record_multi_select_field(options[:name], value || [], record_select_options)
|
@@ -55,18 +48,11 @@ class ActiveScaffold::Bridges::RecordSelect
|
|
55
48
|
end
|
56
49
|
|
57
50
|
def active_scaffold_record_select_autocomplete(column, options)
|
58
|
-
|
59
|
-
|
60
|
-
:
|
61
|
-
:class => options[:class].gsub(/update_form/, '')
|
51
|
+
remote_controller = active_scaffold_controller_for(column.association.klass).controller_path
|
52
|
+
record_select_options = active_scaffold_input_text_options(options).merge(
|
53
|
+
:controller => remote_controller
|
62
54
|
)
|
63
|
-
|
64
|
-
record_select_options[:onchange] = %|function(id, label) {
|
65
|
-
ActiveScaffold.update_column(null, "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
|
66
|
-
}|
|
67
|
-
end
|
68
|
-
|
69
|
-
html = record_select_autocomplete(options[:name], value, record_select_options)
|
55
|
+
html = record_select_autocomplete(options[:name], @record, record_select_options)
|
70
56
|
html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
|
71
57
|
html
|
72
58
|
end
|
@@ -107,7 +107,7 @@ module ActiveScaffold::DataStructures
|
|
107
107
|
if association.primary_key_name == current.primary_key_name
|
108
108
|
# show columns for has_many and has_one child associationes
|
109
109
|
constrained_fields << current.name.to_sym if current.belongs_to?
|
110
|
-
@child_association = current
|
110
|
+
@child_association = current if current.klass == @parent_model
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -6,7 +6,6 @@ module ActiveScaffold::DataStructures
|
|
6
6
|
else
|
7
7
|
session_info = session_storage[:nested].clone
|
8
8
|
begin
|
9
|
-
debugger
|
10
9
|
session_info[:parent_scaffold] = "#{session_info[:parent_scaffold].to_s.camelize}Controller".constantize
|
11
10
|
session_info[:parent_model] = session_info[:parent_scaffold].active_scaffold_config.model
|
12
11
|
session_info[:association] = session_info[:parent_model].reflect_on_association(session_info[:name])
|
@@ -99,13 +98,13 @@ module ActiveScaffold::DataStructures
|
|
99
98
|
|
100
99
|
def iterate_model_associations(model)
|
101
100
|
@constrained_fields = []
|
102
|
-
@constrained_fields << association.
|
101
|
+
@constrained_fields << association.primary_key_name.to_sym unless association.belongs_to?
|
103
102
|
model.reflect_on_all_associations.each do |current|
|
104
|
-
if !current.belongs_to? && association.
|
103
|
+
if !current.belongs_to? && association.primary_key_name == current.association_foreign_key
|
105
104
|
constrained_fields << current.name.to_sym
|
106
105
|
@child_association = current if current.klass == @parent_model
|
107
106
|
end
|
108
|
-
if association.
|
107
|
+
if association.primary_key_name == current.primary_key_name
|
109
108
|
# show columns for has_many and has_one child associationes
|
110
109
|
constrained_fields << current.name.to_sym if current.belongs_to?
|
111
110
|
@child_association = current
|
@@ -0,0 +1,22 @@
|
|
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
|
+
# https://github.com/rails/rails/issues/815
|
4
|
+
# https://github.com/rails/rails/pull/1686
|
5
|
+
ActiveRecord::Reflection::AssociationReflection.class_eval do
|
6
|
+
def klass_with_sti(*opts)
|
7
|
+
sti_col = klass.inheritance_column
|
8
|
+
if (h = opts.first).is_a? Hash and (passed_type = ( h[sti_col] || h[sti_col.to_sym] )) and (new_klass = active_record.send(:compute_type, passed_type)) < klass
|
9
|
+
new_klass
|
10
|
+
else
|
11
|
+
klass
|
12
|
+
end
|
13
|
+
end
|
14
|
+
def build_association(*opts, &block)
|
15
|
+
self.original_build_association_called = true
|
16
|
+
klass_with_sti(*opts).new(*opts, &block)
|
17
|
+
end
|
18
|
+
def create_association(*opts, &block)
|
19
|
+
self.original_build_association_called = true
|
20
|
+
klass_with_sti(*opts).create(*opts, &block)
|
21
|
+
end
|
22
|
+
end
|
@@ -33,8 +33,7 @@ module ActiveScaffold
|
|
33
33
|
parameters[:eid] = params[:parent_controller]
|
34
34
|
end
|
35
35
|
if nested?
|
36
|
-
parameters
|
37
|
-
parameters[:eid] = nil
|
36
|
+
parameters.merge! nested.to_params
|
38
37
|
end
|
39
38
|
if params[:parent_sti]
|
40
39
|
parameters[:controller] = params[:parent_sti]
|
@@ -84,17 +83,11 @@ module ActiveScaffold
|
|
84
83
|
end
|
85
84
|
|
86
85
|
def build_associated(column, record)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
child.send(:"#{reflection.reverse}=", record)
|
92
|
-
# TODO: Might want to extend with this branch in the future
|
93
|
-
# else # plural
|
94
|
-
# child.send(:"#{reflection.reverse}") << record
|
95
|
-
end
|
86
|
+
if column.singular_association?
|
87
|
+
record.send(:"build_#{column.name}")
|
88
|
+
else
|
89
|
+
record.send(column.name).build
|
96
90
|
end
|
97
|
-
child
|
98
91
|
end
|
99
92
|
end
|
100
93
|
end
|
@@ -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, select_options, options, html_options)
|
92
92
|
end
|
93
93
|
|
94
94
|
def active_scaffold_search_text(column, options)
|
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: 51
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 3.0.
|
9
|
+
- 26
|
10
|
+
version: 3.0.26
|
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: 2011-12-
|
18
|
+
date: 2011-12-28 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -155,37 +155,37 @@ files:
|
|
155
155
|
- frontends/default/views/_list_pagination_links.html.erb
|
156
156
|
- frontends/default/views/_list_record.html.erb
|
157
157
|
- frontends/default/views/_action_group.html.erb
|
158
|
-
- frontends/default/views/_list_messages.html.erb
|
159
|
-
- frontends/default/views/_row.html.erb
|
160
158
|
- frontends/default/views/_messages.html.erb
|
159
|
+
- frontends/default/views/_base_form.html.erb
|
160
|
+
- frontends/default/views/_render_field.js.rjs
|
161
161
|
- frontends/default/views/_search.html.erb
|
162
162
|
- frontends/default/views/_show.html.erb
|
163
163
|
- frontends/default/views/list.html.erb
|
164
|
-
- frontends/default/views/list.js.rjs
|
165
164
|
- frontends/default/views/_show_columns.html.erb
|
166
165
|
- frontends/default/views/_update_actions.html.erb
|
167
166
|
- frontends/default/views/_update_form.html.erb
|
168
167
|
- frontends/default/views/_vertical_subform.html.erb
|
169
168
|
- frontends/default/views/_vertical_subform_record.html.erb
|
170
|
-
- frontends/default/views/
|
169
|
+
- frontends/default/views/_row.html.erb
|
170
|
+
- frontends/default/views/list.js.rjs
|
171
171
|
- frontends/default/views/delete.html.erb
|
172
172
|
- frontends/default/views/add_existing_form.html.erb
|
173
173
|
- frontends/default/views/create.html.erb
|
174
|
+
- frontends/default/views/_list_messages.html.erb
|
174
175
|
- frontends/default/views/_human_conditions.html.erb
|
175
|
-
- frontends/default/views/_list_with_header.html.erb
|
176
176
|
- frontends/default/views/field_search.html.erb
|
177
|
-
- frontends/default/views/_render_field.js.rjs
|
178
|
-
- frontends/default/views/search.html.erb
|
179
177
|
- frontends/default/views/add_existing.js.rjs
|
178
|
+
- frontends/default/views/search.html.erb
|
179
|
+
- frontends/default/views/destroy.js.rjs
|
180
180
|
- frontends/default/views/update.html.erb
|
181
|
+
- frontends/default/views/_list_with_header.html.erb
|
181
182
|
- frontends/default/views/_list_pagination.html.erb
|
182
|
-
- frontends/default/views/_list_record_columns.html.erb
|
183
183
|
- frontends/default/views/show.html.erb
|
184
|
-
- frontends/default/views/
|
184
|
+
- frontends/default/views/form_messages.js.rjs
|
185
|
+
- frontends/default/views/_list_record_columns.html.erb
|
186
|
+
- frontends/default/views/edit_associated.js.rjs
|
185
187
|
- frontends/default/views/_search_attribute.html.erb
|
186
188
|
- frontends/default/views/action_confirmation.html.erb
|
187
|
-
- frontends/default/views/edit_associated.js.rjs
|
188
|
-
- frontends/default/views/form_messages.js.rjs
|
189
189
|
- frontends/default/views/on_action_update.js.rjs
|
190
190
|
- frontends/default/views/on_create.js.rjs
|
191
191
|
- frontends/default/views/on_mark_all.js.rjs
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- frontends/default/views/_horizontal_subform_record.html.erb~
|
218
218
|
- frontends/default/views/_list_with_header.html.erb~
|
219
219
|
- frontends/default/views/_update_form.html.erb~
|
220
|
+
- frontends/default/views/add_existing.js.erb~
|
220
221
|
- lib/active_scaffold.rb
|
221
222
|
- lib/active_scaffold_env.rb
|
222
223
|
- lib/active_scaffold/actions/core.rb
|
@@ -228,9 +229,9 @@ files:
|
|
228
229
|
- lib/active_scaffold/actions/show.rb
|
229
230
|
- lib/active_scaffold/actions/nested.rb
|
230
231
|
- lib/active_scaffold/actions/search.rb
|
231
|
-
- lib/active_scaffold/actions/mark.rb
|
232
232
|
- lib/active_scaffold/actions/subform.rb
|
233
233
|
- lib/active_scaffold/actions/update.rb
|
234
|
+
- lib/active_scaffold/actions/mark.rb
|
234
235
|
- lib/active_scaffold/actions/core.rb~
|
235
236
|
- lib/active_scaffold/actions/nested.rb~
|
236
237
|
- lib/active_scaffold/actions/update.rb~
|
@@ -267,9 +268,9 @@ files:
|
|
267
268
|
- lib/active_scaffold/data_structures/set.rb
|
268
269
|
- lib/active_scaffold/data_structures/sorting.rb
|
269
270
|
- lib/active_scaffold/data_structures/nested_info.rb
|
271
|
+
- lib/active_scaffold/data_structures/nested_info.rb~
|
270
272
|
- lib/active_scaffold/data_structures/action_columns.rb~
|
271
273
|
- lib/active_scaffold/data_structures/action_link.rb~
|
272
|
-
- lib/active_scaffold/data_structures/nested_info.rb~
|
273
274
|
- lib/active_scaffold/finder.rb
|
274
275
|
- lib/active_scaffold/helpers/association_helpers.rb
|
275
276
|
- lib/active_scaffold/helpers/controller_helpers.rb
|
@@ -365,6 +366,7 @@ files:
|
|
365
366
|
- lib/active_scaffold/extensions/reverse_associations.rb~
|
366
367
|
- lib/active_scaffold/extensions/routing_mapper.rb~
|
367
368
|
- lib/active_scaffold/extensions/unsaved_associated.rb~
|
369
|
+
- lib/active_scaffold/extensions/active_association_reflection.rb~
|
368
370
|
- lib/active_scaffold/paginator.rb
|
369
371
|
- lib/active_scaffold/responds_to_parent.rb
|
370
372
|
- lib/active_scaffold/attribute_params.rb~
|