active_scaffold 3.0.24 → 3.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. data/frontends/default/javascripts/jquery/active_scaffold.js +7 -4
  2. data/frontends/default/javascripts/prototype/active_scaffold.js +1 -1
  3. data/frontends/default/views/_form_association_footer.html.erb +2 -2
  4. data/frontends/default/views/_horizontal_subform.html.erb~ +5 -2
  5. data/frontends/default/views/_horizontal_subform_header.html.erb~ +1 -1
  6. data/frontends/default/views/_horizontal_subform_record.html.erb~ +1 -1
  7. data/frontends/default/views/_list_with_header.html.erb~ +32 -0
  8. data/frontends/default/views/_show.html.erb~ +8 -0
  9. data/frontends/default/views/_update_form.html.erb~ +6 -0
  10. data/frontends/default/views/on_create.js.erb~ +45 -0
  11. data/frontends/default/views/on_update.js.erb~ +31 -0
  12. data/frontends/default/views/update_column.js.erb~ +16 -0
  13. data/lib/active_scaffold/actions/core.rb~ +3 -3
  14. data/lib/active_scaffold/actions/create.rb +1 -1
  15. data/lib/active_scaffold/actions/list.rb~ +3 -3
  16. data/lib/active_scaffold/actions/update.rb~ +0 -1
  17. data/lib/active_scaffold/attribute_params.rb~ +2 -1
  18. data/lib/active_scaffold/bridges/record_select/helpers.rb~ +20 -1
  19. data/lib/active_scaffold/config/base.rb~ +70 -0
  20. data/lib/active_scaffold/extensions/action_controller_rendering.rb~ +1 -1
  21. data/lib/active_scaffold/extensions/action_view_rendering.rb~ +13 -1
  22. data/lib/active_scaffold/finder.rb +1 -1
  23. data/lib/active_scaffold/helpers/form_column_helpers.rb~ +1 -2
  24. data/lib/active_scaffold/helpers/list_column_helpers.rb~ +12 -10
  25. data/lib/active_scaffold/version.rb +1 -1
  26. metadata +34 -27
@@ -153,10 +153,13 @@ $(document).ready(function() {
153
153
  $(this).prevAll('img.loading-indicator').css('visibility','hidden');
154
154
  return true;
155
155
  });
156
- $('input[type=button].as_add_existing, input[type=button].as_replace_existing').live('ajax:before', function(event) {
157
- var url = $(this).attr('href').replace('--ID--', $(this).prev().val());
158
- event.data_url = url;
159
- return true;
156
+ $('a.as_add_existing, a.as_replace_existing').live('ajax:before', function(event) {
157
+ var id = $(this).prev().val();
158
+ if (id) {
159
+ if (!$(this).data('href')) $(this).data('href', $(this).attr('href'));
160
+ $(this).attr('href', $(this).data('href').replace('--ID--', id));
161
+ return true;
162
+ } else return false;
160
163
  });
161
164
  $('input.update_form, select.update_form').live('change', function(event) {
162
165
  var element = $(this);
@@ -230,7 +230,7 @@ document.observe("dom:loaded", function() {
230
230
  if(loading_indicator) loading_indicator.style.visibility = 'hidden';
231
231
  return true;
232
232
  });
233
- document.on('ajax:before', 'input[type=button].as_add_existing, input[type=button].as_replace_existing', function(event) {
233
+ document.on('ajax:before', 'a.as_add_existing, a.as_replace_existing', function(event) {
234
234
  var button = event.findElement();
235
235
  var url = button.readAttribute('href').sub('--ID--', button.previous().getValue());
236
236
  event.memo.url = url;
@@ -26,7 +26,7 @@ add_new_url = url_for(:action => 'edit_associated', :id => parent_record.id, :as
26
26
  add_class = 'as_replace_with_new'
27
27
  end
28
28
  create_another_id = "#{sub_form_id(:association => column.name)}-create-another" %>
29
- <%= tag(:input, {:id => create_another_id, :type => 'button', :value => add_label, :href => add_new_url.html_safe, 'data-remote' => true, :class => add_class, :style=> "display: none;"}) %>
29
+ <%= link_to add_label, add_new_url, :id => create_another_id, :remote => true, :class => add_class, :style=> "display: none;" %>
30
30
  <%= javascript_tag("ActiveScaffold.show('#{create_another_id}');") %>
31
31
  <% end -%>
32
32
 
@@ -39,7 +39,7 @@ add_new_url = url_for(:action => 'edit_associated', :id => parent_record.id, :as
39
39
  <% select_options = options_for_select(options_for_association(column.association))
40
40
  add_existing_id = "#{sub_form_id(:association => column.name)}-add-existing" %>
41
41
  <%= select_tag 'associated_id', '<option value="">'.html_safe + as_(:_select_) + '</option>'.html_safe + select_options %>
42
- <%= tag(:input, {:id => add_existing_id, :type => 'button', :value => as_(:add_existing), :href => edit_associated_url.html_safe, 'data-remote' => true, :class=> column.plural_association? ? 'as_add_existing' : 'as_replace_existing', :style => "display: none;"}) %>
42
+ <%= link_to as_(:add_existing), edit_associated_url, :id => add_existing_id, :remote => true, :class=> column.plural_association? ? 'as_add_existing' : 'as_replace_existing', :style => "display: none;" %>
43
43
  <%= javascript_tag("ActiveScaffold.show('#{add_existing_id}');") %>
44
44
  <% end -%>
45
45
  <% end -%>
@@ -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} -%>
@@ -1,7 +1,7 @@
1
1
  <thead>
2
2
  <tr>
3
3
  <%
4
- active_scaffold_config_for(@record.class).subform.columns.each :for => @record.class, :flatten => true do |column|
4
+ active_scaffold_config_for(record.class).subform.columns.each :for => record.class, :flatten => true do |column|
5
5
  hidden = column_renders_as(column) == :hidden
6
6
  next unless in_subform?(column, parent_record)
7
7
  -%>
@@ -15,7 +15,7 @@
15
15
  column = column.clone
16
16
  column.form_ui ||= :select if column.association
17
17
  -%>
18
- <td class="<%= 'hidden' if column_renders_as(column) == :hidden %>">
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,32 @@
1
+ <div id="<%= active_scaffold_id -%>" class="<%= as_main_div_class %>" <%= "data-eid=#{id_from_controller(params[:eid])}" if params[:eid]%>>
2
+ <div class="active-scaffold-header">
3
+ <%= render :partial => 'list_header' %>
4
+ </div>
5
+ <table cellpadding="0" cellspacing="0">
6
+ <tbody class="before-header" id="<%= before_header_id -%>">
7
+ <% if active_scaffold_config.list.always_show_search %>
8
+ <tr>
9
+ <td>
10
+ <div class="active-scaffold show_search-view <%= "#{params[:controller]}-view" %> view">
11
+ <%= render :partial => active_scaffold_config.list.search_partial %>
12
+ </div>
13
+ </td>
14
+ </tr>
15
+ <% else %>
16
+ <tr><td></td></tr>
17
+ <% end %>
18
+ <% if !nested? && active_scaffold_config.list.always_show_create %>
19
+ <tr>
20
+ <td>
21
+ <div class="active-scaffold create-view <%= "#{params[:controller]}-view" %> view">
22
+ <%= render :partial => 'create_form_on_list' %>
23
+ </div>
24
+ </td>
25
+ </tr>
26
+ <% end %>
27
+ </tbody>
28
+ </table>
29
+ <div id="<%= active_scaffold_content_id-%>" class="as_content">
30
+ <%= render :partial => 'list' %>
31
+ </div>
32
+ </div>
@@ -0,0 +1,8 @@
1
+ <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : clean_column_value(@record.to_label)) %></h4>
2
+
3
+ <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns} -%>
4
+
5
+ <p class="form-footer">
6
+ <%= link_to as_(:close), main_path_to_return, :class => 'as_cancel', :remote => request.xhr?, 'data-refresh' => false %>
7
+ <%= loading_indicator_tag(:action => :create, :id => params[:id]) %>
8
+ </p>
@@ -0,0 +1,6 @@
1
+ <% cancel_link = true if cancel_link.nil? %>
2
+ <%= render :partial => "base_form", :locals => {:xhr => xhr ||= nil,
3
+ :form_action => form_action ||= :update,
4
+ :method => method ||= :put,
5
+ :cancel_link => cancel_link,
6
+ :headline => headline ||= @record.to_label.nil? ? active_scaffold_config.update.label : as_(:update_model, :model => clean_column_value(@record.to_label))} %>
@@ -0,0 +1,45 @@
1
+ try {
2
+ <% form_selector = "#{element_form_id(:action => :create)}"
3
+ insert_at ||= :top %>
4
+ var action_link = ActiveScaffold.find_action_link('<%= form_selector%>');
5
+ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages').strip)%>');
6
+ <% if controller.send :successful? %>
7
+ <% if render_parent? && controller.respond_to?(:render_component_into_view) %>
8
+ <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
9
+ <% if nested_singular_association? %>
10
+ action_link.close('<%= escape_javascript(parent_rendered)%>');
11
+ <% else %>
12
+ <% if render_parent_action == :row %>
13
+ ActiveScaffold.create_record_row(action_link.scaffold(),'<%= escape_javascript(parent_rendered)%>', <%= {:insert_at => insert_at}.to_json.html_safe %>);
14
+ <% elsif render_parent_action == :index %>
15
+ <%= escape_javascript(parent_rendered) %>
16
+ <% end %>
17
+ action_link.close();
18
+ <% end %>
19
+ <%#page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
20
+ <% elsif (active_scaffold_config.create.refresh_list) %>
21
+ ActiveScaffold.replace_html(<%= active_scaffold_content_id%>, <%= escape_javascript(render(:partial => 'list', :layout => false)) %>);
22
+ <% elsif params[:parent_controller].nil? %>
23
+ <% new_row = render :partial => 'list_record', :locals => {:record => @record} %>
24
+ ActiveScaffold.create_record_row(action_link.scaffold(),'<%=escape_javascript(new_row)%>', <%={:insert_at => insert_at}.to_json.html_safe%>);
25
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
26
+ ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <% unless render_parent? %>
31
+ <% if (active_scaffold_config.create.persistent) %>
32
+ action_link.reload();
33
+ <% else %>
34
+ action_link.close();
35
+ <% end %>
36
+ <% if (active_scaffold_config.create.action_after_create) %>
37
+ var link = $('<%=action_link_id active_scaffold_config.create.action_after_create, @record.id%>');
38
+ if (link) (function() { link.action_link.open() }).defer();
39
+ <% end %>
40
+ <% end %>
41
+ <% else %>
42
+ ActiveScaffold.replace('<%=form_selector%>','<%=escape_javascript(render(:partial => 'create_form', :locals => {:xhr => true}))%>');
43
+ ActiveScaffold.scroll_to('<%=form_selector%>');
44
+ <% end %>
45
+ } catch (e) { alert('RJS error:\n\n' + e.toString());}
@@ -0,0 +1,31 @@
1
+ try {
2
+ <% form_selector = "#{element_form_id(:action => :update)}" %>
3
+ var action_link = ActiveScaffold.find_action_link('<%= form_selector%>');
4
+ action_link.update_flash_messages('<%=escape_javascript(render(:partial => 'messages').strip)%>');
5
+ <% if controller.send :successful? %>
6
+ <% if render_parent? && controller.respond_to?(:render_component_into_view) %>
7
+ <% parent_rendered = controller.send(:render_component_into_view, render_parent_options) %>
8
+ <% if nested_singular_association? %>
9
+ action_link.close('<%= escape_javascript(parent_rendered)%>');
10
+ <% else %>
11
+ <% if render_parent_action == :row %>
12
+ action_link.close('<%= escape_javascript(parent_rendered)%>');
13
+ <% elsif render_parent_action == :index %>
14
+ <%= escape_javascript(parent_rendered) %>
15
+ <% end %>
16
+ <% end %>
17
+ <%#page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
18
+ <% elsif update_refresh_list? %>
19
+ ActiveScaffold.replace_html('<%= active_scaffold_content_id%>', '<%= escape_javascript(render(:partial => 'list', :layout => false))%>');
20
+ <% else %>
21
+ <% updated_row = render :partial => 'list_record', :locals => {:record => @record}%>
22
+ action_link.close('<%= escape_javascript(updated_row)%>');
23
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
24
+ ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
25
+ <% end %>
26
+ <% end %>
27
+ <% else %>
28
+ ActiveScaffold.replace('<%=form_selector%>','<%=escape_javascript(render(:partial => 'update_form', :locals => {:xhr => true}))%>');
29
+ ActiveScaffold.scroll_to('<%=form_selector%>');
30
+ <% end %>
31
+ } catch (e) { alert('RJS error:\n\n' + e.toString());}
@@ -0,0 +1,16 @@
1
+ <% @column_span_id ||= element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column]) %>
2
+ <% unless controller.send :successful?%>
3
+ alert('<%= escape_javascript(@record.errors.full_messages.join("\n"))%>');
4
+ <% @record.reload%>
5
+ <% end%>
6
+ <% column = active_scaffold_config.columns[params[:column]]%>
7
+ <% if column.inplace_edit%>
8
+ ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(format_inplace_edit_column(@record, column))%>');
9
+ <% else%>
10
+ <% formatted_value = get_column_value(@record, column)%>
11
+ ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(formatted_value)%>');
12
+ <% end%>
13
+ <% if column.calculation?%>
14
+ ActiveScaffold.replace_html('<%=active_scaffold_calculations_id(column)%>', '<%=escape_javascript(render_column_calculation(column))%>');
15
+ <% end%>
16
+
@@ -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
@@ -42,7 +42,7 @@ module ActiveScaffold::Actions
42
42
  else
43
43
  if successful?
44
44
  flash[:info] = as_(:created_model, :model => @record.to_label)
45
- if active_scaffold_config.create.edit_after_create
45
+ if active_scaffold_config.create.action_after_create
46
46
  redirect_to params_for(:action => "edit", :id => @record.id)
47
47
  elsif active_scaffold_config.create.persistent
48
48
  redirect_to params_for(:action => "new")
@@ -17,8 +17,6 @@ module ActiveScaffold::Actions
17
17
 
18
18
  def list
19
19
  do_list
20
- do_new if active_scaffold_config.list.always_show_create
21
- @record ||= new_model if active_scaffold_config.list.always_show_search
22
20
  @nested_auto_open = active_scaffold_config.list.nested_auto_open
23
21
  respond_to_action(:list)
24
22
  end
@@ -175,7 +173,9 @@ module ActiveScaffold::Actions
175
173
  end
176
174
  alias_method :index_formats, :list_formats
177
175
 
178
- alias_method :row_formats, :list_formats
176
+ def row_formats
177
+ ([:html] + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
178
+ end
179
179
 
180
180
  def action_update_formats
181
181
  (default_formats + active_scaffold_config.formats).uniq
@@ -82,7 +82,6 @@ module ActiveScaffold::Actions
82
82
  @record = update_record_from_params(@record, active_scaffold_config.update.columns, params[:record]) unless options[:no_record_param_update]
83
83
  before_update_save(@record)
84
84
  self.successful = [@record.valid?, @record.associated_valid?].all? {|v| v == true} # this syntax avoids a short-circuit
85
- debugger
86
85
  if successful?
87
86
  @record.save! and @record.save_associated!
88
87
  after_update_save(@record)
@@ -85,6 +85,8 @@ module ActiveScaffold
85
85
  record = find_or_create_for_params(attributes, column, parent_record)
86
86
  if record
87
87
  record_columns = active_scaffold_config_for(column.association.klass).subform.columns
88
+ record_columns.constraint_columns = [column.association.reverse]
89
+ debugger
88
90
  update_record_from_params(record, record_columns, attributes)
89
91
  record.unsaved = true
90
92
  end
@@ -101,7 +103,6 @@ module ActiveScaffold
101
103
  end
102
104
 
103
105
  def column_value_from_param_simple_value(parent_record, column, value)
104
- debugger if column.name == :working_days
105
106
  if column.singular_association?
106
107
  # it's a single id
107
108
  column.association.klass.find(value) if value and not value.empty?
@@ -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
@@ -0,0 +1,70 @@
1
+ module ActiveScaffold::Config
2
+ class Base
3
+ include ActiveScaffold::Configurable
4
+ extend ActiveScaffold::Configurable
5
+
6
+ def initialize(core_config)
7
+ @core = core_config
8
+ end
9
+
10
+ def self.inherited(subclass)
11
+ class << subclass
12
+ # the crud type of the action. possible values are :create, :read, :update, :delete, and nil.
13
+ # this is not a setting for the developer. it's self-description for the actions.
14
+ def crud_type; @crud_type; end
15
+
16
+ protected
17
+
18
+ def crud_type=(val)
19
+ raise ArgumentError, "unknown CRUD type #{val}" unless [:create, :read, :update, :delete].include?(val.to_sym)
20
+ @crud_type = val.to_sym
21
+ end
22
+ end
23
+ end
24
+
25
+ # delegate
26
+ def crud_type; self.class.crud_type end
27
+
28
+ def label(model = @core.label(:count => 1))
29
+ @label.nil? ? model : as_(@label, :model => model)
30
+ end
31
+
32
+ # the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
33
+ attr_accessor :user
34
+
35
+ # define a default action_group for this action
36
+ # e.g. 'members.crud'
37
+ class_attribute :action_group
38
+
39
+ # action_group this action should belong to
40
+ attr_accessor :action_group
41
+
42
+ class UserSettings
43
+ def initialize(conf, storage, params)
44
+ # the session hash relevant to this action
45
+ @session = storage
46
+ # all the request params
47
+ @params = params
48
+ # the configuration object for this action
49
+ @conf = conf
50
+ end
51
+ end
52
+
53
+ def formats
54
+ @formats ||= []
55
+ end
56
+
57
+ def formats=(val)
58
+ @formats=val
59
+ end
60
+
61
+ private
62
+
63
+ def columns=(val)
64
+ @columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
65
+ @columns.action = self
66
+ @columns.set_columns(@core.columns) if @columns.respond_to?(:set_columns)
67
+ @columns
68
+ end
69
+ end
70
+ end
@@ -8,7 +8,7 @@ module ActionController #:nodoc:
8
8
  opts = args.blank? ? Hash.new : args.first
9
9
  render :partial => params[:adapter][1..-1],
10
10
  :locals => {:payload => render_to_string(opts.merge(:layout => false), &block).html_safe},
11
- :use_full_path => true, :layout => false
11
+ :use_full_path => true, :layout => false, :content_type => :html
12
12
  @rendering_adapter = nil # recursion control
13
13
  else
14
14
  render_without_active_scaffold(*args, &block)
@@ -1,5 +1,6 @@
1
1
  module ActionView
2
2
  class LookupContext
3
+ attr_accessor :uses_active_scaffold
3
4
  module ViewPaths
4
5
  def find_all_templates(name, partial = false, locals = {})
5
6
  prefixes.collect do |prefix|
@@ -11,6 +12,17 @@ module ActionView
11
12
  end.flatten!
12
13
  end
13
14
  end
15
+
16
+ # Overload formats= to expand ["*/*"] values and automatically
17
+ # add :html as fallback to :js.
18
+ def formats=(values)
19
+ debugger
20
+ if values == [:js] && uses_active_scaffold
21
+ _set_detail(:formats, values) if values != @details[:formats]
22
+ else
23
+ super(values)
24
+ end
25
+ end
14
26
  end
15
27
  end
16
28
 
@@ -49,7 +61,7 @@ module ActionView::Helpers #:nodoc:
49
61
  last_view[:templates] = lookup_context.find_all_templates(last_view[:view], last_view[:partial], options[:locals].keys)
50
62
  last_view[:templates].shift
51
63
  end
52
- options[:file] = last_view[:templates].shift
64
+ options[:template] = last_view[:templates].shift
53
65
  view_stack << last_view
54
66
  result = render_without_active_scaffold options
55
67
  view_stack.pop
@@ -95,7 +95,7 @@ module ActiveScaffold
95
95
  elsif value[:from].blank?
96
96
  nil
97
97
  elsif ActiveScaffold::Finder::StringComparators.values.include?(value[:opt])
98
- ["#{column.search_sql} LIKE ?", value[:opt].sub('?', value[:from])]
98
+ ["#{column.search_sql} #{ActiveScaffold::Finder.like_operator} ?", value[:opt].sub('?', value[:from])]
99
99
  elsif value[:opt] == 'BETWEEN'
100
100
  ["#{column.search_sql} BETWEEN ? AND ?", value[:from], value[:to]]
101
101
  elsif ActiveScaffold::Finder::NumericComparators.include?(value[:opt])
@@ -121,8 +121,7 @@ module ActiveScaffold
121
121
  end
122
122
 
123
123
  def active_scaffold_checkbox_list(column, select_options, associated_ids, options)
124
- options[:class] << " checkbox-list"
125
- html = content_tag :ul, :class => options[:class], :id => options[:id] do
124
+ html = content_tag :ul, :class => "#{options[:class]} checkbox-list", :id => options[:id] do
126
125
  content = "".html_safe
127
126
  select_options.each_with_index do |option, i|
128
127
  label, id = option
@@ -84,7 +84,7 @@ module ActiveScaffold
84
84
  link.action = 'index'
85
85
  link.crud_type = :read
86
86
  end
87
- link if link.crud_type.present?
87
+ link if link.action.present?
88
88
  end
89
89
 
90
90
  def column_link_authorized?(link, column, record, associated)
@@ -119,7 +119,7 @@ module ActiveScaffold
119
119
  ## Overrides
120
120
  ##
121
121
  def active_scaffold_column_text(column, record)
122
- truncate(clean_column_value(record.send(column.name)), :length => column.options[:truncate] || 50)
122
+ clean_column_value(truncate(record.send(column.name), :length => column.options[:truncate] || 50))
123
123
  end
124
124
 
125
125
  def active_scaffold_column_checkbox(column, record)
@@ -190,25 +190,25 @@ module ActiveScaffold
190
190
  end
191
191
 
192
192
  def format_association_value(value, column, size)
193
- case column.association.macro
193
+ format_value case column.association.macro
194
194
  when :has_one, :belongs_to
195
195
  if column.polymorphic_association?
196
- format_value("#{value.class.model_name.human}: #{value.to_label}")
196
+ "#{value.class.model_name.human}: #{value.to_label}"
197
197
  else
198
- format_value(value.to_label)
198
+ value.to_label
199
199
  end
200
200
  when :has_many, :has_and_belongs_to_many
201
201
  if column.associated_limit.nil?
202
- firsts = value.collect { |v| clean_column_value(v.to_label) }
202
+ firsts = value.collect { |v| v.to_label }
203
203
  else
204
204
  firsts = value.first(column.associated_limit)
205
- firsts.collect! { |v| clean_column_value(v.to_label) }
205
+ firsts.collect! { |v| v.to_label }
206
206
  firsts[column.associated_limit] = '…' if value.size > column.associated_limit
207
207
  end
208
208
  if column.associated_limit == 0
209
209
  size if column.associated_number?
210
210
  else
211
- joined_associated = format_value(firsts.join(active_scaffold_config.list.association_join_text))
211
+ joined_associated = firsts.join(active_scaffold_config.list.association_join_text)
212
212
  joined_associated << " (#{size})" if column.associated_number? and column.associated_limit and value.size > column.associated_limit
213
213
  joined_associated
214
214
  end
@@ -275,11 +275,13 @@ module ActiveScaffold
275
275
 
276
276
  def inplace_edit_control(column)
277
277
  if inplace_edit?(active_scaffold_config.model, column) and inplace_edit_cloning?(column)
278
- @record = new_model
278
+ old_record, @record = @record, new_model
279
279
  column = column.clone
280
280
  column.options = column.options.clone
281
281
  column.form_ui = :select if (column.association && column.form_ui.nil?)
282
- content_tag(:div, active_scaffold_input_for(column), {:style => "display:none;", :class => inplace_edit_control_css_class})
282
+ content_tag(:div, active_scaffold_input_for(column), :style => "display:none;", :class => inplace_edit_control_css_class).tap do
283
+ @record = old_record
284
+ end
283
285
  end
284
286
  end
285
287
 
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- PATCH = 24
5
+ PATCH = 25
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: 55
4
+ hash: 53
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 24
10
- version: 3.0.24
9
+ - 25
10
+ version: 3.0.25
11
11
  platform: ruby
12
12
  authors:
13
13
  - Many, see README
@@ -15,10 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-07 00:00:00 Z
18
+ date: 2011-12-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
22
  none: false
23
23
  requirements:
24
24
  - - ">="
@@ -27,12 +27,12 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  version: "0"
30
+ requirement: *id001
31
+ prerelease: false
30
32
  type: :development
31
33
  name: shoulda
32
- version_requirements: *id001
33
- prerelease: false
34
34
  - !ruby/object:Gem::Dependency
35
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
36
  none: false
37
37
  requirements:
38
38
  - - ~>
@@ -43,12 +43,12 @@ dependencies:
43
43
  - 0
44
44
  - 0
45
45
  version: 1.0.0
46
+ requirement: *id002
47
+ prerelease: false
46
48
  type: :development
47
49
  name: bundler
48
- version_requirements: *id002
49
- prerelease: false
50
50
  - !ruby/object:Gem::Dependency
51
- requirement: &id003 !ruby/object:Gem::Requirement
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ">="
@@ -57,12 +57,12 @@ dependencies:
57
57
  segments:
58
58
  - 0
59
59
  version: "0"
60
+ requirement: *id003
61
+ prerelease: false
60
62
  type: :development
61
63
  name: rcov
62
- version_requirements: *id003
63
- prerelease: false
64
64
  - !ruby/object:Gem::Dependency
65
- requirement: &id004 !ruby/object:Gem::Requirement
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
66
  none: false
67
67
  requirements:
68
68
  - - ">="
@@ -71,12 +71,12 @@ dependencies:
71
71
  segments:
72
72
  - 0
73
73
  version: "0"
74
+ requirement: *id004
75
+ prerelease: false
74
76
  type: :runtime
75
77
  name: render_component_vho
76
- version_requirements: *id004
77
- prerelease: false
78
78
  - !ruby/object:Gem::Dependency
79
- requirement: &id005 !ruby/object:Gem::Requirement
79
+ version_requirements: &id005 !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements:
82
82
  - - ">="
@@ -85,12 +85,12 @@ dependencies:
85
85
  segments:
86
86
  - 0
87
87
  version: "0"
88
+ requirement: *id005
89
+ prerelease: false
88
90
  type: :runtime
89
91
  name: verification
90
- version_requirements: *id005
91
- prerelease: false
92
92
  - !ruby/object:Gem::Dependency
93
- requirement: &id006 !ruby/object:Gem::Requirement
93
+ version_requirements: &id006 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -101,10 +101,10 @@ dependencies:
101
101
  - 0
102
102
  - 0
103
103
  version: 3.0.0
104
+ requirement: *id006
105
+ prerelease: false
104
106
  type: :runtime
105
107
  name: rails
106
- version_requirements: *id006
107
- prerelease: false
108
108
  description: Save time and headaches, and create a more easily maintainable set of pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read, update, delete) user interface needs, leaving you more time to focus on more challenging (and interesting!) problems.
109
109
  email: activescaffold@googlegroups.com
110
110
  executables: []
@@ -172,16 +172,16 @@ files:
172
172
  - frontends/default/views/add_existing_form.html.erb
173
173
  - frontends/default/views/create.html.erb
174
174
  - frontends/default/views/_human_conditions.html.erb
175
- - frontends/default/views/_render_field.js.rjs
175
+ - frontends/default/views/_list_with_header.html.erb
176
176
  - frontends/default/views/field_search.html.erb
177
- - frontends/default/views/add_existing.js.rjs
177
+ - frontends/default/views/_render_field.js.rjs
178
178
  - frontends/default/views/search.html.erb
179
- - frontends/default/views/destroy.js.rjs
179
+ - frontends/default/views/add_existing.js.rjs
180
180
  - frontends/default/views/update.html.erb
181
181
  - frontends/default/views/_list_pagination.html.erb
182
182
  - frontends/default/views/_list_record_columns.html.erb
183
183
  - frontends/default/views/show.html.erb
184
- - frontends/default/views/_list_with_header.html.erb
184
+ - frontends/default/views/destroy.js.rjs
185
185
  - frontends/default/views/_search_attribute.html.erb
186
186
  - frontends/default/views/action_confirmation.html.erb
187
187
  - frontends/default/views/edit_associated.js.rjs
@@ -197,13 +197,14 @@ files:
197
197
  - frontends/default/views/_form.html.erb~
198
198
  - frontends/default/views/_row.html.erb~
199
199
  - frontends/default/views/render_field.js.erb~
200
- - frontends/default/views/_horizontal_subform_record.html.erb~
200
+ - frontends/default/views/update_column.js.erb~
201
201
  - frontends/default/views/_form_association_footer.html.erb~
202
202
  - frontends/default/views/edit_associated.js.erb~
203
203
  - frontends/default/views/_list_inline_adapter.html.erb~
204
204
  - frontends/default/views/_form_association.html.erb~
205
205
  - frontends/default/views/_vertical_subform.html.erb~
206
206
  - frontends/default/views/_horizontal_subform.html.erb~
207
+ - frontends/default/views/_show.html.erb~
207
208
  - frontends/default/views/_horizontal_subform_header.html.erb~
208
209
  - frontends/default/views/_list_pagination.html.erb~
209
210
  - frontends/default/views/_list_actions.html.erb~
@@ -211,6 +212,11 @@ files:
211
212
  - frontends/default/views/_list_messages.html.erb~
212
213
  - frontends/default/views/_render_field.js.erb~
213
214
  - frontends/default/views/_action_group.html.erb~
215
+ - frontends/default/views/on_update.js.erb~
216
+ - frontends/default/views/on_create.js.erb~
217
+ - frontends/default/views/_horizontal_subform_record.html.erb~
218
+ - frontends/default/views/_list_with_header.html.erb~
219
+ - frontends/default/views/_update_form.html.erb~
214
220
  - lib/active_scaffold.rb
215
221
  - lib/active_scaffold_env.rb
216
222
  - lib/active_scaffold/actions/core.rb
@@ -248,6 +254,7 @@ files:
248
254
  - lib/active_scaffold/config/mark.rb
249
255
  - lib/active_scaffold/config/search.rb~
250
256
  - lib/active_scaffold/config/nested.rb~
257
+ - lib/active_scaffold/config/base.rb~
251
258
  - lib/active_scaffold/configurable.rb
252
259
  - lib/active_scaffold/constraints.rb
253
260
  - lib/active_scaffold/data_structures/action_columns.rb