active_scaffold 3.0.22 → 3.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -260,6 +260,10 @@ background: #333 url(../../../images/active_scaffold/default/indicator-small.gif
260
260
  margin-left: 5px;
261
261
  }
262
262
 
263
+ .active-scaffold th.hidden, .active-scaffold td.hidden {
264
+ display: none;
265
+ }
266
+
263
267
  /* Table :: Record Rows
264
268
  ============================= */
265
269
 
@@ -1086,4 +1090,4 @@ padding: 5px 2px 5px 5px;
1086
1090
 
1087
1091
  .as_touch tr.record td {
1088
1092
  padding: 5px 10px;
1089
- }
1093
+ }
@@ -2,9 +2,10 @@
2
2
  <tr>
3
3
  <%
4
4
  active_scaffold_config_for(@record.class).subform.columns.each :for => @record.class, :flatten => true do |column|
5
- next unless in_subform?(column, parent_record) and column_renders_as(column) != :hidden
5
+ hidden = column_renders_as(column) == :hidden
6
+ next unless in_subform?(column, parent_record)
6
7
  -%>
7
- <th<%= ' class="required"' if column.required? %>><label><%= column.label %></label></th>
8
+ <th class="<%= "#{'required' if column.required?} #{'hidden' if hidden}" %>"><label><%= column.label unless hidden %></label></th>
8
9
  <% end -%>
9
10
  </tr>
10
11
  </thead>
@@ -0,0 +1,10 @@
1
+ <thead>
2
+ <tr>
3
+ <%
4
+ active_scaffold_config_for(@record.class).subform.columns.each :for => @record.class, :flatten => true do |column|
5
+ next unless in_subform?(column, parent_record) and column_renders_as(column) != :hidden
6
+ -%>
7
+ <th<%= ' class="required"' if column.required? %>><label><%= column.label %></label></th>
8
+ <% end -%>
9
+ </tr>
10
+ </thead>
@@ -15,7 +15,7 @@
15
15
  column = column.clone
16
16
  column.form_ui ||= :select if column.association
17
17
  -%>
18
- <td>
18
+ <td<%= ' class="hidden"'.html_safe if column_renders_as(column) == :hidden %>>
19
19
  <% unless readonly and not @record.new_record? or not @record.authorized_for?(:crud_type => crud_type, :column => column.name) -%>
20
20
  <%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%>
21
21
  <% else -%>
@@ -0,0 +1,38 @@
1
+ <%
2
+ record_column = column
3
+ readonly = (@record.readonly? or not @record.authorized_for?(:crud_type => :update))
4
+ crud_type = @record.new_record? ? :create : (readonly ? :read : :update)
5
+ show_actions = false
6
+ config = active_scaffold_config_for(@record.class)
7
+ options = active_scaffold_input_options(config.columns[@record.class.primary_key], scope)
8
+ tr_id = "association-#{options[:id]}"
9
+ %>
10
+ <tr id="<%= tr_id %>" class="association-record <%= 'association-record-new' if @record.new_record? -%> <%= 'locked' if locked -%>">
11
+ <% config.subform.columns.each :for => @record.class, :crud_type => crud_type, :flatten => true do |column| %>
12
+ <%
13
+ next unless in_subform?(column, parent_record)
14
+ show_actions = true
15
+ column = column.clone
16
+ column.form_ui ||= :select if column.association
17
+ -%>
18
+ <td class="<%= 'hidden' if column_renders_as(column) == :hidden %>">
19
+ <% unless readonly and not @record.new_record? or not @record.authorized_for?(:crud_type => crud_type, :column => column.name) -%>
20
+ <%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%>
21
+ <% else -%>
22
+ <p><%= get_column_value(@record, column) -%></p>
23
+ <% end -%>
24
+ </td>
25
+ <% end -%>
26
+ <% if show_actions -%>
27
+ <td class="actions">
28
+ <% if record_column.plural_association? and (@record.authorized_for?(:crud_type => :delete) or not [:destroy, :delete_all].include?(record_column.association.options[:dependent])) %>
29
+ <% destroy_id = "#{options[:id]}-destroy" %>
30
+ <%= link_to as_(:remove), '#', :class => 'destroy', :id => destroy_id , :onclick => "ActiveScaffold.delete_subform_record(\"#{tr_id}\"); return false;", :style=> "display: none;" %>
31
+ <%= javascript_tag("ActiveScaffold.show('#{destroy_id}');") if !locked %>
32
+ <% end %>
33
+ <% unless @record.new_record? %>
34
+ <input type="hidden" name="<%= options[:name] -%>" id="<%= options[:id] -%>" value="<%= @record.id -%>" />
35
+ <% end -%>
36
+ </td>
37
+ <% end -%>
38
+ </tr>
@@ -42,8 +42,11 @@ module ActiveScaffold
42
42
  params.merge!({column.association.primary_key_name => ''})
43
43
  end
44
44
 
45
- record_select_options = {:controller => remote_controller, :id => options[:id]}
46
- record_select_options.merge!(active_scaffold_input_text_options)
45
+ record_select_options = active_scaffold_input_text_options(
46
+ :controller => remote_controller,
47
+ :id => options[:id],
48
+ :class => options[:class]
49
+ )
47
50
  record_select_options.merge!(column.options)
48
51
  if options['data-update_url']
49
52
  record_select_options[:onchange] = %|function(id, label) {
@@ -51,11 +54,13 @@ module ActiveScaffold
51
54
  }|
52
55
  end
53
56
 
54
- if multiple
57
+ html = if multiple
55
58
  record_multi_select_field(options[:name], value || [], record_select_options)
56
59
  else
57
60
  record_select_field(options[:name], value || column.association.klass.new, record_select_options)
58
61
  end
62
+ html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
63
+ html
59
64
  end
60
65
  end
61
66
 
@@ -42,9 +42,17 @@ module ActiveScaffold
42
42
  params.merge!({column.association.primary_key_name => ''})
43
43
  end
44
44
 
45
- record_select_options = {:controller => remote_controller, :id => options[:id]}
46
- record_select_options.merge!(active_scaffold_input_text_options)
45
+ record_select_options = active_scaffold_input_text_options(
46
+ :controller => remote_controller,
47
+ :id => options[:id],
48
+ :class => options[:class]
49
+ )
47
50
  record_select_options.merge!(column.options)
51
+ if options['data-update_url']
52
+ record_select_options[:onchange] = %|function(id, label) {
53
+ ActiveScaffold.update_column($("##{options[:id]}"), "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
54
+ }|
55
+ end
48
56
 
49
57
  if multiple
50
58
  record_multi_select_field(options[:name], value || [], record_select_options)
@@ -63,7 +71,7 @@ module ActiveScaffold
63
71
  def field_search_record_select_value(column)
64
72
  begin
65
73
  value = field_search_params[column.name]
66
- value = unless value.blank?
74
+ unless value.blank?
67
75
  if column.options[:multiple]
68
76
  column.association.klass.find value.collect!(&:to_i)
69
77
  else
@@ -74,8 +82,6 @@ module ActiveScaffold
74
82
  logger.error Time.now.to_s + "Sorry, we are not that smart yet. Attempted to restore search values to search fields but instead got -- #{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{@controller.class}"
75
83
  raise e
76
84
  end
77
-
78
- active_scaffold_record_select(column, options, value, column.options[:multiple])
79
85
  end
80
86
  end
81
87
  end
@@ -3,7 +3,9 @@ module ActiveScaffold
3
3
  module AssociationHelpers
4
4
  # Provides a way to honor the :conditions on an association while searching the association's klass
5
5
  def association_options_find(association, conditions = nil)
6
- association.klass.where(conditions).where(association.options[:conditions]).all
6
+ relation = association.klass.where(conditions).where(association.options[:conditions])
7
+ relation = relation.includes(association.options[:include]) if association.options[:include]
8
+ relation.all
7
9
  end
8
10
 
9
11
  def association_options_count(association, conditions = nil)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- PATCH = 22
5
+ PATCH = 23
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
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: 43
4
+ hash: 41
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 22
10
- version: 3.0.22
9
+ - 23
10
+ version: 3.0.23
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-08-30 00:00:00 +02:00
18
+ date: 2011-09-05 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -195,7 +195,9 @@ files:
195
195
  - frontends/default/views/_search_attribute.html.erb
196
196
  - frontends/default/views/action_confirmation.html.erb
197
197
  - frontends/default/views/_base_form.html.erb~
198
+ - frontends/default/views/_horizontal_subform_header.html.erb~
198
199
  - frontends/default/views/_form_association_footer.html.erb~
200
+ - frontends/default/views/_horizontal_subform_record.html.erb~
199
201
  - lib/active_scaffold.rb
200
202
  - lib/active_scaffold_env.rb
201
203
  - lib/active_scaffold/actions/common_search.rb