Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from mirceapricop/master

Make it possible to have non-remote links in tables. Too much AJAX hurts.
  • Loading branch information...
commit d7e7d443280fae73351de4f6178ebd50018b18e8 2 parents 1a65b8b + 70ae8b4
jpincheira authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/tabletastic/table_builder.rb
View
14 lib/tabletastic/table_builder.rb
@@ -29,7 +29,7 @@ def data(*args, &block) # :yields: tablebody
else
@table_fields = args.empty? ? orm_fields : args.collect {|f| TableField.new(f.to_sym)}
end
- action_cells(options[:actions], options[:action_prefix])
+ action_cells(options[:actions], options[:action_prefix], options[:non_remote])
["\n", head, "\n", body, "\n"].join("").html_safe
end
@@ -92,17 +92,21 @@ def cells_for_row(record)
end
# Used internally to build up cells for common CRUD actions
- def action_cells(actions, prefix = nil)
+ def action_cells(actions, prefix = nil, non_remote=nil)
return if actions.blank?
actions = [actions] if !actions.respond_to?(:each)
actions = [:show, :edit, :destroy] if actions == [:all]
actions.each do |action|
- action_link(action.to_sym, prefix)
+ if non_remote
+ action_link(action.to_sym, prefix, !non_remote.include?(action.to_sym))
+ else
+ action_link(action.to_sym, prefix)
+ end
end
end
# Dynamically builds links for the action
- def action_link(action, prefix)
+ def action_link(action, prefix, remote=true)
html_class = "actions #{action.to_s}_link"
block = lambda do |resource|
compound_resource = [prefix, resource].compact
@@ -115,7 +119,7 @@ def action_link(action, prefix)
:method => :delete, :confirm => confirmation_message)
else # edit, other resource GET actions
@template.link_to(content_tag( :span, link_title(action)),
- @template.polymorphic_path(compound_resource, :action => action), :remote => true)
+ @template.polymorphic_path(compound_resource, :action => action), :remote => remote)
end
end
self.cell(action, :heading => "", :cell_html => {:class => html_class}, &block)

0 comments on commit d7e7d44

Please sign in to comment.
Something went wrong with that request. Please try again.