Sha256: 90001fa86a5fd0ed340d0a5a58297b0d1dc7212314ebbb6a86516c4b2843073d

Contents?: true

Size: 797 Bytes

Versions: 7

Compression:

Stored size: 797 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class NotificationsCell < Decidim::ViewModel
    include Decidim::CellsPaginateHelper
    include Decidim::LayoutHelper
    include Decidim::Core::Engine.routes.url_helpers

    helper_method :notifications

    def show
      return render :validations if validation_messages.present?

      render :show
    end

    private

    def validation_messages
      return [] if notifications_with_resource.present?

      [t("decidim.notifications.no_notifications")]
    end

    def notifications_with_resource
      @notifications_with_resource ||= notifications.select(&:resource)
    end

    def notifications
      @notifications ||= model.notifications.includes(:resource).order(created_at: :desc).page(params[:page]).per(50)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/cells/decidim/notifications_cell.rb
decidim-core-0.28.3 app/cells/decidim/notifications_cell.rb
decidim-core-0.28.2 app/cells/decidim/notifications_cell.rb
decidim-core-0.28.1 app/cells/decidim/notifications_cell.rb
decidim-core-0.28.0 app/cells/decidim/notifications_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/notifications_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/notifications_cell.rb