Module: Curate::CollectionsHelper
- Defined in:
- app/helpers/curate/collections_helper.rb
Overview
require Hydra::Collections::Engine.root + ‘/app/helpers/collections_helper.rb’ View Helpers for Hydra Collections functionality
Instance Method Summary collapse
- #actions_for_member(collection, member) ⇒ Object
-
#actions_for_profile_section(collection, member) ⇒ Object
NOTE: Profile Sections and Collections are being rendered the same way.
-
#button_for_create_new_collection(label = 'Create Collection') ⇒ Object
Displays the Collections create collection button.
- #can_edit_profile_collection?(person) ⇒ Boolean
- #collection_line_item(collection, terminate) ⇒ Object
- #collection_member_actions(collection, member) ⇒ Object
- #contributors(work) ⇒ Object
- #has_any_collections? ⇒ Boolean
- #hidden_collection_members ⇒ Object
- #line_item_class(collection) ⇒ Object
- #list_items_in_collection(collection, terminate = false) ⇒ Object
- #member_line_item(collection, member, terminate) ⇒ Object
- #title_for_new_form(profile_section) ⇒ Object
- #work_line_item(work) ⇒ Object
Instance Method Details
#actions_for_member(collection, member) ⇒ Object
102 103 104 105 106 |
# File 'app/helpers/curate/collections_helper.rb', line 102 def actions_for_member(collection, member) remove_member_collections_path(id: collection.to_param, item_id: member.pid), data: { confirm: 'Are you sure you want to remove this item from the collection?' }, method: :put, id: "remove-#{member.noid}", class: 'btn btn-danger', form_class: 'remove-member', remote: true do raw('<i class="icon-white icon-minus"></i> Remove') end end |
#actions_for_profile_section(collection, member) ⇒ Object
NOTE: Profile Sections and Collections are being rendered the same way.
94 95 96 97 98 99 100 |
# File 'app/helpers/curate/collections_helper.rb', line 94 def actions_for_profile_section(collection, member) if can? :edit, member link_to edit_collection_path(id: member.to_param), class: 'btn' do raw('<i class="icon-pencil"></i> Edit') end end end |
#button_for_create_new_collection(label = 'Create Collection') ⇒ Object
Displays the Collections create collection button.
6 7 8 |
# File 'app/helpers/curate/collections_helper.rb', line 6 def (label = 'Create Collection') render partial: 'button_create_collection', locals:{label:label} end |
#can_edit_profile_collection?(person) ⇒ Boolean
14 15 16 |
# File 'app/helpers/curate/collections_helper.rb', line 14 def can_edit_profile_collection?(person) person.profile && can?(:edit, person.profile) end |
#collection_line_item(collection, terminate) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'app/helpers/curate/collections_helper.rb', line 63 def collection_line_item(collection, terminate) list_item = content_tag :h3, class: 'collection-section-heading' do link_to(collection.to_s, collection_path(collection)) end if collection.description.present? list_item << content_tag( :div, collection.description, class: 'collection-section-description') end list_item << list_items_in_collection(collection, true) unless terminate # limit nesting list_item end |
#collection_member_actions(collection, member) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'app/helpers/curate/collections_helper.rb', line 82 def collection_member_actions(collection, member) content_tag :span, class: 'collection-member-actions' do if member.respond_to?(:members) markup = actions_for_member(collection, member) markup << actions_for_profile_section(collection, member) else actions_for_member(collection, member) end end end |
#contributors(work) ⇒ Object
74 75 76 77 78 79 80 |
# File 'app/helpers/curate/collections_helper.rb', line 74 def contributors(work) if work.respond_to?(:contributors) "(#{work.contributors.to_a.join(', ')})" else '' end end |
#has_any_collections? ⇒ Boolean
28 29 30 |
# File 'app/helpers/curate/collections_helper.rb', line 28 def has_any_collections? current_user.collections.count > 0 if current_user end |
#hidden_collection_members ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/curate/collections_helper.rb', line 18 def hidden_collection_members _erbout = '' if params[:batch_document_ids].present? params[:batch_document_ids].each do |batch_item| _erbout.concat hidden_field_tag("batch_document_ids[]", batch_item) end end _erbout.html_safe end |
#line_item_class(collection) ⇒ Object
52 53 54 55 56 |
# File 'app/helpers/curate/collections_helper.rb', line 52 def line_item_class(collection) css_class = 'collection-member' css_class << ' with-controls' if can? :edit, collection css_class end |
#list_items_in_collection(collection, terminate = false) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/helpers/curate/collections_helper.rb', line 32 def list_items_in_collection(collection, terminate=false) content_tag :ul, class: 'collection-listing' do collection.members.inject('') do |output, member| output << member_line_item(collection, member, terminate) end.html_safe end end |
#member_line_item(collection, member, terminate) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/curate/collections_helper.rb', line 40 def member_line_item(collection, member, terminate) content_tag :li, class: line_item_class(collection), data: { noid: member.noid }do markup = member.respond_to?(:members) ? collection_line_item(member, terminate) : work_line_item(member) if can? :edit, collection markup << collection_member_actions(collection, member) end markup end end |
#title_for_new_form(profile_section) ⇒ Object
10 11 12 |
# File 'app/helpers/curate/collections_helper.rb', line 10 def title_for_new_form(profile_section) profile_section == 'true' ? 'Add a Section to my Profile' : 'Create a New Collection' end |
#work_line_item(work) ⇒ Object
58 59 60 61 |
# File 'app/helpers/curate/collections_helper.rb', line 58 def work_line_item(work) link = link_to work.to_s, polymorphic_path_for_asset(work) link + ' ' + contributors(work) end |