Sha256: 01447992e95acf38bcc72a1b28735ec8228ca5fb38bc33e77694016dd5a87412

Contents?: true

Size: 1.12 KB

Versions: 14

Compression:

Stored size: 1.12 KB

Contents

window.Ransack ?= {}

Ransack.predicates =
  eq: 'not_eq'
  cont: 'not_cont'
  matches: 'does_not_match'
  start: 'not_start'
  end: 'not_end'
  present: 'blank'
  null: 'not_null'
  lt: 'gteq'
  gt: 'lteq'
  in: 'not_in'
  true: 'false'

# Setup supported predicates for each column type.
Ransack.type_predicates = {}
((o, f) -> f.call o) Ransack.type_predicates, ->
  @text = @string = ['eq', 'cont', 'matches', 'start', 'end', 'present', 'in']
  @boolean = ['true', 'null']
  @integer = @float = @decimal = ['eq', 'null', 'lt', 'gt', 'in']
  @date = @datetime = @time = ['eq', 'null', 'lt', 'gt']

# Setup input field types for each predicate
Ransack.predicate_inputs = {}
((o, f) -> f.call o) Ransack.predicate_inputs, ->
  @cont = @matches = @start = @end = @in = 'string'
  @present = @null = @true = false
  @eq = @gt = @lt = (type) ->
    switch type
      when 'string','text' then 'string'
      when 'integer','float','decimal' then 'numeric'
      when 'date','datetime','time' then type
      else false # Hide for unhandled types.

# Use a tags input for 'in' if Select2 is available
if Select2?
  Ransack.predicate_inputs.in = 'tags'

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ransack_ui-1.0.2 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.0.1 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.0.0 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.1.7 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.1.6 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.1.5 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.1.4 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.1.3 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.1.2 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.1.1 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.1.0 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.0.6 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.0.5 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-0.0.4 app/assets/javascripts/ransack/predicates.js.coffee