Class: Hyrax::AdminSetPresenter
- Inherits:
-
CollectionPresenter
- Object
- CollectionPresenter
- Hyrax::AdminSetPresenter
- Defined in:
- app/presenters/hyrax/admin_set_presenter.rb
Instance Attribute Summary
Attributes inherited from CollectionPresenter
#current_ability, #parent_collections, #request, #solr_document, #subcollection_count
Class Method Summary collapse
Instance Method Summary collapse
-
#allow_batch? ⇒ Boolean
Determine if the user can perform batch operations on this admin set.
-
#any_items? ⇒ Boolean
True if there are items.
- #available_parent_collections ⇒ Object
- #collection_type ⇒ Object
-
#collection_type_gid ⇒ Object
Overrides delegate because admin sets do not index collection type gid.
-
#disable_delete? ⇒ Boolean
AdminSet cannot be deleted if default set or non-empty.
-
#disabled_message ⇒ Object
Message to display if deletion is disabled.
-
#managed_access ⇒ Object
For the Managed Collections tab, determine the label to use for the level of access the user has for this admin set.
- #show_path ⇒ Object
- #total_items ⇒ Object
- #total_viewable_items ⇒ Object
Methods inherited from CollectionPresenter
#[], #banner_file, #collection_type_badge, #create_many_work_types?, #create_work_presenter, #draw_select_work_modal?, #editor?, #first_work_type, #initialize, #logo_record, #parent_collection_count, #size, #terms_with_values, #total_parent_collections, #total_viewable_collections, #total_viewable_works, #user_can_create_new_nest_collection?, #user_can_nest_collection?
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, #valid_child_concerns
Constructor Details
This class inherits a constructor from Hyrax::CollectionPresenter
Class Method Details
.terms ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 6 def self.terms base = super if Hyrax.config.flexible? && Hyrax.config.admin_set_class.new.respond_to?(:contexts) base | [:contexts] else base end end |
Instance Method Details
#allow_batch? ⇒ Boolean
Determine if the user can perform batch operations on this admin set. Currently, the only batch operation allowed is deleting, so this is equivalent to checking if the user can delete the admin set determined by criteria...
- user must be able to edit the admin set to be able to delete it
- the admin set itself must be able to be deleted (i.e., there cannot be any works in the admin set)
77 78 79 80 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 77 def allow_batch? return false unless current_ability.can?(:edit, solr_document) !disable_delete? end |
#any_items? ⇒ Boolean
Returns true if there are items.
17 18 19 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 17 def any_items? total_items.positive? end |
#available_parent_collections ⇒ Object
57 58 59 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 57 def available_parent_collections(*) [] end |
#collection_type ⇒ Object
44 45 46 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 44 def collection_type @collection_type ||= Hyrax::CollectionType.find_or_create_admin_set_type end |
#collection_type_gid ⇒ Object
Overrides delegate because admin sets do not index collection type gid
49 50 51 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 49 def collection_type_gid collection_type.to_global_id end |
#disable_delete? ⇒ Boolean
AdminSet cannot be deleted if default set or non-empty
34 35 36 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 34 def disable_delete? default_set? || any_items? end |
#disabled_message ⇒ Object
Message to display if deletion is disabled
39 40 41 42 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 39 def return I18n.t('hyrax.admin.admin_sets.delete.error_default_set') if default_set? I18n.t('hyrax.admin.admin_sets.delete.error_not_empty') if any_items? end |
#managed_access ⇒ Object
For the Managed Collections tab, determine the label to use for the level of access the user has for this admin set. Checks from most permissive to most restrictive.
64 65 66 67 68 69 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 64 def managed_access return I18n.t('hyrax.dashboard.my.collection_list.managed_access.manage') if current_ability.can?(:edit, solr_document) return I18n.t('hyrax.dashboard.my.collection_list.managed_access.deposit') if current_ability.can?(:deposit, solr_document) return I18n.t('hyrax.dashboard.my.collection_list.managed_access.view') if current_ability.can?(:read, solr_document) '' end |
#show_path ⇒ Object
53 54 55 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 53 def show_path Hyrax::Engine.routes.url_helpers.admin_admin_set_path(id, locale: I18n.locale) end |
#total_items ⇒ Object
21 22 23 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 21 def total_items Hyrax::SolrService.count("{!field f=#{Hyrax.config.admin_set_predicate.qname.last}_ssim}#{id}") end |
#total_viewable_items ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/presenters/hyrax/admin_set_presenter.rb', line 25 def total_viewable_items field_pairs = { "#{Hyrax.config.admin_set_predicate.qname.last}_ssim" => id.to_s } SolrQueryService.new .with_field_pairs(field_pairs: field_pairs) .accessible_by(ability: current_ability) .count end |