Module: SpotlightSearch::Helpers
- Defined in:
- lib/spotlight_search/helpers.rb
Instance Method Summary collapse
- #cm_paginate(facets) ⇒ Object
- #exportable(email, klass) ⇒ Object
- #sortable(column, title = nil, sort_column = "created_at", sort_direction = "asc") ⇒ Object
Instance Method Details
#cm_paginate(facets) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/spotlight_search/helpers.rb', line 43 def cm_paginate(facets) tag.div class: 'text-center' do tag.div class: 'nav navbar navbar-inner' do tag.ul class: 'pagination' do if facets.previous_page != false previous_page = tag.li do tag. class: 'btn btn-bordered', data: { behaviour: 'previous-page'} do tag.span "Previous" end end end current_page = content_tag :li do tag.a class: 'btn btn-bordered mx-2', data: {sort_column: facets.sort[:sort_column], sort_direction: facets.sort[:sort_direction], page: facets.current_page, behaviour: 'current-page' } do "Showing #{facets.current_page} of #{facets.total_pages} pages" end end if facets.next_page != false next_page = tag.li do tag. class: 'btn btn-bordered', data: { behaviour: 'next-page'} do tag.span "Next" end end end (previous_page || ActiveSupport::SafeBuffer.new) + current_page + (next_page || ActiveSupport::SafeBuffer.new) end end end end |
#exportable(email, klass) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/spotlight_search/helpers.rb', line 12 def exportable(email, klass) tag. "Export as excel", class: "modal-btn", data: {toggle: "modal", target: "#exportmodal"} tag.div class: "modal fade", id: "exportmodal", tabindex: "-1", role: "dialog", aria: {labelledby: "exportModal"} do tag.div class: "modal-dialog", role: "document" do tag.div class: "modal-content" do tag.div class: "modal-header" do tag. type: "button", class: "close", data: {dismiss: "modal"}, aria: {label: "Close"} do tag.span "X", aria: {hidden: "true"} end tag.h4 "Select columns to export", class: "modal-title", id: "exportModal" end tag.div class: "modal-body" do form_tag '/export_to_file', id: 'export-to-file-form' do hidden_field_tag 'email', email, id: 'export-to-file-email' hidden_field_tag 'filters', nil, id: 'export-to-file-filters' hidden_field_tag 'klass', klass.to_s, id: 'export-to-file-klass' klass.enabled_columns.each do |column_name| tag.div class: "row" do tag.div class: "col-md-4" do check_box_tag "columns[]", column_name end end end submit_tag 'Export as excel', class: 'btn btn-bordered export-to-file-btn' end end end end end end |
#sortable(column, title = nil, sort_column = "created_at", sort_direction = "asc") ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/spotlight_search/helpers.rb', line 4 def sortable(column, title = nil, sort_column="created_at", sort_direction="asc") title ||= column.titleize css_class = column == sort_column ? "current #{sort_direction}" : nil direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc" # link_to title, '#', {:class => css_class, data: {sort: column, direction: direction}} content_tag("a","Title", class: css_class, data: {sort_column: column, sort_direction: direction, behaviour: 'sort', type: 'anchor-filter'}) end |