Sha256: 5943cd5db770cc0c637b9376cf7b7f2d25fff6dace6f4d8440e1e70eb13e7d27

Contents?: true

Size: 1.9 KB

Versions: 10

Compression:

Stored size: 1.9 KB

Contents

module Hyrax
  module DashboardHelperBehavior
    def render_sent_transfers
      if @outgoing.present?
        render 'hyrax/transfers/sent'
      else
        t('hyrax.dashboard.no_transfers')
      end
    end

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

    def render_recent_activity
      if @activity.empty?
        t('hyrax.dashboard.no_activity')
      else
        render 'hyrax/users/activity_log', events: @activity
      end
    end

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

    def on_the_dashboard?
      params[:controller].match(%r{^hyrax/dashboard|hyrax/my})
    end

    def on_my_works?
      params[:controller].match(%r{^hyrax/my/works})
    end

    def number_of_works(user = current_user)
      Hyrax::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(Hyrax.config.max_notifications_for_dashboard)
    end

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

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/helpers/hyrax/dashboard_helper_behavior.rb
hyrax-1.1.0 app/helpers/hyrax/dashboard_helper_behavior.rb
hyrax-1.0.5 app/helpers/hyrax/dashboard_helper_behavior.rb
hyrax-1.0.4 app/helpers/hyrax/dashboard_helper_behavior.rb
hyrax-1.0.3 app/helpers/hyrax/dashboard_helper_behavior.rb
hyrax-1.0.2 app/helpers/hyrax/dashboard_helper_behavior.rb
hyrax-1.0.1 app/helpers/hyrax/dashboard_helper_behavior.rb
hyrax-1.0.0.rc2 app/helpers/hyrax/dashboard_helper_behavior.rb
hyrax-1.0.0.rc1 app/helpers/hyrax/dashboard_helper_behavior.rb
test_hyrax-0.0.1.alpha app/helpers/hyrax/dashboard_helper_behavior.rb