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

Instance Method Details

#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 button_for_create_new_collection(label = 'Create Collection')
  render partial: 'button_create_collection', locals:{label:label}
end

#can_edit_profile_collection?(person) ⇒ Boolean

Returns:

  • (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



51
52
53
54
55
# File 'app/helpers/curate/collections_helper.rb', line 51

def collection_line_item(collection, terminate)
  list_item = link_to(collection.to_s, collection_path(collection))
  list_item << list_items_in_collection(collection, true) unless terminate  # limit nesting
  list_item
end

#contributors(work) ⇒ Object



57
58
59
60
61
62
63
# File 'app/helpers/curate/collections_helper.rb', line 57

def contributors(work)
  if work.respond_to?(:contributors)
    "(#{work.contributors.to_a.join(', ')})"
  else
    ''
  end
end

#has_any_collections?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/helpers/curate/collections_helper.rb', line 28

def has_any_collections?
  current_user.collections.count > 0
end

#hidden_collection_membersObject



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

#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)
   :ul do
    collection.members.inject('') do |output, member|
      output << member_line_item(member, terminate)
    end.html_safe
  end
end

#member_line_item(member, terminate) ⇒ Object



40
41
42
43
44
# File 'app/helpers/curate/collections_helper.rb', line 40

def member_line_item(member, terminate)
   :li do
    member.respond_to?(:members) ? collection_line_item(member, terminate) : work_line_item(member)
  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



46
47
48
49
# File 'app/helpers/curate/collections_helper.rb', line 46

def work_line_item(work)
  link = link_to work.to_s, polymorphic_path_for_asset(work)
  link + ' ' + contributors(work)
end