Sha256: 5d396f9bc3bd824f697c88d9a2ef5cef3091b829a27e95c5dad941979895f278

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

module Sufia
  module DashboardHelperBehavior

    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 number_of_files user=current_user
      ::GenericFile.where(Solrizer.solr_name('depositor', :stored_searchable) => user.user_key).count
    end

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

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

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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sufia-4.0.1 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-4.0.0 app/helpers/sufia/dashboard_helper_behavior.rb
sufia-4.0.0.rc2 app/helpers/sufia/dashboard_helper_behavior.rb