rails-tables 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -12,7 +12,7 @@ A clean jQuery datatables DSL
12
12
  [jqd-railscast]: http://railscasts.com/episodes/340-datatables (Episode #340: Datatables)
13
13
  [squeel]: https://github.com/ernie/squeel (Squeel: ActiveRecord 3, improved)
14
14
 
15
- Version: 0.6.4
15
+ Version: 0.6.5
16
16
 
17
17
  Please refer to the [RailsTables Wiki][wiki] for:
18
18
 
@@ -6,8 +6,8 @@ $ ->
6
6
 
7
7
  @rails_tables = {}
8
8
  @rails_tables.columns = (datatable)->
9
- for column, order of $(datatable).data() when /_ordering/.test(column)
10
- {asSorting: [ order ], aTargets: [ column.substring(0, column.length - "_ordering".length) ]}
9
+ console.log $(datatable).data().order_column, $(datatable).data().order_direction
10
+ asSorting: [ $(datatable).data().order_direction ], aTargets: [ $(datatable).data().order_column ]
11
11
  @rails_tables.params = (datatable) ->
12
12
  (aoData) ->
13
13
  aoData.push
@@ -25,10 +25,9 @@ class RailsTables::Datatable
25
25
  if self.class.source?
26
26
  options[:source] = self.class.source
27
27
  end
28
- unless self.initial_orderings.nil?
29
- self.class.initial_orderings.each do |column, order|
30
- options["#{column}_ordering".to_sym] = order.to_s
31
- end
28
+ if self.initial_order.present?
29
+ options[:order_column] = self.columns.select{|c|c.name==self.class.initial_order.first[0].to_s}.first.order
30
+ options[:order_direction] = self.class.initial_order.first[1]
32
31
  end
33
32
  options[:unsorted] = 'true'
34
33
  options
@@ -68,7 +67,7 @@ class RailsTables::Datatable
68
67
  end
69
68
  # Lazily instanciates and caches columns
70
69
  def columns
71
- @columns ||= self.column_factory.map{ |new_column| RailsTables::Column.new(self.class.name, self.model, new_column[:name], new_column[:args]) }
70
+ @columns ||= self.column_factory.map.with_index{ |new_column, index| RailsTables::Column.new(self.class.name, self.model, new_column[:name], index, new_column[:args]) }
72
71
  end
73
72
 
74
73
  class_attribute :joins
@@ -1,11 +1,12 @@
1
1
  class RailsTables::Column
2
2
 
3
- attr_accessor :table_name, :model, :name, :method, :column_source, :render_with, :blank_value, :virtual, :sortable, :searchable
3
+ attr_accessor :table_name, :model, :name, :order, :method, :column_source, :render_with, :blank_value, :virtual, :sortable, :searchable
4
4
 
5
- def initialize(table_name, model, name, *args)
5
+ def initialize(table_name, model, name, order, *args)
6
6
  self.table_name = table_name
7
7
  self.model = model
8
8
  self.name = name
9
+ self.order = order
9
10
 
10
11
  attributes = args.pop || {}
11
12
  self.method = attributes.fetch(:method, name).to_s
@@ -1,3 +1,3 @@
1
1
  module RailsTables
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-11 00:00:00.000000000 Z
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails