Sha256: 879af89c268eb9ae8820cdcd4a34c98dea2608b4159acda68988a1d00c56d638

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 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.

# Setup predicates for fixed select options. Includes relevant any/all permutations
Ransack.option_predicates = ['eq', 'eq_any', 'not_eq', 'not_eq_all', 'null', 'not_null']

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

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
fat_free_crm-0.19.0 vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.4.0 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.3.4 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.3.3 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.3.2 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.3.1 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.3.0 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.2.2 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.2.1 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.2.0 app/assets/javascripts/ransack/predicates.js.coffee
ransack_ui-1.1.0 app/assets/javascripts/ransack/predicates.js.coffee