diff --git a/authentication/app/controllers/admin/users_controller.rb b/authentication/app/controllers/admin/users_controller.rb index fa7498ddc9..c98466c7fa 100644 --- a/authentication/app/controllers/admin/users_controller.rb +++ b/authentication/app/controllers/admin/users_controller.rb @@ -1,17 +1,13 @@ module Admin class UsersController < Admin::BaseController - crudify :user, :order => 'username ASC', :title_attribute => 'username' + crudify :user, + :order => 'username ASC', + :title_attribute => 'username', + :xhr_paging => true before_filter :load_available_plugins_and_roles, :only => [:new, :create, :edit, :update] - def index - search_all_users if searching? - paginate_all_users - - render :partial => 'users' if request.xhr? - end - def new @user = User.new @selected_plugin_names = [] diff --git a/core/lib/refinery/crud.rb b/core/lib/refinery/crud.rb index bbf7a621fd..70f38314d3 100644 --- a/core/lib/refinery/crud.rb +++ b/core/lib/refinery/crud.rb @@ -27,7 +27,8 @@ def self.default_options(model_name) :searchable => true, :search_conditions => '', :sortable => true, - :title_attribute => "title" + :title_attribute => "title", + :xhr_paging => false } end @@ -197,6 +198,8 @@ def search_all_#{plural_name} def index search_all_#{plural_name} if searching? paginate_all_#{plural_name} + + render :partial => '#{plural_name}' if #{options[:xhr_paging].inspect} && request.xhr? end ) else @@ -216,6 +219,8 @@ def index module_eval %( def index paginate_all_#{plural_name} + + render :partial => '#{plural_name}' if #{options[:xhr_paging].inspect} && request.xhr? end ) else diff --git a/doc/crud.md b/doc/crud.md index e73cad090f..5f05137826 100644 --- a/doc/crud.md +++ b/doc/crud.md @@ -134,6 +134,29 @@ Default value is ``true`` The ``:paging`` option tells ``crudify`` you don't just want one big long list but rather to break it out into pages and support paging methods uses [will_paginate](http://wiki.github.com/mislav/will_paginate/). +### ``:xhr_paging`` + +Default value is ``false`` + +The ``:xhr_paging`` option tells ``crudify`` you want to use more advanced paging. +This works using the HTML5 History API to swap out only the content that is being +paged rather than the entire webpage. To support this option you will need a partial +named after the plural name for example with ``news_items``: + + class NewsItemsController < ApplicationController + + crudify :news_item, :paging => true, :xhr_paging => true + + end + +This requires a partial called "news_items" in the appropriate directory which contains: + + <%= will_paginate @news_items %> +