Module: QueryOwl::ApplicationHelper

Defined in:
app/helpers/query_owl/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#inline_stylesObject



3
4
5
6
7
# File 'app/helpers/query_owl/application_helper.rb', line 3

def inline_styles
  dir = QueryOwl::Engine.root.join("app/assets/stylesheets/query_owl")
  css = dir.glob("_*.css").sort.map(&:read).join("\n")
  (:style, css.html_safe)
end

#sort_th(label, column, current_sort, current_dir) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/query_owl/application_helper.rb', line 9

def sort_th(label, column, current_sort, current_dir)
  active    = current_sort == column.to_s
  next_dir  = (active && current_dir == "asc") ? "desc" : "asc"
  indicator = active ? (current_dir == "asc" ? "" : "") : ""
  params    = request.query_parameters.merge("sort" => column, "direction" => next_dir)
  href      = "?" + params.to_query
  (:th) do
    link_to(
      "#{label}#{indicator}".html_safe,
      href,
      class: ["qo-sort-link", ("qo-sort-active" if active)].compact.join(" "),
      data: { turbo_frame: "qo-events" }
    )
  end
end