Permalink
Browse files

Prototyping checking rows interaction

  • Loading branch information...
1 parent d8d501c commit ae73a31c19f525145d7b2d50d00ddef03ed72dfe @mattvague committed Oct 4, 2011
View
25 app/assets/javascripts/active_admin/base.js
@@ -10,10 +10,33 @@ $(function(){
return false;
});
- $('#batch_actions_button:not(:disabled)').toggle(function() {
+ $('#batch_actions_button').toggle(function() {
$("#batch_actions_popover").fadeIn(50);
}, function() {
$("#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;
+
+ });
});
View
5 lib/active_admin/views/index_as_table.rb
@@ -115,6 +115,11 @@ def table_for(*args, &block)
#
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
def id_column
column('ID', :sortable => :id){|resource| link_to resource.id, resource_path(resource), :class => "resource_id_link"}
View
1 lib/active_admin/views/pages/index.rb
@@ -66,6 +66,7 @@ def build_scopes
# with each column displayed as well as all the default actions
def default_index_config
@default_index_config ||= ::ActiveAdmin::PageConfig.new(:as => :table) do |display|
+ selectable_column
id_column
resource_class.content_columns.each do |col|
column col.name.to_sym

0 comments on commit ae73a31

Please sign in to comment.