Module: CurationConcerns::CollectionsHelper
- Included in:
- MainAppHelpers
- Defined in:
- app/helpers/curation_concerns/collections_helper.rb
Instance Method Summary collapse
- #button_for_remove_from_collection(collection, document, label = 'Remove From Collection') ⇒ Object
- #button_for_remove_selected_from_collection(collection, label = 'Remove From Collection') ⇒ Object
- #collection_modal_id(collectible) ⇒ Object
- #collection_options_for_select(exclude_item = nil) ⇒ Object
- #has_collection_search_parameters? ⇒ Boolean
- #hidden_collection_members ⇒ Object
- #icon(type) ⇒ Object
-
#link_to_remove_from_collection(document, label = 'Remove From Collection') ⇒ Object
override hydra-collections.
- #link_to_select_collection(collectible, opts = {}) ⇒ Object
-
#single_item_action_add_form_fields(form, document) ⇒ Object
add hidden fields to a form for adding a single document to a collection.
-
#single_item_action_form_fields(form, document, action) ⇒ Object
add hidden fields to a form for performing an action on a single document on a collection.
-
#single_item_action_remove_form_fields(form, document) ⇒ Object
add hidden fields to a form for removing a single document from a collection.
Instance Method Details
#button_for_remove_from_collection(collection, document, label = 'Remove From Collection') ⇒ Object
6 7 8 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 6 def (collection, document, label = 'Remove From Collection') render '/collections/button_remove_from_collection', collection: collection, label: label, document: document end |
#button_for_remove_selected_from_collection(collection, label = 'Remove From Collection') ⇒ Object
10 11 12 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 10 def (collection, label = 'Remove From Collection') render '/collections/button_for_remove_selected_from_collection', collection: collection, label: label end |
#collection_modal_id(collectible) ⇒ Object
39 40 41 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 39 def collection_modal_id(collectible) "#{collectible.to_param.tr(':', '-')}-modal" end |
#collection_options_for_select(exclude_item = nil) ⇒ Object
64 65 66 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 64 def (exclude_item = nil) (available_collections(exclude_item)) end |
#has_collection_search_parameters? ⇒ Boolean
2 3 4 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 2 def has_collection_search_parameters? !params[:cq].blank? end |
#hidden_collection_members ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 29 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 |
#icon(type) ⇒ Object
60 61 62 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 60 def icon(type) content_tag :span, '', class: "glyphicon glyphicon-#{type}" end |
#link_to_remove_from_collection(document, label = 'Remove From Collection') ⇒ Object
override hydra-collections
52 53 54 55 56 57 58 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 52 def link_to_remove_from_collection(document, label = 'Remove From Collection') collection_id = @collection ? @collection.id : @presenter.id link_to collection_path(collection_id, collection: { members: 'remove' }, batch_document_ids: [document.id]), method: :put do icon('minus-sign') + ' ' + label end end |
#link_to_select_collection(collectible, opts = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 43 def link_to_select_collection(collectible, opts = {}) html_class = opts[:class] link_to '#', data: { toggle: 'modal', target: '#' + collection_modal_id(collectible) }, class: "add-to-collection #{html_class}", title: "Add #{collectible.human_readable_type} to Collection" do icon('plus-sign') + ' Add to a Collection' end end |
#single_item_action_add_form_fields(form, document) ⇒ Object
add hidden fields to a form for adding a single document to a collection
20 21 22 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 20 def single_item_action_add_form_fields(form, document) single_item_action_form_fields(form, document, 'add') end |
#single_item_action_form_fields(form, document, action) ⇒ Object
add hidden fields to a form for performing an action on a single document on a collection
25 26 27 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 25 def single_item_action_form_fields(form, document, action) render '/collections/single_item_action_fields', form: form, document: document, action: action end |
#single_item_action_remove_form_fields(form, document) ⇒ Object
add hidden fields to a form for removing a single document from a collection
15 16 17 |
# File 'app/helpers/curation_concerns/collections_helper.rb', line 15 def single_item_action_remove_form_fields(form, document) single_item_action_form_fields(form, document, 'remove') end |