Module: Sufia::DashboardHelperBehavior
- Included in:
- DashboardHelper
- Defined in:
- app/helpers/sufia/dashboard_helper_behavior.rb
Instance Method Summary collapse
- #link_to_additional_notifications ⇒ Object
- #notifications_for_dashboard ⇒ Object
- #number_of_collections(user = current_user) ⇒ Object
- #number_of_files(user = current_user) ⇒ Object
- #number_of_works(user = current_user) ⇒ Object
- #on_my_works? ⇒ Boolean
- #on_the_dashboard? ⇒ Boolean
- #render_received_transfers ⇒ Object
- #render_recent_activity ⇒ Object
- #render_recent_notifications ⇒ Object
- #render_sent_transfers ⇒ Object
Instance Method Details
#link_to_additional_notifications ⇒ Object
65 66 67 68 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 65 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 |
#notifications_for_dashboard ⇒ Object
61 62 63 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 61 def notifications_for_dashboard @notifications.limit(Sufia.config.max_notifications_for_dashboard) end |
#number_of_collections(user = current_user) ⇒ Object
55 56 57 58 59 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 55 def number_of_collections(user = current_user) ::Collection.where(DepositSearchBuilder.depositor_field => user.user_key).count rescue RSolr::Error::ConnectionRefused 'n/a' end |
#number_of_files(user = current_user) ⇒ Object
49 50 51 52 53 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 49 def number_of_files(user = current_user) ::FileSet.where(DepositSearchBuilder.depositor_field => user.user_key).count rescue RSolr::Error::ConnectionRefused 'n/a' end |
#number_of_works(user = current_user) ⇒ Object
43 44 45 46 47 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 43 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 |
#on_my_works? ⇒ Boolean
39 40 41 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 39 def on_my_works? params[:controller].match(/^my\/works/) end |
#on_the_dashboard? ⇒ Boolean
35 36 37 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 35 def on_the_dashboard? params[:controller].match(/^dashboard|my/) end |
#render_received_transfers ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 11 def render_received_transfers if @incoming.present? render partial: 'transfers/received' else t('sufia.dashboard.no_transfer_requests') end end |
#render_recent_activity ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 19 def render_recent_activity if @activity.empty? t('sufia.dashboard.no_activity') else render partial: 'users/activity_log', locals: { events: @activity } end end |
#render_recent_notifications ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 27 def render_recent_notifications if @notifications.empty? t('sufia.dashboard.no_notifications') else render partial: "mailbox/notifications", locals: { messages: notifications_for_dashboard } end end |
#render_sent_transfers ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/sufia/dashboard_helper_behavior.rb', line 3 def render_sent_transfers if @outgoing.present? render partial: 'transfers/sent' else t('sufia.dashboard.no_transfers') end end |