Skip to content

Commit

Permalink
Prototyping checking rows interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
mattvague committed Oct 12, 2011
1 parent d8d501c commit ae73a31
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
25 changes: 24 additions & 1 deletion app/assets/javascripts/active_admin/base.js
Expand Up @@ -10,10 +10,33 @@ $(function(){
return false; return false;
}); });


$('#batch_actions_button:not(:disabled)').toggle(function() { $('#batch_actions_button').toggle(function() {
$("#batch_actions_popover").fadeIn(50); $("#batch_actions_popover").fadeIn(50);
}, function() { }, function() {
$("#batch_actions_popover").fadeOut(100); $("#batch_actions_popover").fadeOut(100);
}); });

$('.index_table thead :checkbox').toggle(function() {
$('#batch_actions_button').removeClass("disabled");
$('#batch_actions_button').addClass("selected");
$(this).parents(".index_table").find('tr :checkbox').attr('checked', 'true');
$(this).attr('checked', 'true');
}, function() {
$('#batch_actions_button').addClass("disabled");
$('#batch_actions_button').removeClass("selected");
$(this).parents(".index_table").find('tr :checkbox').attr('checked', '');
$(this).attr('checked', 'false');
});

$('.index_table tbody :checkbox').toggle(function() {
$('#batch_actions_button').removeClass("disabled");
$('#batch_actions_button').addClass("selected");
return true;
}, function() {
$('#batch_actions_button').addClass("disabled");
$('#batch_actions_button').removeClass("selected");
return true;

});


}); });
5 changes: 5 additions & 0 deletions lib/active_admin/views/index_as_table.rb
Expand Up @@ -115,6 +115,11 @@ def table_for(*args, &block)
# #
class IndexTableFor < ::ActiveAdmin::Views::TableFor class IndexTableFor < ::ActiveAdmin::Views::TableFor


# Display a column for checkbox
def selectable_column
column(input(:type => "checkbox"), :class => "selectable"){|resource| input :type => "checkbox" }
end

# Display a column for the id # Display a column for the id
def id_column def id_column
column('ID', :sortable => :id){|resource| link_to resource.id, resource_path(resource), :class => "resource_id_link"} column('ID', :sortable => :id){|resource| link_to resource.id, resource_path(resource), :class => "resource_id_link"}
Expand Down
1 change: 1 addition & 0 deletions lib/active_admin/views/pages/index.rb
Expand Up @@ -66,6 +66,7 @@ def build_scopes
# with each column displayed as well as all the default actions # with each column displayed as well as all the default actions
def default_index_config def default_index_config
@default_index_config ||= ::ActiveAdmin::PageConfig.new(:as => :table) do |display| @default_index_config ||= ::ActiveAdmin::PageConfig.new(:as => :table) do |display|
selectable_column
id_column id_column
resource_class.content_columns.each do |col| resource_class.content_columns.each do |col|
column col.name.to_sym column col.name.to_sym
Expand Down

0 comments on commit ae73a31

Please sign in to comment.