Sha256: 45e80a4ff1f385a7d10a63e1cc1ccf16b9c5b92977dca17cb955074b10f977a2

Contents?: true

Size: 1.92 KB

Versions: 8

Compression:

Stored size: 1.92 KB

Contents

module Sufia
  module DashboardHelperBehavior
    def render_sent_transfers
      if @outgoing.present?
        render partial: 'transfers/sent'
      else
        t('sufia.dashboard.no_transfers')
      end
    end

    def render_received_transfers
      if @incoming.present?
        render partial: 'transfers/received'
      else
        t('sufia.dashboard.no_transfer_requests')
      end
    end

    def render_recent_activity
      if @activity.empty?
        t('sufia.dashboard.no_activity')
      else
        render partial: 'users/activity_log', locals: { events: @activity }
      end
    end

    def render_recent_notifications
      if @notifications.empty?
        t('sufia.dashboard.no_notifications')
      else
        render partial: "mailbox/notifications", locals: { messages: notifications_for_dashboard }
      end
    end

    def on_the_dashboard?
      params[:controller].match(/^dashboard|my/)
    end

    def on_my_works?
      params[:controller].match(/^my\/works/)
    end

    def number_of_works(user = current_user)
      CurationConcerns::WorkRelation.new.where(DepositSearchBuilder.depositor_field => user.user_key).count
    rescue RSolr::Error::ConnectionRefused
      'n/a'
    end

    def number_of_files(user = current_user)
      ::FileSet.where(DepositSearchBuilder.depositor_field => user.user_key).count
    rescue RSolr::Error::ConnectionRefused
      'n/a'
    end

    def number_of_collections(user = current_user)
      ::Collection.where(DepositSearchBuilder.depositor_field => user.user_key).count
    rescue RSolr::Error::ConnectionRefused
      'n/a'
    end

    def notifications_for_dashboard
      @notifications.limit(Sufia.config.max_notifications_for_dashboard)
    end

    def link_to_additional_notifications
      return unless @notifications.count > Sufia.config.max_notifications_for_dashboard
      link_to t('sufia.dashboard.additional_notifications'), sufia.notifications_path
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.4.1 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-7.4.0 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-7.3.1 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-7.3.0 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-7.3.0.rc3 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-7.3.0.rc2 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-7.3.0.rc1 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-7.2.0 app/helpers/sufia/dashboard_helper_behavior.rb