Module: ManifestationsHelper
- Includes:
- EnjuCirculation::ManifestationsHelper
- Included in:
- OwnsHelper, SeriesStatementsHelper
- Defined in:
- app/helpers/manifestations_helper.rb
Instance Method Summary collapse
- #back_to_manifestation_index ⇒ Object
- #call_number_label(item) ⇒ Object
- #carrier_type_facet(facet) ⇒ Object
- #holding_item_sort_criteria(item) ⇒ Object
- #language_facet(language, current_languages, facet) ⇒ Object
- #language_list(languages) ⇒ Object
- #library_facet(current_libraries, facet) ⇒ Object
- #link_to_bookmark(manifestation) ⇒ Object
- #paginate_id_link(manifestation, manifestation_ids) ⇒ Object
- #pub_year_facet(pub_date_from, pub_date_until, facet) ⇒ Object
- #resource_title(manifestation, action) ⇒ Object
- #title_with_volume_number(manifestation) ⇒ Object
Instance Method Details
#back_to_manifestation_index ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/manifestations_helper.rb', line 15 def back_to_manifestation_index if session[:params] params = session[:params].merge(view: nil, controller: :manifestations) link_to t('page.back_to_search_results'), url_for(params) else link_to t('page.back'), :back end #rescue # link_to t('page.listing', model: t('activerecord.models.manifestation')), manifestations_path end |
#call_number_label(item) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/manifestations_helper.rb', line 26 def call_number_label(item) if item.call_number? unless item.shelf.web_shelf? # TODO 請求記号の区切り文字 numbers = item.call_number.split(item.shelf.library.call_number_delimiter) call_numbers = [] numbers.each do |number| call_numbers << h(number.to_s) end render partial: 'manifestations/call_number', locals: { item: item, call_numbers: call_numbers } end end end |
#carrier_type_facet(facet) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/helpers/manifestations_helper.rb', line 97 def carrier_type_facet(facet) string = '' carrier_type = CarrierType.where(name: facet.value).select([:id, :name, :display_name]).first if carrier_type string << form_icon(carrier_type) current = true if params[:carrier_type] == carrier_type.name if current content_tag :strong do link_to("#{carrier_type.display_name.localize} (" + facet.count.to_s + ")", url_for(request.params.merge(carrier_type: carrier_type.name, page: nil, view: nil, only_path: true))) end else link_to("#{carrier_type.display_name.localize} (" + facet.count.to_s + ")", url_for(request.params.merge(carrier_type: carrier_type.name, page: nil, view: nil, only_path: true))) end end end |
#holding_item_sort_criteria(item) ⇒ Object
141 142 143 144 145 |
# File 'app/helpers/manifestations_helper.rb', line 141 def holding_item_sort_criteria( item ) own_library = 2 own_library = 1 if signed_in? and current_user.profile.library_id == item.shelf.library_id [ own_library, Library.find(item.shelf.library_id).position, item.shelf.position, item.id ] end |
#language_facet(language, current_languages, facet) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/manifestations_helper.rb', line 68 def language_facet(language, current_languages, facet) string = '' languages = current_languages.dup current = true if languages.include?(language.name) if current content_tag :strong do link_to("#{language.display_name.localize} (" + facet.count.to_s + ")", url_for(request.params.merge(page: nil, language: language.name, view: nil, only_path: true))) end else link_to("#{language.display_name.localize} (" + facet.count.to_s + ")", url_for(request.params.merge(page: nil, language: language.name, view: nil, only_path: true))) end end |
#language_list(languages) ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/helpers/manifestations_helper.rb', line 40 def language_list(languages) list = [] languages.each do |language| list << language.display_name.localize if language.name != 'unknown' end list.join("; ") end |
#library_facet(current_libraries, facet) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/helpers/manifestations_helper.rb', line 81 def library_facet(current_libraries, facet) library = Library.where(name: facet.value).select([:name, :display_name]).first return nil unless library string = '' current = true if current_libraries.include?(library.name) content_tag :li do if current content_tag :strong do link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(request.params.merge(page: nil, library: (current_libraries << library.name).uniq.join(' '), view: nil, only_path: true))) end else link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(request.params.merge(page: nil, library: (current_libraries << library.name).uniq.join(' '), view: nil, only_path: true))) end end end |
#link_to_bookmark(manifestation) ⇒ Object
148 149 150 151 152 153 154 |
# File 'app/helpers/manifestations_helper.rb', line 148 def link_to_bookmark(manifestation) if manifestation.bookmarked?(current_user) link_to t('bookmark.remove_from_my_bookmark'), bookmark_path(Bookmark.where(user_id: current_user.id, manifestation_id: manifestation.id).first), confirm: t('page.are_you_sure'), method: :delete else link_to t('bookmark.add_to_my_bookmark'), new_bookmark_path(bookmark: {url: manifestation_url(manifestation)}) end end |
#paginate_id_link(manifestation, manifestation_ids) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/helpers/manifestations_helper.rb', line 48 def paginate_id_link(manifestation, manifestation_ids) links = [] if manifestation_ids.is_a?(Array) current_seq = manifestation_ids.index(manifestation.id) if current_seq unless manifestation.id == manifestation_ids.last links << link_to(t('page.next'), manifestation_path(manifestation_ids[current_seq + 1])) else links << t('page.next').to_s end unless manifestation.id == manifestation_ids.first links << link_to(t('page.previous'), manifestation_path(manifestation_ids[current_seq - 1])) else links << t('page.previous').to_s end end end links.join(" ").html_safe end |
#pub_year_facet(pub_date_from, pub_date_until, facet) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'app/helpers/manifestations_helper.rb', line 113 def pub_year_facet(pub_date_from, pub_date_until, facet) string = '' current = true if facet.value.first.to_i == pub_date_from.to_i and facet.value.last.to_i - 1 == pub_date_until.to_i if current content_tag :strong do link_to("#{facet.value.first.to_i} - #{facet.value.last.to_i - 1} (" + facet.count.to_s + ")", url_for(request.params.merge(pub_date_from: facet.value.first.to_i, pub_date_until: facet.value.last.to_i - 1, page: nil, view: nil, only_path: true))) end else link_to("#{facet.value.first.to_i} - #{facet.value.last.to_i - 1} (" + facet.count.to_s + ")", url_for(request.params.merge(pub_date_from: facet.value.first.to_i, pub_date_until: facet.value.last.to_i - 1, page: nil, view: nil, only_path: true))) end end |
#resource_title(manifestation, action) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'app/helpers/manifestations_helper.rb', line 4 def resource_title(manifestation, action) string = LibraryGroup.site_config.display_name.localize.dup unless action == ('index' or 'new') if manifestation.try(:original_title) string << ' - ' + manifestation.original_title.to_s end end string << ' - Next-L Enju Leaf' string.html_safe end |
#title_with_volume_number(manifestation) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'app/helpers/manifestations_helper.rb', line 125 def title_with_volume_number(manifestation) title = manifestation.original_title if manifestation.volume_number_string? title << " " + manifestation.volume_number_string end if manifestation.serial? if manifestation.issue_number_string? title << " (#{manifestation.issue_number_string})" end if manifestation.serial_number? title << " " + manifestation.serial_number.to_s end end title end |