Sha256: ead4ab045deda81db95253cbe004b65808ec8505e7f75ac1dcde584352603ee4

Contents?: true

Size: 1.01 KB

Versions: 37

Compression:

Stored size: 1.01 KB

Contents

module ActiveScaffold::Actions
  module DeletedRecords
    def self.included(base)
      base.class_eval do
        config = active_scaffold_config
        if config.actions.include?(:nested) && config.deleted_records.nested_link_group
          config.configure { nested.add_link :versions, :label => config.deleted_records.nested_link_label, :action_group => config.deleted_records.nested_link_group }
        end
      end
    end

    def deleted
      query = PaperTrail::Version.destroys.where(:item_type => active_scaffold_config.model)
      query = query.where_object(nested.child_association.foreign_key => nested.parent_id) if nested? && nested.child_association.macro == :belongs_to && PaperTrail::Version.respond_to?(:where_object)
      pager = Paginator.new(query.count, active_scaffold_config.list.per_page) do |offset, per_page|
        query.offset(offset).limit(per_page).map(&:reify)
      end
      @page = pager.page(params[:page] || 1)
      @records = @page.items
      respond_to_action(:list)
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
active_scaffold-3.4.41.1 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.41 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.40 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.39 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.38 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.37 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.36 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.35 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.34 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.33 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.32 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.31 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.30 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.29 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.28 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.27 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.26 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.25 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.24 lib/active_scaffold/bridges/paper_trail/actions.rb
active_scaffold-3.4.23 lib/active_scaffold/bridges/paper_trail/actions.rb