active_scaffold 3.1.7 → 3.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  <% case ActiveScaffold.js_framework %>
2
2
  <% when :jquery %>
3
3
  <% require_asset "jquery-ui" %>
4
+ <% require_asset "jquery-ui-timepicker-addon" %>
4
5
  <% require_asset "jquery/active_scaffold" %>
5
6
  <% require_asset "jquery/jquery.editinplace" %>
6
7
  <% require_asset "jquery/date_picker_bridge" %>
@@ -1,6 +1,6 @@
1
1
  <table cellpadding="0" cellspacing="0">
2
2
  <%
3
- record = if associated.empty?
3
+ @record = if associated.empty?
4
4
  if column.singular_association?
5
5
  parent_record.send("build_#{column.name}".to_sym)
6
6
  else
@@ -10,7 +10,7 @@
10
10
  associated.last
11
11
  end
12
12
  -%>
13
- <%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record, :record => record} %>
13
+ <%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record, :record => @record} %>
14
14
 
15
15
  <tbody id="<%= sub_form_list_id(:association => column.name) %>">
16
16
  <% associated.each_index do |index| %>
@@ -25,8 +25,8 @@
25
25
  <%= render :partial => 'horizontal_subform_record', :locals => {:scope => column_scope(column), :parent_record => parent_record, :column => column, :locked => show_blank_record && @record.new_record? && @record == associated.last} %>
26
26
  <% end -%>
27
27
  </tbody>
28
- <tfooter>
28
+ <tfoot>
29
29
  <%= render :partial => 'horizontal_subform_footer', :locals => {:scope => column_scope(column), :parent_record => parent_record, :column => column} %>
30
- </tfooter>
30
+ </tfoot>
31
31
  </table>
32
32
  <%= render :partial => 'form_association_footer', :locals => {:parent_record => parent_record, :column => column, :associated => associated} -%>
@@ -1,6 +1,6 @@
1
1
  <table cellpadding="0" cellspacing="0">
2
2
  <%
3
- record = if associated.empty?
3
+ @record = if associated.empty?
4
4
  if column.singular_association?
5
5
  parent_record.send("build_#{column.name}".to_sym)
6
6
  else
@@ -10,7 +10,7 @@
10
10
  associated.last
11
11
  end
12
12
  -%>
13
- <%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record, :record => record} %>
13
+ <%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record, :record => @record} %>
14
14
 
15
15
  <tbody id="<%= sub_form_list_id(:association => column.name) %>">
16
16
  <% associated.each_index do |index| %>
@@ -25,5 +25,8 @@
25
25
  <%= render :partial => 'horizontal_subform_record', :locals => {:scope => column_scope(column), :parent_record => parent_record, :column => column, :locked => show_blank_record && @record.new_record? && @record == associated.last} %>
26
26
  <% end -%>
27
27
  </tbody>
28
+ <tfooter>
29
+ <%= render :partial => 'horizontal_subform_footer', :locals => {:scope => column_scope(column), :parent_record => parent_record, :column => column} %>
30
+ </tfooter>
28
31
  </table>
29
32
  <%= render :partial => 'form_association_footer', :locals => {:parent_record => parent_record, :column => column, :associated => associated} -%>
@@ -36,8 +36,8 @@ module ActiveScaffold::Actions
36
36
  @scope = params[:scope]
37
37
 
38
38
  if column.send_form_on_update_column
39
- hash = if params[:scope]
40
- params[:scope].gsub('[','').split(']').inject(params[:record]) do |hash, index|
39
+ hash = if @scope
40
+ @scope.gsub('[','').split(']').inject(params[:record]) do |hash, index|
41
41
  hash[index]
42
42
  end
43
43
  else
@@ -165,7 +165,7 @@ module ActiveScaffold::Actions
165
165
  params = params[:record] || {} unless params[model.inheritance_column] # in create action must be inside record key
166
166
  model = params.delete(model.inheritance_column).camelize.constantize if params[model.inheritance_column]
167
167
  end
168
- model.respond_to?(:build) ? model.build(build_options || {}) : model.new
168
+ model.new(build_options || {})
169
169
  end
170
170
 
171
171
  private
@@ -16,6 +16,8 @@ class ActiveScaffold::Bridges::RecordSelect
16
16
  active_scaffold_record_select(column, options, @record.send(column.name), multiple)
17
17
  elsif column.plural_association?
18
18
  active_scaffold_record_select(column, options, @record.send(column.name), true)
19
+ else
20
+ active_scaffold_record_select_autocomplete(column, options)
19
21
  end
20
22
  end
21
23
 
@@ -51,6 +53,23 @@ class ActiveScaffold::Bridges::RecordSelect
51
53
  html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
52
54
  html
53
55
  end
56
+
57
+ def active_scaffold_record_select_autocomplete(column, options)
58
+ record_select_options = active_scaffold_input_text_options(
59
+ :controller => active_scaffold_controller_for(@record.class).controller_path,
60
+ :id => options[:id],
61
+ :class => options[:class].gsub(/update_form/, '')
62
+ )
63
+ if options['data-update_url']
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], @record, record_select_options)
70
+ html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
71
+ html
72
+ end
54
73
  end
55
74
 
56
75
  module SearchColumnHelpers
@@ -16,6 +16,8 @@ class ActiveScaffold::Bridges::RecordSelect
16
16
  active_scaffold_record_select(column, options, @record.send(column.name), multiple)
17
17
  elsif column.plural_association?
18
18
  active_scaffold_record_select(column, options, @record.send(column.name), true)
19
+ else
20
+ active_scaffold_record_select_autocomplete(column, options)
19
21
  end
20
22
  end
21
23
 
@@ -34,7 +36,7 @@ class ActiveScaffold::Bridges::RecordSelect
34
36
  record_select_options = active_scaffold_input_text_options(
35
37
  :controller => remote_controller,
36
38
  :id => options[:id],
37
- :class => options[:class]
39
+ :class => options[:class].gsub(/update_form/, '')
38
40
  )
39
41
  record_select_options.merge!(column.options)
40
42
  if options['data-update_url']
@@ -51,6 +53,23 @@ class ActiveScaffold::Bridges::RecordSelect
51
53
  html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
52
54
  html
53
55
  end
56
+
57
+ def active_scaffold_record_select_autocomplete(column, options)
58
+ record_select_options = active_scaffold_input_text_options(
59
+ :controller => active_scaffold_controller_for(@record.class).controller_path,
60
+ :id => options[:id],
61
+ :class => options[:class].gsub(/update_form/, '')
62
+ )
63
+ if options['data-update_url']
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)
70
+ html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
71
+ html
72
+ end
54
73
  end
55
74
 
56
75
  module SearchColumnHelpers
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 7
5
+ PATCH = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end