Class: Hyrax::AdminSetPresenter

Inherits:
CollectionPresenter show all
Defined in:
app/presenters/hyrax/admin_set_presenter.rb

Instance Attribute Summary

Attributes inherited from CollectionPresenter

#current_ability, #request, #solr_document

Instance Method Summary collapse

Methods inherited from CollectionPresenter

#[], #initialize, #size, terms, #terms_with_values

Methods included from PresentsAttributes

#attribute_to_html, #display_microdata?, #microdata_type_to_html, #permission_badge, #permission_badge_class

Methods included from ModelProxy

#persisted?, #to_model, #to_partial_path

Constructor Details

This class inherits a constructor from Hyrax::CollectionPresenter

Instance Method Details

#disable_delete?Boolean

AdminSet cannot be deleted if default set or non-empty

Returns:

  • (Boolean)


8
9
10
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 8

def disable_delete?
  AdminSet.default_set?(id) || total_items > 0
end

#disabled_messageObject

Message to display if deletion is disabled



13
14
15
16
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 13

def disabled_message
  return I18n.t('hyrax.admin.admin_sets.delete.error_default_set') if AdminSet.default_set?(id)
  return I18n.t('hyrax.admin.admin_sets.delete.error_not_empty') if total_items > 0
end

#total_itemsObject



3
4
5
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 3

def total_items
  ActiveFedora::SolrService.count("{!field f=isPartOf_ssim}#{id}")
end