Sha256: 8d0308d1d63645d30ad30ee6a003b8156b62cb4f869eb48a22cd332690492469

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

module Marty
  module Notifications
    class GridView < Marty::Grid
      has_marty_permissions read: :any,
                            create: nil,
                            update: nil,
                            delete: nil

      def configure(c)
        super

        c.header = false
        c.model = 'Marty::Notifications::Delivery'
        c.attributes = [:created_at, :notification__event_type, :text, :error_text]
        c.store_config.merge!(
          sorters: [{ property: :created_at, direction: 'DESC' }],
          page_size: 30
        )

        c.scope = ->(arel) { arel.includes(:notification) }
      end

      def get_records(params)
        model.where(
          delivery_type: :web,
          state: [:sent, :delivered],
          recipient_id: Mcfly.whodunnit
        ).scoping do
          super
        end
      end

      def default_bbar
        []
      end

      attribute :notification__event_type do |config|
        config.width = 150
        config.label = 'Event'
      end

      attribute :text do |config|
        config.width = 300

        config.getter = lambda do |record|
          [record.notification.text, record.text].join(', ')
        end
      end

      attribute :error_text do |config|
        config.width = 300
        config.label = 'Error'
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
marty-14.3.0 app/components/marty/notifications/grid_view.rb
marty-14.0.0 app/components/marty/notifications/grid_view.rb
marty-13.0.2 app/components/marty/notifications/grid_view.rb
marty-11.0.0 app/components/marty/notifications/grid_view.rb
marty-10.0.3 app/components/marty/notifications/grid_view.rb
marty-10.0.2 app/components/marty/notifications/grid_view.rb
marty-10.0.0 app/components/marty/notifications/grid_view.rb
marty-9.5.1 app/components/marty/notifications/grid_view.rb
marty-9.5.0 app/components/marty/notifications/grid_view.rb
marty-9.3.3 app/components/marty/notifications/grid_view.rb
marty-9.3.2 app/components/marty/notifications/grid_view.rb
marty-9.3.0 app/components/marty/notifications/grid_view.rb
marty-8.5.0 app/components/marty/notifications/grid_view.rb
marty-8.4.1 app/components/marty/notifications/grid_view.rb
marty-8.3.1 app/components/marty/notifications/grid_view.rb
marty-8.2.0 app/components/marty/notifications/grid_view.rb