diff --git a/Gemfile.lock b/Gemfile.lock index e9a573816..8591a0c34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -799,7 +799,7 @@ GEM unf_ext (0.0.8.2) unicode-display_width (2.4.2) uniform_notifier (1.16.0) - uri (0.13.0) + uri (1.0.3) uri_template (0.7.0) valid_email2 (5.2.6) activemodel (>= 3.2) diff --git a/app/assets/stylesheets/administrate/custom_styles.scss b/app/assets/stylesheets/administrate/custom_styles.scss index 5e6d803d8..00f1a058c 100644 --- a/app/assets/stylesheets/administrate/custom_styles.scss +++ b/app/assets/stylesheets/administrate/custom_styles.scss @@ -10,7 +10,6 @@ .icon-container { margin-right: 2px; - } .value-container { diff --git a/app/dashboards/account_dashboard.rb b/app/dashboards/account_dashboard.rb index b566551f4..f7b04a167 100644 --- a/app/dashboards/account_dashboard.rb +++ b/app/dashboards/account_dashboard.rb @@ -78,7 +78,11 @@ class AccountDashboard < Administrate::BaseDashboard # COLLECTION_FILTERS = { # open: ->(resources) { resources.where(open: true) } # }.freeze - COLLECTION_FILTERS = {}.freeze + COLLECTION_FILTERS = { + active: ->(resources) { resources.where(status: :active) }, + suspended: ->(resources) { resources.where(status: :suspended) }, + recent: ->(resources) { resources.where('created_at > ?', 30.days.ago) } + }.freeze # Overwrite this method to customize how accounts are displayed # across all pages of the admin dashboard. diff --git a/app/dashboards/user_dashboard.rb b/app/dashboards/user_dashboard.rb index 6b2129eed..8abdefd1a 100644 --- a/app/dashboards/user_dashboard.rb +++ b/app/dashboards/user_dashboard.rb @@ -94,7 +94,12 @@ class UserDashboard < Administrate::BaseDashboard # COLLECTION_FILTERS = { # open: ->(resources) { resources.where(open: true) } # }.freeze - COLLECTION_FILTERS = {}.freeze + COLLECTION_FILTERS = { + super_admin: ->(resources) { resources.where(type: 'SuperAdmin') }, + confirmed: ->(resources) { resources.where.not(confirmed_at: nil) }, + unconfirmed: ->(resources) { resources.where(confirmed_at: nil) }, + recent: ->(resources) { resources.where('created_at > ?', 30.days.ago) } + }.freeze # Overwrite this method to customize how users are displayed # across all pages of the admin dashboard. diff --git a/app/views/super_admin/application/_filters.html.erb b/app/views/super_admin/application/_filters.html.erb new file mode 100644 index 000000000..f2e339ebe --- /dev/null +++ b/app/views/super_admin/application/_filters.html.erb @@ -0,0 +1,63 @@ +<%# +# Filters + +This partial is used on the `index` page to display available filters +for a collection of resources. + +## Local variables: + +- `page`: + An instance of [Administrate::Page::Collection][1]. + Contains helper methods to help display a table, + and knows which attributes should be displayed in the resource's table. + +[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection +%> + +<% + # Get the dashboard class name from the resource name + resource_name = page.resource_name.classify + dashboard_class_name = "#{resource_name}Dashboard" + dashboard_class = dashboard_class_name.constantize + + # Get the current filter if any + current_filter = nil + if params[:search] && params[:search].include?(':') + current_filter = params[:search].split(':').first + end +%> + +<% if dashboard_class.const_defined?(:COLLECTION_FILTERS) && !dashboard_class::COLLECTION_FILTERS.empty? %> +