Sha256: ce64f387bac337d2818cb8beafc19b215fc269ae4782ed6ee3c70d5ea59a0370

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 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_files?
      params[:controller].match(/^my\/files/)
    end

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

    def number_of_files(user = current_user)
      ::GenericFile.where(Solrizer.solr_name('depositor', :symbol) => user.user_key).count
    end

    def number_of_collections(user = current_user)
      ::Collection.where(Solrizer.solr_name('depositor', :symbol) => user.user_key).count
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sufia-6.7.0 app/helpers/sufia/dashboard_helper_behavior.rb