-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade activeadmin to 1.2.x * Update ransack to < 1.8.7 * active_admin 1.3 support * update readme; set activeadmin 1.3
- Loading branch information
1 parent
0a37baf
commit 89bcd52
Showing
17 changed files
with
174 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
lib/active_admin/mongoid/controllers/resource_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'active_admin/engine' | ||
|
||
ActiveAdmin::Engine.module_eval do | ||
|
||
initializer 'active_admin.mongoid.resource_controller' do | ||
class ActiveAdmin::ResourceController | ||
def build_new_resource | ||
scoped_collection.send( | ||
method_for_build, | ||
*resource_params | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module ActiveAdmin | ||
class CSVBuilder | ||
def build(controller, csv) | ||
@collection = controller.send :find_collection, except: :pagination | ||
columns = exec_columns controller.view_context | ||
options = ActiveAdmin.application.csv_options.merge self.options | ||
bom = options.delete :byte_order_mark | ||
column_names = options.delete(:column_names) { true } | ||
csv_options = options.except :encoding_options, :humanize_name | ||
|
||
csv << bom if bom | ||
|
||
if column_names | ||
csv << CSV.generate_line(columns.map{ |c| encode c.name, options }, csv_options) | ||
end | ||
|
||
(1..paginated_collection.total_pages).each do |page| | ||
paginated_collection(page).each do |resource| | ||
resource = controller.send :apply_decorator, resource | ||
csv << CSV.generate_line(build_row(resource, columns, options), csv_options) | ||
end | ||
end | ||
|
||
csv | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'active_admin/filters/active_filter' | ||
module ActiveAdmin | ||
module Filters | ||
|
||
class ActiveFilter | ||
def related_primary_key | ||
if predicate_association | ||
predicate_association.key | ||
elsif related_class | ||
related_class.key | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'active_admin/filters/resource_extension' | ||
|
||
module ActiveAdmin::Filters::ResourceExtension | ||
def default_association_filters | ||
if resource_class.respond_to?(:reflect_on_all_associations) | ||
poly, not_poly = resource_class.reflect_on_all_associations.partition{ |r| r.macro == :belongs_to && r.options[:polymorphic] } | ||
|
||
filters = poly.map(&:foreign_type) + not_poly.map(&:name) | ||
filters.map &:to_sym | ||
else | ||
[] | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
lib/active_admin/mongoid/inputs/filters/check_boxes_input.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'active_admin/inputs/filters/check_boxes_input' | ||
|
||
class ActiveAdmin::Inputs::Filters::CheckBoxesInput | ||
def searchable_method_name | ||
if searchable_has_many_through? | ||
"#{reflection.through_reflection.name}_#{reflection.foreign_key}" | ||
else | ||
reflection.key || method | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'active_admin/inputs/filters/select_input' | ||
|
||
class ActiveAdmin::Inputs::Filters::SelectInput | ||
def searchable_method_name | ||
name = if searchable_has_many_through? | ||
"#{reflection.through_reflection.name}_#{reflection.foreign_key}" | ||
elsif reflection_searchable? | ||
reflection.key | ||
end | ||
(name == '_id') ? 'id' : name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'active_admin/resource/attributes' | ||
|
||
module ActiveAdmin | ||
|
||
class Resource | ||
module Attributes | ||
def foreign_methods | ||
@foreign_methods ||= resource_class.reflect_on_all_associations. | ||
select{ |r| r.macro == :belongs_to }. | ||
index_by{ |r| r.foreign_key.to_sym } | ||
end | ||
|
||
def primary_col?(c) | ||
c.name == '_id' | ||
end | ||
|
||
def sti_col?(c) | ||
false | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,3 +211,4 @@ | |
|
||
|
||
end | ||
|