app/controllers/integral/backend/activities_controller.rb in integral-1.3.0 vs app/controllers/integral/backend/activities_controller.rb in integral-1.4.0

- old
+ new

@@ -1,12 +1,19 @@ module Integral module Backend # Activity management class ActivitiesController < BaseController - before_action :authorize_with_klass + before_action :authorize_with_klass, except: [:widget] before_action -> { set_grid } + def widget + activities = cast_activities(@grid.assets.limit(10)) + last_created_at = activities.last.created_at.utc if activities.present? + + render json: { content: render_to_string(partial: 'integral/backend/activities/activity', collection: activities), last_created_at: last_created_at } + end + # POST /grid # AJAX grid for activities # TODO: Could move this grid action into index action and respond different if json request def grid render json: { content: render_to_string(partial: 'integral/backend/activities/grid', @@ -42,11 +49,15 @@ def authorize_with_klass authorize Version end + def resource_klass + Integral::Version + end + def grid_options - grid_params = params[:grid].present? ? params[:grid].permit(:descending, :order, :page, :user, :action, :object) : {} + grid_params = params[:grid].present? ? params[:grid].permit(:descending, :order, :page, :user, :action, :object, :created_at, :item_id) : {} grid_params.delete_if { |_k, v| v.empty? } { 'order' => 'date', 'page' => 1, descending: true }.merge(grid_params) end helper_method :grid_options end